Skip to content

Conversation

@Evalir
Copy link
Member

@Evalir Evalir commented Oct 23, 2025

Adds cursor-based pagination types to the tx-cache crate. This allows us to implement pagination on the cache, and for the tx-cache client to be able to use pagination queries.

Getting all items in one of the collections in the cache is as simple as:

  • getting items in the collection, which will return a PaginationInfo
  • passing the cursor returned from PaginationInfo into the next request. This can easily be done by .into()ing a PaginationInfo into a PaginationParams.
  • do this repeatedly until there are no more pages. PaginationInfo has an utility method to detect this.

These changes are not breaking for the current tx cache consumers.

Copy link
Member Author

Evalir commented Oct 23, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Evalir Evalir force-pushed the evalir/cache-pagination branch 2 times, most recently from 695f90e to 38133ea Compare October 23, 2025 15:52
@Evalir Evalir force-pushed the evalir/cache-pagination branch from 38133ea to 9c99eeb Compare October 23, 2025 16:32
@Evalir Evalir marked this pull request as ready for review October 23, 2025 16:34
@Evalir Evalir requested a review from a team as a code owner October 23, 2025 16:34
Copy link
Member

is this a breaking change for existing consumers of the api? i.e. if they are using an older version of the builder will their builder break if I deploy this version of the tx cache?

@Evalir
Copy link
Member Author

Evalir commented Oct 27, 2025

Not technically a breaking change. The builder will still be able to fetch items from the cache as serde can partially deserialize JSON (it's a self-described format). They will be missing the pagination info, which is fine for now. I've added partial deser tests on the companion pagination PR to confirm this.

@prestwich
Copy link
Member

prestwich commented Oct 30, 2025

these changes are currently breaking, as serde will expect pagination info to be present unless given a specific serde(default) or similar attribute tag

@prestwich
Copy link
Member

I would prefer to see something like:

pub enum CacheResponse<T> { 
    Paginated{
        inner: T,
        pagination: PaginationInfo
    },
    Unpaginated(T),
}

@Evalir
Copy link
Member Author

Evalir commented Oct 31, 2025

took a stab at the suggestion @prestwich, wdyt?

Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add serde roundtrip tests with what you think these json objects should look like.

If pagination params is a query, I don't think it's appropriate to use serde. Instead, there should be a method to apply it to a url?

@Evalir Evalir requested a review from prestwich November 7, 2025 17:42
@Evalir Evalir requested a review from prestwich November 7, 2025 20:17
@Evalir Evalir requested a review from prestwich November 11, 2025 19:05
@Evalir Evalir changed the title feat(tx-cache): Pagination types and impl feat(tx-cache): Pagination types and client impl Nov 11, 2025

/// A query for pagination.
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct PaginationParams<C: CursorKey> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this struct exist now?

@Evalir Evalir force-pushed the evalir/cache-pagination branch from 8ab5d34 to 60b3efa Compare November 12, 2025 17:56
@Evalir Evalir requested a review from prestwich November 12, 2025 19:23
@Evalir Evalir requested a review from prestwich November 12, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants