-
Notifications
You must be signed in to change notification settings - Fork 698
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 & ListKeysWithFilters methods to KV interface #1658
Conversation
…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.
Closes #1655 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey!
Thanks for your effort.
However, this PR needs quite some work, as it does not do what it should do.
Please take a look at Keys
or ListKeys
to see how we are using ordered consumer
to fetch the keys from the server.
Also, this is where they should be filtered out - by providing subject filters
with appropriate subjects.
@@ -484,6 +484,63 @@ func (js *jetStream) CreateKeyValue(ctx context.Context, cfg KeyValueConfig) (Ke | |||
return nil, err | |||
} | |||
|
|||
// KeysWithFilters returns a filtered list of keys in the bucket. | |||
func (js *jetStream) KeysWithFilters(filter []string) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filtering the keys does not mean filtering them on client side code.
It means passing subject filters
to ordered consumer
. Take a look how ListKeys
or Keys
are implemented.
index int | ||
} | ||
|
||
// NewKeyIterator creates a new KeyIterator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To see how those APIs should work in nats.go client, please take a look at ListKeys
method.
Hey @Jarema! Thank you for your patience in guiding me. I've read through the docs about FilterSubject (I hope this is what you were referring to), but I'd a hard time understanding the implementation of passing subject filters to ordered customers in ListKeys from the Kv.go file. Could you please provide more details on this? |
implemented a method KeysWithFilters to return keys matching specified 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.