nats-io / nats.py

Python3 client for NATS
https://nats-io.github.io/nats.py/
Apache License 2.0
902 stars 193 forks source link

Ability to delete a consumer #567

Open superlevure opened 5 months ago

superlevure commented 5 months ago

Proposed change

I haven't found a way to delete a consumer using the Python SDK, the official documentation shows how to do it in Go using the DeleteConsumer method, but it doesn't seem to exist in nats.py.

Calling sub.unsubscribe() doesn't delete the consumer either.

Use case

My App is creating a one off pull based consumer and it needs to clean it after the work is done. I don't want to use an ephemeral consumer because I want to give it a name, and I need to explicitly control its lifecycle.

Contribution

If the proposal is accepted I'm willing to push a PR.

superlevure commented 5 months ago

Actually my bad, there is a delete_consumer method exposed in JetStreamManager: https://github.com/nats-io/nats.py/blob/fe305ac92b9e1d8a762c9eec2a6c4ab98f7500be/nats/js/manager.py#L226

It is not documented in the SDK documentation though: https://nats-io.github.io/nats.py/search.html?q=delete_consumer&check_keywords=yes&area=default#

dudwe commented 1 week ago

Hey - I can update the docs for this!