From ffa2a509edabc94592ca6860196f3f2586120d65 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Tue, 5 Nov 2024 10:39:47 +0100 Subject: [PATCH] add advisories Signed-off-by: R.I.Pienaar --- api/gen.go | 2 + .../advisory/consumer_group_pinned.go | 33 ++++++++++ .../advisory/consumer_group_unpinned.go | 33 ++++++++++ api/schemas_generated.go | 4 +- .../advisory/v1/consumer_group_pinned.json | 57 +++++++++++++++++ .../advisory/v1/consumer_group_unpinned.json | 58 ++++++++++++++++++ .../advisory/v1/consumer_group_pinned.json | 57 +++++++++++++++++ .../advisory/v1/consumer_group_unpinned.json | 61 +++++++++++++++++++ .../api/v1/consumer_configuration.json | 20 ++++++ .../api/v1/consumer_create_request.json | 20 ++++++ .../api/v1/consumer_create_response.json | 40 ++++++------ .../api/v1/consumer_info_response.json | 40 ++++++------ .../api/v1/consumer_list_response.json | 40 ++++++------ 13 files changed, 404 insertions(+), 61 deletions(-) create mode 100644 api/jetstream/advisory/consumer_group_pinned.go create mode 100644 api/jetstream/advisory/consumer_group_unpinned.go create mode 100644 schema_source/jetstream/advisory/v1/consumer_group_pinned.json create mode 100644 schema_source/jetstream/advisory/v1/consumer_group_unpinned.json create mode 100644 schemas/jetstream/advisory/v1/consumer_group_pinned.json create mode 100644 schemas/jetstream/advisory/v1/consumer_group_unpinned.json diff --git a/api/gen.go b/api/gen.go index 47da4f7..732e11c 100644 --- a/api/gen.go +++ b/api/gen.go @@ -209,6 +209,8 @@ func main() { &schema{P: "jetstream/advisory/v1/consumer_quorum_lost.json", St: "jsadvisory.JSConsumerQuorumLostV1"}, &schema{P: "jetstream/advisory/v1/server_out_of_space.json", St: "jsadvisory.JSServerOutOfSpaceAdvisoryV1"}, &schema{P: "jetstream/advisory/v1/server_removed.json", St: "jsadvisory.JSServerRemovedAdvisoryV1"}, + &schema{P: "jetstream/advisory/v1/consumer_group_pinned.json", St: "jsadvisory.JSConsumerGroupPinnedAdvisoryV1"}, + &schema{P: "jetstream/advisory/v1/consumer_group_unpinned.json", St: "jsadvisory.JSConsumerGroupUnPinnedAdvisoryV1"}, &schema{P: "jetstream/metric/v1/consumer_ack.json", St: "jsmetric.ConsumerAckMetricV1"}, &schema{P: "jetstream/api/v1/consumer_configuration.json", St: "ConsumerConfig"}, &schema{P: "jetstream/api/v1/stream_configuration.json", St: "StreamConfig"}, diff --git a/api/jetstream/advisory/consumer_group_pinned.go b/api/jetstream/advisory/consumer_group_pinned.go new file mode 100644 index 0000000..069bb60 --- /dev/null +++ b/api/jetstream/advisory/consumer_group_pinned.go @@ -0,0 +1,33 @@ +package advisory + +import "github.com/nats-io/jsm.go/api/event" + +// JSConsumerGroupPinnedAdvisoryV1 is an advisory published when a consumer pinned_client grouped consumer pins a client +// +// NATS Schema Type io.nats.jetstream.advisory.v1.consumer_group_pinned +type JSConsumerGroupPinnedAdvisoryV1 struct { + event.NATSEvent + + 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"` +} + +func init() { + err := event.RegisterTextCompactTemplate("io.nats.jetstream.advisory.v1.consumer_group_pinned", `{{ .Time | ShortTime }} [PINNED] Consumer {{ .Stream }} > {{ .Consumer }} pinned client {{ .PinnedClientId }} for group {{ .Group }}`) + if err != nil { + panic(err) + } + + err = event.RegisterTextExtendedTemplate("io.nats.jetstream.advisory.v1.consumer_group_pinned", ` +[{{ .Time | ShortTime }}] [{{ .ID }}] Grouped Consumer Pinned a Client + + Stream: {{ .Stream }} + Consumer: {{ .Consumer }} + Group: {{ .Group }} + Domain: {{ .Domain }} + Pinned Client: {{ .PinnedClientId }}`) +} diff --git a/api/jetstream/advisory/consumer_group_unpinned.go b/api/jetstream/advisory/consumer_group_unpinned.go new file mode 100644 index 0000000..13013bc --- /dev/null +++ b/api/jetstream/advisory/consumer_group_unpinned.go @@ -0,0 +1,33 @@ +package advisory + +import "github.com/nats-io/jsm.go/api/event" + +// JSConsumerGroupUnPinnedAdvisoryV1 is an advisory published when a consumer pinned_client grouped consumer unpins a client +// +// NATS Schema Type io.nats.jetstream.advisory.v1.consumer_group_unpinned +type JSConsumerGroupUnPinnedAdvisoryV1 struct { + event.NATSEvent + + Account string `json:"account,omitempty"` + Stream string `json:"stream"` + Consumer string `json:"consumer"` + Domain string `json:"domain,omitempty"` + Group string `json:"group"` + Reason string `json:"reason"` +} + +func init() { + err := event.RegisterTextCompactTemplate("io.nats.jetstream.advisory.v1.consumer_group_unpinned", `{{ .Time | ShortTime }} [UNPINNED] Consumer {{ .Stream }} > {{ .Consumer }} unpinned client for group {{ .Group }}: {{ .Reason }}`) + if err != nil { + panic(err) + } + + err = event.RegisterTextExtendedTemplate("io.nats.jetstream.advisory.v1.consumer_group_unpinned", ` +[{{ .Time | ShortTime }}] [{{ .ID }}] Grouped Consumer Un-Pinned a Client + + Stream: {{ .Stream }} + Consumer: {{ .Consumer }} + Group: {{ .Group }} + Domain: {{ .Domain }} + Reason: {{ .Reason }}`) +} diff --git a/api/schemas_generated.go b/api/schemas_generated.go index c10cf2a..27c9151 100644 --- a/api/schemas_generated.go +++ b/api/schemas_generated.go @@ -1,4 +1,4 @@ -// auto generated 2024-11-04 14:23:49.004 +0100 CET m=+0.007873084 +// auto generated 2024-11-05 10:39:09.667726 +0100 CET m=+0.015344168 package api @@ -34,6 +34,8 @@ var schemaTypes = map[string]func() any{ "io.nats.jetstream.advisory.v1.consumer_quorum_lost": func() any { return &jsadvisory.JSConsumerQuorumLostV1{} }, "io.nats.jetstream.advisory.v1.server_out_of_space": func() any { return &jsadvisory.JSServerOutOfSpaceAdvisoryV1{} }, "io.nats.jetstream.advisory.v1.server_removed": func() any { return &jsadvisory.JSServerRemovedAdvisoryV1{} }, + "io.nats.jetstream.advisory.v1.consumer_group_pinned": func() any { return &jsadvisory.JSConsumerGroupPinnedAdvisoryV1{} }, + "io.nats.jetstream.advisory.v1.consumer_group_unpinned": func() any { return &jsadvisory.JSConsumerGroupUnPinnedAdvisoryV1{} }, "io.nats.jetstream.metric.v1.consumer_ack": func() any { return &jsmetric.ConsumerAckMetricV1{} }, "io.nats.jetstream.api.v1.consumer_configuration": func() any { return &ConsumerConfig{} }, "io.nats.jetstream.api.v1.stream_configuration": func() any { return &StreamConfig{} }, diff --git a/schema_source/jetstream/advisory/v1/consumer_group_pinned.json b/schema_source/jetstream/advisory/v1/consumer_group_pinned.json new file mode 100644 index 0000000..4cafd93 --- /dev/null +++ b/schema_source/jetstream/advisory/v1/consumer_group_pinned.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/advisory/v1/consumer_group_pinned.json", + "description": "An Advisory sent when a pinned_client grouped consumer pinned a client", + "title": "io.nats.jetstream.advisory.v1.consumer_group_pinned", + "type": "object", + "required": [ + "type", + "id", + "timestamp", + "server", + "stream", + "consumer", + "group", + "pinned_id" + ], + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "const": "io.nats.jetstream.advisory.v1.consumer_group_pinned" + }, + "id": { + "type": "string", + "description": "Unique correlation ID for this event" + }, + "timestamp": { + "type": "string", + "description": "The time this event was created in RFC3339 format" + }, + "account": { + "type": "string", + "description": "The account hosting the consumer" + }, + "stream": { + "type": "string", + "description": "The stream hosting the consumer" + }, + "consumer": { + "type": "string", + "description": "The consumer name" + }, + "domain": { + "type": "string", + "minLength": 1, + "description": "The domain of the JetStreamServer" + }, + "group": { + "type": "string", + "description": "The group that unpinned a client" + }, + "pinned_id": { + "type": "string", + "description": "The unique server-assigned ID for the client" + } + } +} diff --git a/schema_source/jetstream/advisory/v1/consumer_group_unpinned.json b/schema_source/jetstream/advisory/v1/consumer_group_unpinned.json new file mode 100644 index 0000000..fc4c66f --- /dev/null +++ b/schema_source/jetstream/advisory/v1/consumer_group_unpinned.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/advisory/v1/consumer_group_unpinned.json", + "description": "An Advisory sent when a pinned_client grouped consumer unpinned a client", + "title": "io.nats.jetstream.advisory.v1.consumer_group_unpinned", + "type": "object", + "required": [ + "type", + "id", + "timestamp", + "server", + "stream", + "consumer", + "group", + "reason" + ], + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "const": "io.nats.jetstream.advisory.v1.consumer_group_unpinned" + }, + "id": { + "type": "string", + "description": "Unique correlation ID for this event" + }, + "timestamp": { + "type": "string", + "description": "The time this event was created in RFC3339 format" + }, + "account": { + "type": "string", + "description": "The account hosting the consumer" + }, + "stream": { + "type": "string", + "description": "The stream hosting the consumer" + }, + "consumer": { + "type": "string", + "description": "The consumer name" + }, + "domain": { + "type": "string", + "minLength": 1, + "description": "The domain of the JetStreamServer" + }, + "group": { + "type": "string", + "description": "The group that unpinned a client" + }, + "reason": { + "type": "string", + "enum": ["admin", "timeout"], + "description": "The reason the client was unpinned" + } + } +} diff --git a/schemas/jetstream/advisory/v1/consumer_group_pinned.json b/schemas/jetstream/advisory/v1/consumer_group_pinned.json new file mode 100644 index 0000000..4cafd93 --- /dev/null +++ b/schemas/jetstream/advisory/v1/consumer_group_pinned.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/advisory/v1/consumer_group_pinned.json", + "description": "An Advisory sent when a pinned_client grouped consumer pinned a client", + "title": "io.nats.jetstream.advisory.v1.consumer_group_pinned", + "type": "object", + "required": [ + "type", + "id", + "timestamp", + "server", + "stream", + "consumer", + "group", + "pinned_id" + ], + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "const": "io.nats.jetstream.advisory.v1.consumer_group_pinned" + }, + "id": { + "type": "string", + "description": "Unique correlation ID for this event" + }, + "timestamp": { + "type": "string", + "description": "The time this event was created in RFC3339 format" + }, + "account": { + "type": "string", + "description": "The account hosting the consumer" + }, + "stream": { + "type": "string", + "description": "The stream hosting the consumer" + }, + "consumer": { + "type": "string", + "description": "The consumer name" + }, + "domain": { + "type": "string", + "minLength": 1, + "description": "The domain of the JetStreamServer" + }, + "group": { + "type": "string", + "description": "The group that unpinned a client" + }, + "pinned_id": { + "type": "string", + "description": "The unique server-assigned ID for the client" + } + } +} diff --git a/schemas/jetstream/advisory/v1/consumer_group_unpinned.json b/schemas/jetstream/advisory/v1/consumer_group_unpinned.json new file mode 100644 index 0000000..545704f --- /dev/null +++ b/schemas/jetstream/advisory/v1/consumer_group_unpinned.json @@ -0,0 +1,61 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/advisory/v1/consumer_group_unpinned.json", + "description": "An Advisory sent when a pinned_client grouped consumer unpinned a client", + "title": "io.nats.jetstream.advisory.v1.consumer_group_unpinned", + "type": "object", + "required": [ + "type", + "id", + "timestamp", + "server", + "stream", + "consumer", + "group", + "reason" + ], + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "const": "io.nats.jetstream.advisory.v1.consumer_group_unpinned" + }, + "id": { + "type": "string", + "description": "Unique correlation ID for this event" + }, + "timestamp": { + "type": "string", + "description": "The time this event was created in RFC3339 format" + }, + "account": { + "type": "string", + "description": "The account hosting the consumer" + }, + "stream": { + "type": "string", + "description": "The stream hosting the consumer" + }, + "consumer": { + "type": "string", + "description": "The consumer name" + }, + "domain": { + "type": "string", + "minLength": 1, + "description": "The domain of the JetStreamServer" + }, + "group": { + "type": "string", + "description": "The group that unpinned a client" + }, + "reason": { + "type": "string", + "enum": [ + "admin", + "timeout" + ], + "description": "The reason the client was unpinned" + } + } +} diff --git a/schemas/jetstream/api/v1/consumer_configuration.json b/schemas/jetstream/api/v1/consumer_configuration.json index f9b0017..1fbafef 100644 --- a/schemas/jetstream/api/v1/consumer_configuration.json +++ b/schemas/jetstream/api/v1/consumer_configuration.json @@ -284,6 +284,26 @@ "$comment": "A point in time in RFC3339 format including timezone, though typically in UTC", "type": "string", "format": "date-time" + }, + "priority_groups": { + "description": "List of priority groups this consumer supports", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "priority_policy": { + "description": "The policy the consumer is set to", + "type": "string", + "enum": [ + "none", + "overflow", + "pinned_client" + ] + }, + "pinned_ttl": { + "description": "For pinned_client priority policy how long before the client times out" } } } diff --git a/schemas/jetstream/api/v1/consumer_create_request.json b/schemas/jetstream/api/v1/consumer_create_request.json index 6955491..2b72c39 100644 --- a/schemas/jetstream/api/v1/consumer_create_request.json +++ b/schemas/jetstream/api/v1/consumer_create_request.json @@ -296,6 +296,26 @@ "$comment": "A point in time in RFC3339 format including timezone, though typically in UTC", "type": "string", "format": "date-time" + }, + "priority_groups": { + "description": "List of priority groups this consumer supports", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "priority_policy": { + "description": "The policy the consumer is set to", + "type": "string", + "enum": [ + "none", + "overflow", + "pinned_client" + ] + }, + "pinned_ttl": { + "description": "For pinned_client priority policy how long before the client times out" } } }, diff --git a/schemas/jetstream/api/v1/consumer_create_response.json b/schemas/jetstream/api/v1/consumer_create_response.json index d5c44ad..86f8219 100644 --- a/schemas/jetstream/api/v1/consumer_create_response.json +++ b/schemas/jetstream/api/v1/consumer_create_response.json @@ -318,6 +318,26 @@ "$comment": "A point in time in RFC3339 format including timezone, though typically in UTC", "type": "string", "format": "date-time" + }, + "priority_groups": { + "description": "List of priority groups this consumer supports", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "priority_policy": { + "description": "The policy the consumer is set to", + "type": "string", + "enum": [ + "none", + "overflow", + "pinned_client" + ] + }, + "pinned_ttl": { + "description": "For pinned_client priority policy how long before the client times out" } } }, @@ -491,26 +511,6 @@ "type": "string", "format": "date-time" }, - "priority_groups": { - "description": "List of priority groups this consumer supports", - "type": "array", - "items": { - "type": "string", - "minLength": 1 - } - }, - "priority_policy": { - "description": "The policy the consumer is set to", - "type": "string", - "enum": [ - "none", - "overflow", - "pinned_client" - ] - }, - "pinned_ttl": { - "description": "For pinned_client priority policy how long before the client times out" - }, "pinned_ids": { "description": "The IDs pinned by each consumer priority group", "type": "object", diff --git a/schemas/jetstream/api/v1/consumer_info_response.json b/schemas/jetstream/api/v1/consumer_info_response.json index 3389717..8713976 100644 --- a/schemas/jetstream/api/v1/consumer_info_response.json +++ b/schemas/jetstream/api/v1/consumer_info_response.json @@ -318,6 +318,26 @@ "$comment": "A point in time in RFC3339 format including timezone, though typically in UTC", "type": "string", "format": "date-time" + }, + "priority_groups": { + "description": "List of priority groups this consumer supports", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "priority_policy": { + "description": "The policy the consumer is set to", + "type": "string", + "enum": [ + "none", + "overflow", + "pinned_client" + ] + }, + "pinned_ttl": { + "description": "For pinned_client priority policy how long before the client times out" } } }, @@ -491,26 +511,6 @@ "type": "string", "format": "date-time" }, - "priority_groups": { - "description": "List of priority groups this consumer supports", - "type": "array", - "items": { - "type": "string", - "minLength": 1 - } - }, - "priority_policy": { - "description": "The policy the consumer is set to", - "type": "string", - "enum": [ - "none", - "overflow", - "pinned_client" - ] - }, - "pinned_ttl": { - "description": "For pinned_client priority policy how long before the client times out" - }, "pinned_ids": { "description": "The IDs pinned by each consumer priority group", "type": "object", diff --git a/schemas/jetstream/api/v1/consumer_list_response.json b/schemas/jetstream/api/v1/consumer_list_response.json index 9d53a09..e0aeef5 100644 --- a/schemas/jetstream/api/v1/consumer_list_response.json +++ b/schemas/jetstream/api/v1/consumer_list_response.json @@ -383,6 +383,26 @@ "$comment": "A point in time in RFC3339 format including timezone, though typically in UTC", "type": "string", "format": "date-time" + }, + "priority_groups": { + "description": "List of priority groups this consumer supports", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "priority_policy": { + "description": "The policy the consumer is set to", + "type": "string", + "enum": [ + "none", + "overflow", + "pinned_client" + ] + }, + "pinned_ttl": { + "description": "For pinned_client priority policy how long before the client times out" } } }, @@ -556,26 +576,6 @@ "type": "string", "format": "date-time" }, - "priority_groups": { - "description": "List of priority groups this consumer supports", - "type": "array", - "items": { - "type": "string", - "minLength": 1 - } - }, - "priority_policy": { - "description": "The policy the consumer is set to", - "type": "string", - "enum": [ - "none", - "overflow", - "pinned_client" - ] - }, - "pinned_ttl": { - "description": "For pinned_client priority policy how long before the client times out" - }, "pinned_ids": { "description": "The IDs pinned by each consumer priority group", "type": "object",