Skip to content

Commit

Permalink
Add standardized models for cursor based pagination (#949)
Browse files Browse the repository at this point in the history

Co-authored-by: Karthik Ramgopal <kramgopa@linkedin.com>
  • Loading branch information
karthikrg and li-kramgopa authored Nov 29, 2023
1 parent 76980d0 commit 668bff9
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [29.48.3] - 2023-11-28
- Add standardized models for cursor based pagination

## [29.48.2] - 2023-11-27
- Remove usage of Optional from SimpleLoadBalancer

Expand Down Expand Up @@ -5569,7 +5572,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.48.2...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.48.3...master
[29.48.3]: https://github.com/linkedin/rest.li/compare/v29.48.2...v29.48.3
[29.48.2]: https://github.com/linkedin/rest.li/compare/v29.48.1...v29.48.2
[29.48.1]: https://github.com/linkedin/rest.li/compare/v29.48.0...v29.48.1
[29.48.0]: https://github.com/linkedin/rest.li/compare/v29.47.0...v29.48.0
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.48.2
version=29.48.3
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace com.linkedin.restli.common

/**
* Metadata for cursor based pagination with collections.
*/
record CursorPagination {

/**
* Pagination cursor that points to the end of the current page and can be used to fetch the next page.
* Not populated if the current page is the last page.
*/
next: optional string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type" : "record",
"name" : "CursorPagination",
"namespace" : "com.linkedin.restli.common",
"doc" : "Metadata for cursor based pagination with collections.",
"fields" : [ {
"name" : "next",
"type" : "string",
"doc" : "Pagination cursor that points to the end of the current page and can be used to fetch the next page.\nNot populated if the current page is the last page.",
"optional" : true
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.linkedin.restli.server;

import com.linkedin.data.template.RecordTemplate;
import com.linkedin.restli.common.CursorPagination;
import java.util.List;


/**
* Convenience extension to {@link CollectionResult} for use with cursor based pagination.
*/
public class CursorCollectionResult<T extends RecordTemplate> extends CollectionResult<T, CursorPagination>
{
/**
* Constructor
*
* @param elements List of elements in the current page.
* @param pagination The cursor pagination metadata.
*/
public CursorCollectionResult(final List<T> elements, CursorPagination pagination)
{
super(elements, null, pagination);
}
}

0 comments on commit 668bff9

Please sign in to comment.