nats-io/nats.rs

Add kv::keys with filters

Jarema opened this issue · 4 comments

Proposed change

Add two new methods:

pub async fn keys_with_filters(&self, F) -> Result<Keys, HistoryError>

keys_with_fitlters require a feature flag server_2_10. That is also the reason why they are separated, instead of one method taking interator of sorts.

https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-8.md?plain=1#L139
Reference ADR issue: nats-io/nats-architecture-and-design#289

Use case

nats-io/nats-architecture-and-design#289

Contribution

No response

Can I try to work on this? I'm a noobie on rust though!

Sure, go ahead!
It should be pretty simple, like normal keys, just with filter(s) passed to the underlying ordered consumer.

are unit test working? I tried to run cargo test (both on the whole project and only on keys() and get errors.

running 1 test
test kv::keys ... FAILED

failures:

---- kv::keys stdout ----
thread 'kv::keys' panicked at nats-server/src/lib.rs:268:29:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    kv::keys

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 19 filtered out; finished in 0.01s

error: test failed, to rerun pass `-p async-nats --test kv_tests`

EDIT: Sorry, I got where the error comes from.

As we updated the ADR to have just one method, please re-check the description.