From c523e34e881b778e0b2d518b4f1d6767ed39135b 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 | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/adr/ADR-42.md b/adr/ADR-42.md index 637b88c..c80b2a3 100644 --- a/adr/ADR-42.md +++ b/adr/ADR-42.md @@ -174,4 +174,40 @@ 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 JSAdvisoryConsumerPinnedPre = "$JS.EVENT.ADVISORY.CONSUMER.PINNED" +const JSAdvisoryConsumerUnpinnedPre = "$JS.EVENT.ADVISORY.CONSUMER.UNPINNED" +const JSConsumerGroupPinnedAdvisoryType = "io.nats.jetstream.advisory.v1.consumer_group_pinned" + +// JSConsumerGroupPinnedAdvisory indicates that a group switched to a new pinned client +type JSConsumerGroupPinnedAdvisory 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 JSConsumerGroupUnPinnedAdvisoryType = "io.nats.jetstream.advisory.v1.consumer_group_unpinned" + +// JSConsumerGroupUnPinnedAdvisory indicates that a pin was lost +type JSConsumerGroupUnPinnedAdvisory 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