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

Add filtering to KV method returning all keys #575

Closed
Jarema opened this issue Jun 20, 2024 · 3 comments · Fixed by #602
Closed

Add filtering to KV method returning all keys #575

Jarema opened this issue Jun 20, 2024 · 3 comments · Fixed by #602
Labels

Comments

@Jarema
Copy link
Member

Jarema commented Jun 20, 2024

Here is the revised issue description:

Description

The current method that returns all keys in the bucket does not support filtering specific keys. Adding this functionality would be beneficial, especially when working with large buckets.

Details

Extract from ADR:

	// KeysWithFilters returns a filtered list of keys in the bucket.
	// Historically this method returned a complete slice of all keys in the bucket,
	// however clients should return interable result.
	// Languages can implement the list of filters in most idiomatic way - as an iterator, variadic argument, slice, etc.
	// When multiple filters are passed, client library should check `consumer info` from `consumer create method` if the filters are matching,
	// as nats-server < 2.10 would ignore them.
	KeysWithFilters(filter []string) ([]string, error)

The new method should align with the current library API in terms of signature and behavior for retrieving all keys.

Contribution

This is a good first issue for someone new to the project, as it should be based on the same underlying Ordered Consumer
that the method for receiving all keys is based on, plus the provided subject filters (and properly kv handled prefixes).

References

@Jarema Jarema added good first issue Good for newcomers help wanted labels Jun 20, 2024
@aryan-py
Copy link

aryan-py commented Jul 10, 2024

I would love to take this up as my first issue and would love any advice about the project and the issue.

somratdutta pushed a commit to somratdutta/nats.py that referenced this issue Sep 4, 2024
…cket

- Added KeysWithFilters method to KeyValue store to allow retrieving keys that match specific filters.
- The method returns a list of keys from the KV bucket, applying the provided filters for pattern matching.
- Checks consumer info to ensure filters are properly supported by the NATS server, with warnings for server versions < 2.10.

Resolves: [nats-io#575](nats-io#575)
@somratdutta
Copy link

Ho @Jarema would love to have your comments on this PR.

@Jarema
Copy link
Member Author

Jarema commented Sep 4, 2024

thanks @somratdutta ! We will take a look at that PR shortly!

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

Successfully merging a pull request may close this issue.

3 participants