Skip to content

Commit

Permalink
add advisories
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Nov 5, 2024
1 parent bc1e289 commit ffa2a50
Show file tree
Hide file tree
Showing 13 changed files with 404 additions and 61 deletions.
2 changes: 2 additions & 0 deletions api/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
33 changes: 33 additions & 0 deletions api/jetstream/advisory/consumer_group_pinned.go
Original file line number Diff line number Diff line change
@@ -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 }}`)
}
33 changes: 33 additions & 0 deletions api/jetstream/advisory/consumer_group_unpinned.go
Original file line number Diff line number Diff line change
@@ -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 }}`)
}
4 changes: 3 additions & 1 deletion api/schemas_generated.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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{} },
Expand Down
57 changes: 57 additions & 0 deletions schema_source/jetstream/advisory/v1/consumer_group_pinned.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
58 changes: 58 additions & 0 deletions schema_source/jetstream/advisory/v1/consumer_group_unpinned.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
57 changes: 57 additions & 0 deletions schemas/jetstream/advisory/v1/consumer_group_pinned.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
61 changes: 61 additions & 0 deletions schemas/jetstream/advisory/v1/consumer_group_unpinned.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
20 changes: 20 additions & 0 deletions schemas/jetstream/api/v1/consumer_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
20 changes: 20 additions & 0 deletions schemas/jetstream/api/v1/consumer_create_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down
Loading

0 comments on commit ffa2a50

Please sign in to comment.