nats.rs icon indicating copy to clipboard operation
nats.rs copied to clipboard

add `Stream.update_consumer`

Open databasedav opened this issue 1 year ago • 1 comments

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

databasedav avatar Jun 05 '23 05:06 databasedav

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 avatar Jun 11 '23 06:06 Jarema