From 49ed0c9a618d2d3fd23790990e773a69f296aab0 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Thu, 1 Aug 2024 09:57:35 +0300 Subject: [PATCH] Add advisories for pull consumer groups Signed-off-by: R.I.Pienaar --- adr/ADR-42.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/adr/ADR-42.md b/adr/ADR-42.md index 637b88c..89d7d85 100644 --- a/adr/ADR-42.md +++ b/adr/ADR-42.md @@ -174,4 +174,38 @@ type PriorityGroupState struct { Future iterations will include delivery stats per group. Once multiple groups are supported consumer updates could add and remove groups. Today only the `PriorityTimeout` -setting supports being updated. \ No newline at end of file +setting supports being updated. + +#### Advisories + +We will publish advisories when a switch is performed and when a pin is lost. + +```golang +const JSStreamGroupPinnedAdvisoryType = "io.nats.jetstream.advisory.v1.consumer_group_pinned" + +// JSStreamGroupPinnedAdvisory that a group switched to a new pinned client +type JSStreamGroupPinnedAdvisory struct { + TypedEvent + Account string `json:"account,omitempty"` + Stream string `json:"stream"` + Consumer string `json:"consumer"` + Domain string `json:"domain,omitempty"` + Group string `json:"group"` + PinnedClientId string `json:"pinned_id"` + Client *ClientInfo `json:"client"` // if available +} + +const JSStreamGroupUnPinnedAdvisoryType = "io.nats.jetstream.advisory.v1.consumer_group_unpinned" + +// JSStreamGroupUnPinnedAdvisory indicates that a pin was lost +type JSStreamGroupUnPinnedAdvisory struct { + TypedEvent + Account string `json:"account,omitempty"` + Stream string `json:"stream"` + Consumer string `json:"consumer"` + Domain string `json:"domain,omitempty"` + Group string `json:"group"` + // one of "admin" or "timeout", could be an enum up to the implementor to decide + Reason string `json:"reason"` +} +``` \ No newline at end of file