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 & ListKeysWithFilters methods to KV interface #1658

Closed
wants to merge 2 commits into from
Closed

Add KeysWithFilter & ListKeysWithFilters methods to KV interface #1658

wants to merge 2 commits into from

Conversation

Darshan174
Copy link

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.

…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.
@Darshan174
Copy link
Author

Closes #1655

Copy link
Member

@Jarema Jarema left a 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) {
Copy link
Member

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.
Copy link
Member

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.

@Darshan174
Copy link
Author

Darshan174 commented Jun 22, 2024

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?

@Darshan174 Darshan174 closed this Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants