-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: R.I.Pienaar <[email protected]>
- Loading branch information
Showing
4 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package advisory | ||
|
||
import ( | ||
"github.com/nats-io/jsm.go/api/event" | ||
) | ||
|
||
// JSDomainLeaderElectedV1 is a advisory published when a domain leader is elected | ||
// | ||
// NATS Schema Type io.nats.jetstream.advisory.v1.domain_leader_elected | ||
type JSDomainLeaderElectedV1 struct { | ||
event.NATSEvent | ||
|
||
Leader string `json:"leader"` | ||
Cluster string `json:"cluster"` | ||
Domain string `json:"domain,omitempty"` | ||
Replicas []*PeerInfoV1 `json:"replicas"` | ||
} | ||
|
||
func init() { | ||
err := event.RegisterTextCompactTemplate("io.nats.jetstream.advisory.v1.domain_leader_elected", `{{ .Time | ShortTime }} [RAFT] Domain leader elected {{ .Leader }} in cluster {{.Cluster}} leader of {{ .Replicas | len }} peers`) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
err = event.RegisterTextExtendedTemplate("io.nats.jetstream.advisory.v1.domain_leader_elected", ` | ||
[{{ .Time | ShortTime }}] [{{ .ID }}] Domain Leader Election | ||
Leader: {{ .Leader }} | ||
Cluster: {{ .Cluster }} | ||
{{- if .Domain }} | ||
Domain: {{ .Domain }} | ||
{{- end }} | ||
Replicas: | ||
{{ range .Replicas }} | ||
Name: {{ .Name }} | ||
Current: {{ .Current }} | ||
Active: {{ .Active }} | ||
{{ end }} | ||
`) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
schema_source/jetstream/advisory/v1/domain_leader_elected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://nats.io/schemas/jetstream/advisory/v1/domain_leader_elected.json", | ||
"description": "An Advisory sent when a meta leader is elected", | ||
"title": "io.nats.jetstream.advisory.v1.domain_leader_elected", | ||
"type": "object", | ||
"required": [ | ||
"type", | ||
"id", | ||
"timestamp", | ||
"leader", | ||
"replicas", | ||
"cluster" | ||
], | ||
"additionalProperties": false, | ||
"properties": { | ||
"type": { | ||
"type": "string", | ||
"const": "io.nats.jetstream.advisory.v1.domain_leader_elected" | ||
}, | ||
"id": { | ||
"type": "string", | ||
"description": "Unique correlation ID for this event" | ||
}, | ||
"timestamp": { | ||
"type": "string", | ||
"description": "The time this event was created in RFC3339 format" | ||
}, | ||
"leader": { | ||
"type": "string", | ||
"description": "The server name of the elected leader" | ||
}, | ||
"replicas": { | ||
"$ref": "../../../jetstream/api/v1/definitions.json#/definitions/peer_info" | ||
}, | ||
"cluster": { | ||
"type": "string", | ||
"description": "The cluster holding the leader" | ||
}, | ||
"domain": { | ||
"type": "string", | ||
"description": "The domain the leader is in" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://nats.io/schemas/jetstream/advisory/v1/domain_leader_elected.json", | ||
"description": "An Advisory sent when a meta leader is elected", | ||
"title": "io.nats.jetstream.advisory.v1.domain_leader_elected", | ||
"type": "object", | ||
"required": [ | ||
"type", | ||
"id", | ||
"timestamp", | ||
"leader", | ||
"replicas", | ||
"cluster" | ||
], | ||
"additionalProperties": false, | ||
"properties": { | ||
"type": { | ||
"type": "string", | ||
"const": "io.nats.jetstream.advisory.v1.domain_leader_elected" | ||
}, | ||
"id": { | ||
"type": "string", | ||
"description": "Unique correlation ID for this event" | ||
}, | ||
"timestamp": { | ||
"type": "string", | ||
"description": "The time this event was created in RFC3339 format" | ||
}, | ||
"leader": { | ||
"type": "string", | ||
"description": "The server name of the elected leader" | ||
}, | ||
"replicas": { | ||
"type": "object", | ||
"required": [ | ||
"name", | ||
"current", | ||
"active" | ||
], | ||
"properties": { | ||
"name": { | ||
"description": "The server name of the peer", | ||
"type": "string", | ||
"minimum": 1 | ||
}, | ||
"current": { | ||
"description": "Indicates if the server is up to date and synchronised", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"active": { | ||
"description": "Nanoseconds since this peer was last seen", | ||
"type": "number" | ||
}, | ||
"offline": { | ||
"description": "Indicates the node is considered offline by the group", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"lag": { | ||
"description": "How many uncommitted operations this peer is behind the leader", | ||
"type": "integer", | ||
"minimum": 0 | ||
} | ||
} | ||
}, | ||
"cluster": { | ||
"type": "string", | ||
"description": "The cluster holding the leader" | ||
}, | ||
"domain": { | ||
"type": "string", | ||
"description": "The domain the leader is in" | ||
} | ||
} | ||
} |