nats.go icon indicating copy to clipboard operation
nats.go copied to clipboard

Add `KeysWithFilter` methods to KV interface

Open Jarema opened this issue 1 year ago • 4 comments

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: https://github.com/nats-io/nats-architecture-and-design/issues/289

Use case

https://github.com/nats-io/nats-server/issues/5540

Contribution

No response

Jarema avatar Jun 20 '24 04:06 Jarema

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

ripienaar avatar Jun 20 '24 09:06 ripienaar

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

Darshan174 avatar Jun 20 '24 10:06 Darshan174

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

aditya7302 avatar Jul 01 '24 18:07 aditya7302

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

somratdnutanix avatar Sep 05 '24 06:09 somratdnutanix