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 KeysWithFilter methods to KV interface #1655

Open
Jarema opened this issue Jun 20, 2024 · 4 comments · May be fixed by #1711
Open

Add KeysWithFilter methods to KV interface #1655

Jarema opened this issue Jun 20, 2024 · 4 comments · May be fixed by #1711
Labels

Comments

@Jarema
Copy link
Member

Jarema commented Jun 20, 2024

Proposed change

// KeysWithFilters returns a filtered list of keys in the bucket.
KeysWithFilters(filter []string) ([]string, error)


// And for the new, iterable API:
ListKeysWithFilters(filter []string) (KeyLister, error)
	// 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)

We have two separate functions for single and multiple filters, as multiple filters requires server 2.10

reference ADR: https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-8.md?plain=1#L139
reference ADR issue: nats-io/nats-architecture-and-design#289

Use case

nats-io/nats-server#5540

Contribution

No response

@ripienaar
Copy link
Contributor

In the case of go at least, wouldnt a WatchOpt be better? These commands already take those.

@Darshan174
Copy link

Darshan174 commented Jun 20, 2024

Hey please checkout PR #1658, any suggestion would be helpful.

Darshan174 referenced this issue Jun 20, 2024
…d filters and ListKeysWithFilters to provide an iterable list of keys (as suggested). And additionally defined KeyIterator for iterating over keys and a utility function matchesFilters to check if a key meets all filter criteria.
@aditya7302
Copy link

@Jarema is this issue still open. I would like to work on this. Please assign me this issue.

@somratdnutanix
Copy link

Hi @Jarema , worked on the Go one too, would love to have your comments. 😄

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.

5 participants