Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds update_consumer to nats.py #503

Open
theworksofvon opened this issue Oct 9, 2023 · 0 comments
Open

Adds update_consumer to nats.py #503

theworksofvon opened this issue Oct 9, 2023 · 0 comments
Labels
proposal Enhancement idea or proposal

Comments

@theworksofvon
Copy link

theworksofvon commented Oct 9, 2023

What motivated this proposal?

Add an update_consumer method for jet stream, same as the one in the javascript library.

What is the proposed change?

pretty much a copy/paste of add_consumer just updated subject to "CONSUMER.UPDATE"

 async def update_consumer(
            self,
            stream: str,
            consumer: str,
            config: Optional[api.ConsumerUpdateConfig] = None,  # Assuming a similar class exists
            timeout: Optional[float] = None,
            **params,
        ) -> api.ConsumerInfo:
        if not timeout:
            timeout = self._timeout
        if config is None:
            config = api.ConsumerUpdateConfig()  # Assuming a similar class exists
        config = config.evolve(**params)  
        
        req = {"stream_name": stream, "consumer_name": consumer, "config": config.as_dict()}  # Adjusted key names
        req_data = json.dumps(req).encode()

        # The subject format is speculative and should be replaced with the correct format.
        subject = f"{self._prefix}.CONSUMER.UPDATE.{stream}.{consumer}"  

        resp = await self._api_request(subject, req_data, timeout=timeout)
        return api.ConsumerInfo.from_response(resp)

Who benefits from this change?

Everyone. Allows changeable items in the consumer configs to be updated.

What alternatives have you evaluated?

The only alternative is to delete and recreate a new consumer. Which is not the most suitable option.

@theworksofvon theworksofvon added the proposal Enhancement idea or proposal label Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal
Projects
None yet
Development

No branches or pull requests

1 participant