nats-io / nats.c

A C client for NATS
Apache License 2.0
382 stars 132 forks source link

Add filtering to KV method returning all keys #766

Open Jarema opened 2 months ago

Jarema commented 2 months 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