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

Consumer Action API #276

Open
4 of 16 tasks
Jarema opened this issue Apr 3, 2024 · 2 comments
Open
4 of 16 tasks

Consumer Action API #276

Jarema opened this issue Apr 3, 2024 · 2 comments
Labels
client Client related work enhancement New feature or request

Comments

@Jarema
Copy link
Member

Jarema commented Apr 3, 2024

Overview

Since nats-server 2.10, Consumer Create API ($JS.API.CONSUMER.CREATE & $JS.API.CONSUMER.DURABLE.CREATE) support action` field.

This allows for clients to specify the intent when calling CREATE, which in turn allows for reduction of CONSUMER.INFO calls by the clients to figure out what to do and what is the state of the server/cluster.

type CreateConsumerRequest struct {
	Stream string         `json:"stream_name"`
	Config ConsumerConfig `json:"config"`
	// a new added field
	Action ConsumerAction `json:"action"`
}

There are three possible values for the action:

- "create"
- "update"
- ""

Empty value (default)

If field is not passed, or it's an empty string, it's the same behavior as before this change was intruduced.
It will create consumer if it was not there, and update it if its found.

Older clients will automatically default to this variant.

create

Consumer will be created only if consumer was not there.
If consumer is present, error 10148 will be returned.

Error will not be returned if the consumer is there, but with exactly the same config.
That allows clients to send a retry without a risk to get misleading errors (timeout after first call, already exist at second).

update

Consumer will be updated.
If consumer does not exist, error 10149 will be returned.

Server PR: https://github.com/nats-io/nats-server/pull/4217/files

Clients and Tools

Other Tasks

  • docs.nats.io updated @bruth
  • Update ADR to Implemented
  • Update client features spreadsheet

Client authors please update with your progress. If you open issues in your own repositories as a result of this request, please link them to this one by pasting the issue URL in a comment or main issue description.

@Jarema Jarema added enhancement New feature or request client Client related work labels Apr 3, 2024
@Jarema
Copy link
Member Author

Jarema commented Apr 3, 2024

javascript clients: nats-io/nats.deno#552

@Jarema
Copy link
Member Author

Jarema commented Apr 3, 2024

go: nats-io/nats.go#1300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related work enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants