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

Add PausedUntil to consumer config #1554

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions jetstream/consumer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ type (

// TimeStamp indicates when the info was gathered by the server.
TimeStamp time.Time `json:"ts"`

// Paused reports if the consumer is currently paused or not.
Paused bool `json:"paused,omitempty"`

// PauseRemaining contains the amount of time left until the consumer
// unpauses. It will only be non-zero if the consumer is currently paused.
PauseRemaining time.Duration `json:"pause_remaining,omitempty"`
}

// ConsumerConfig is the configuration of a JetStream consumer.
Expand Down Expand Up @@ -217,6 +224,15 @@ type (
// associating metadata on the consumer. This feature requires
// nats-server v2.10.0 or later.
Metadata map[string]string `json:"metadata,omitempty"`

// PauseUntil pauses the consumer until the given deadline. When
// paused, the consumer will continue to send heartbeats but will not
// deliver any messages. The consumer will unpause automatically when
// the deadline is reached and messages will flow again automatically.
// Setting this to a zero timestamp, or any time in the past, results
// in the consumer being unpaused.
// This feature requires nats-server v2.11.0 or later.
PauseUntil time.Time `json:"pause_until,omitempty"`
}

// OrderedConsumerConfig is the configuration of an ordered JetStream
Expand Down
9 changes: 9 additions & 0 deletions js.go
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,15 @@ type ConsumerConfig struct {
// Keys starting with `_nats` are reserved.
// NOTE: Metadata requires nats-server v2.10.0+
Metadata map[string]string `json:"metadata,omitempty"`

// PauseUntil pauses the consumer until the given deadline. When
// paused, the consumer will continue to send heartbeats but will not
// deliver any messages. The consumer will unpause automatically when
// the deadline is reached and messages will flow again automatically.
// Setting this to a zero timestamp, or any time in the past, results
// in the consumer being unpaused.
// NOTE: Consumer pause requires nats-server v2.11.0+
PauseUntil time.Time `json:"pause_until,omitempty"`
}

// ConsumerInfo is the info from a JetStream consumer.
Expand Down