nats-io / nats-architecture-and-design

Architecture and Design Docs
Apache License 2.0
170 stars 20 forks source link

Support consumer pause #266

Open ripienaar opened 2 months ago

ripienaar commented 2 months ago

Overview

In 2.11 consumers can be paused using the API and optionally started paused.

Clients should at the very least support the added fields to config and state for consumers, but might be handy to also add some utilities.

Initial server issue https://github.com/nats-io/nats-server/issues/4966

NOTE This is not merged at the moment, hold until merged. Also review the PR or schemas rather than the Issue for latest implementation detail

Clients and Tools

Other Tasks

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 commented 2 months ago

The PR has been merged: https://github.com/nats-io/nats-server/pull/5066

Schemas PR, which is probably the best source of information how to implement the feature: https://github.com/nats-io/jsm.go/pull/522/files

Request and response schemas:

// io.nats.jetstream.api.v1.consumer_pause_request
type JSApiConsumerPauseRequest struct {
    PauseUntil time.Time `json:"pause_until,omitempty"`
}

// io.nats.jetstream.api.v1.consumer_pause_response
type JSApiConsumerPauseResponse struct {
    JSApiResponse
    Paused         bool          `json:"paused"`
    PauseUntil     time.Time     `json:"pause_until"`
    PauseRemaining time.Duration `json:"pause_remaining,omitempty"`
}

Consumer info includes 2 new fields:

Paused bool json:"paused,omitempty" PauseRemaining time.Duration json:"pause_remaining,omitempty" The paused state and time time would need to be persisted to the raft layer such that server restarts would not unpause paused consumers. This is done using the consumer configuration that has a new value:

PauseUntil time.Time json:"pause_until,omitempty"

yordis commented 2 months ago

Go Client: https://github.com/nats-io/nats.go/pull/1571

MauriceVanVeen commented 2 months ago

Java client: https://github.com/nats-io/nats.java/pull/1093

MauriceVanVeen commented 1 month ago

.NET.v2 client: https://github.com/nats-io/nats.net.v2/pull/432

yordis commented 1 month ago

Rust Client: https://github.com/nats-io/nats.rs/pull/1234

levb commented 1 month ago

C: https://github.com/nats-io/nats.c/pull/726

bruth commented 1 month ago

☝️ All of these contributions are so cool to see 😄