Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination to Jetstream KV #1738

Open
m13t opened this issue Nov 19, 2024 · 1 comment
Open

Pagination to Jetstream KV #1738

m13t opened this issue Nov 19, 2024 · 1 comment
Labels
proposal Enhancement idea or proposal

Comments

@m13t
Copy link

m13t commented Nov 19, 2024

Proposed change

It would be nice to have pagination built in to the Jetstream KV operations. I know internally, I could load the stream and fetch a batch with a given size and start sequence to achieve this, but it would be a lot cleaner if this was supported in the KV api to match operations supported by traditional KV stores.

As this functionality is technically there for streams already, it's more a case of adding syntactical sugar to the API rather than having to create this functionality from scratch.

Use case

Whilst it is currently possible to get a list of keys in a KV bucket already, this is channel based with no option to specify a starting sequence as this is itself just sugar for the watcher implementation (which also does not support start sequence).

In situations where it is not desirable or feasible to load all keys into memory and paginate from the in-memory list, it would be very useful to be able to simply retrieve a list of keys of a given size starting with an optional sequence number. This way state would not need to be stored within an application that is batch iterating over keys in a bucket, such as perhaps a web-based application that's displaying a list of keys in a given bucket.

Contribution

I'm not overly familiar with the codebase beyond the exposed APIs but I would be happy to attempt the implementation. However, I did note that the internal stream sequence number is not exposed on values retrieved from a KV bucket either via Get or from KeyValueEntry interface.

@m13t m13t added the proposal Enhancement idea or proposal label Nov 19, 2024
@ripienaar
Copy link
Contributor

Nats 2.11 introduces batching on the direct get method we use to get data from streams for KV so should become easier to add.

We have a few more improvements specifically for KV coming in 2.11 so clients could take a bit to get it all but it’s on the cards for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

2 participants