nats-io / nats.rs

Rust client for NATS, the cloud native messaging system.
Apache License 2.0
1.06k stars 168 forks source link

add `Stream.update_consumer` #987

Closed databasedav closed 5 months ago

databasedav commented 1 year ago

Use case

updating consumers at runtime, useful for running consumer migrations

one thing i'm unsure of (i haven't been able to find any docs on updating consumers) is the broader effects of a consumer update, e.g. does the server need to be restarted for the changes to take effect? will the effects apply to existing consumer clients (e.g. a consumer configuration stored on client may be out of sync with the server, but the consumer operates with the updated configuration because the configuration contracts are entirely enforced by the server)?

i noticed that the python client also does not have an update_consumer method, although natscli does (called with nats con edit ...) and ends up calling the NewConsumerFromDefault function and i'm not a good enough go reader to deduce the effects of what seems to be some sort of overwriting update/edit

Proposed change

add a Stream.update_consumer method, ideally requiring minimal higher level intervention in a distributed environment, e.g. clients in separate processes communicating with the same consumer eventually synchronize with the updated consumer on server, without having to restart the server or restart all clients

Who benefits from the change(s)?

those who want dynamic consumer configuration

Alternative Approaches

No response

Jarema commented 1 year ago

Hey.

The mismatch between clients comes from the fact, that initially, JetStream didn't support updating consumers. Currently, you can update consumer via calling create again.

When the new addition to the server will be merged https://github.com/nats-io/nats-server/pull/4217 , I will update rust client to have proper update method.

Jarema commented 5 months ago

Hey. This has been released in v0.35.0. Closing the issue.