nats-io / nats.net.v2

Full Async C# / .NET client for NATS
https://nats-io.github.io/nats.net.v2/
Apache License 2.0
202 stars 40 forks source link

Add filtering to KV method returning all keys #521

Closed Jarema closed 4 days ago

Jarema commented 2 weeks ago

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