nats-io / nats.rs

Rust client for NATS, the cloud native messaging system.
Apache License 2.0
980 stars 159 forks source link

Fix: adds new filters functions #1281

Open TheGhoul21 opened 1 week ago

TheGhoul21 commented 1 week ago

1280

I think that actually everything could be brought to a unique implementation where we fill OrderedConfig with the correct additional key (namely filter_subject and filter_subjects).

Since is my very first commit I wasn't sure about that.

Jarema commented 1 week ago

Yes, this is correct. We were discussing having separate methods only because of compatibility with server version.

Instead we landed on this: https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-8.md?plain=1#L139

// 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)
TheGhoul21 commented 1 week ago

ok, I changed the code. I hope the way I instantiate the config is fine. Tests are passing, I'm just not sure if it's the most idiomatic way to implement this.