nats-architecture-and-design icon indicating copy to clipboard operation
nats-architecture-and-design copied to clipboard

Support consumer pause

Open ripienaar opened this issue 1 year ago • 7 comments
trafficstars

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

  • [x] Schemas @ripienaar
  • [x] CLI @ripienaar
  • [ ] Terraform @ripienaar
  • [ ] Go @piotrpio https://github.com/nats-io/nats.go/pull/1571
  • [x] Java @scottf https://github.com/nats-io/nats.java/pull/1093 @MauriceVanVeen
  • [x] JavaScript @aricart https://github.com/nats-io/nats.deno/pull/653
  • [x] .Net @scottf https://github.com/nats-io/nats.net/pull/874
  • [x] C @levb
  • [ ] Python @wallyqs
  • [ ] Ruby @wallyqs
  • [x] Rust @Jarema
  • [ ] .Net V2 @mtmk

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.

ripienaar avatar Feb 19 '24 14:02 ripienaar

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"

Jarema avatar Feb 26 '24 16:02 Jarema

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

yordis avatar Feb 27 '24 22:02 yordis

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

MauriceVanVeen avatar Mar 04 '24 21:03 MauriceVanVeen

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

MauriceVanVeen avatar Mar 06 '24 20:03 MauriceVanVeen

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

yordis avatar Mar 14 '24 00:03 yordis

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

levb avatar Mar 15 '24 15:03 levb

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

bruth avatar Mar 15 '24 17:03 bruth