Skip to content

Commit

Permalink
Merge pull request #594 from ripienaar/preferred_placement
Browse files Browse the repository at this point in the history
Support preferred leader in step down and asset placement
  • Loading branch information
ripienaar authored Dec 20, 2024
2 parents 2a95464 + 18bad9f commit 8b9ee4d
Show file tree
Hide file tree
Showing 23 changed files with 204 additions and 61 deletions.
7 changes: 4 additions & 3 deletions api/streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,11 @@ type StreamConsumerLimits struct {
MaxAckPending int `json:"max_ack_pending,omitempty" yaml:"max_ack_pending"`
}

// Placement describes stream placement requirements for a stream
// Placement describes stream placement requirements for a stream or leader
type Placement struct {
Cluster string `json:"cluster,omitempty" yaml:"cluster"`
Tags []string `json:"tags,omitempty" yaml:"tags"`
Cluster string `json:"cluster,omitempty" yaml:"cluster"`
Tags []string `json:"tags,omitempty" yaml:"tags"`
Preferred string `json:"preferred,omitempty" yaml:"preferred"`
}

// StreamSourceInfo shows information about an upstream stream source.
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/jedib0t/go-pretty/v6 v6.6.5
github.com/klauspost/compress v1.17.11
github.com/nats-io/jwt/v2 v2.7.3
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241216161640-d32daa29debe
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241219180704-470a7acda496
github.com/nats-io/nats.go v1.37.0
github.com/nats-io/nkeys v0.4.9
github.com/nats-io/nuid v1.0.1
Expand All @@ -24,7 +24,6 @@ require (
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/goccy/go-json v0.10.4 // indirect
github.com/google/go-tpm v0.9.2 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
Expand All @@ -34,7 +33,6 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/time v0.8.0 // indirect
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/expr-lang/expr v1.16.9 h1:WUAzmR0JNI9JCiF0/ewwHB1gmcGw5wW7nWt8gc6PpCI=
github.com/expr-lang/expr v1.16.9/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-tpm v0.9.2 h1:Gh8CMnMm06b09DmcsuY9fI3oF69188lGXCpiT/a05T4=
Expand All @@ -31,10 +29,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nats-io/jwt/v2 v2.7.3 h1:6bNPK+FXgBeAqdj4cYQ0F8ViHRbi7woQLq4W29nUAzE=
github.com/nats-io/jwt/v2 v2.7.3/go.mod h1:GvkcbHhKquj3pkioy5put1wvPxs78UlZ7D/pY+BgZk4=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241127165413-cfaad68e19db h1:XSsKLcdTjNwRhhiPS2G193zgh7yCHjT5IRzRyTuI/Y0=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241127165413-cfaad68e19db/go.mod h1:nI8h87Ryi/zcaQcDLSSVbMfomhyck+0oDqxR7NoZX0Y=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241216161640-d32daa29debe h1:IrqVL1wnRhZ06wJGHMIzBcjr2gzMlRsY1OuDWIXBQwY=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241216161640-d32daa29debe/go.mod h1:Ky5GDRMam5300yCf1N+pD0apW7TqfVvTNgYEvbXtnE8=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241219180704-470a7acda496 h1:NT7IPFPqkHccMqQWFoCOATlBLR+POK1sqFx4oOX3bAY=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20241219180704-470a7acda496/go.mod h1:Ky5GDRMam5300yCf1N+pD0apW7TqfVvTNgYEvbXtnE8=
github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE=
github.com/nats-io/nats.go v1.37.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
github.com/nats-io/nkeys v0.4.9 h1:qe9Faq2Gxwi6RZnZMXfmGMZkg3afLLOtrU+gDZJ35b0=
Expand All @@ -58,8 +54,6 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/exp v0.0.0-20241215155358-4a5509556b9e h1:4qufH0hlUYs6AO6XmZC3GqfDPGSXHVXUFR6OND+iJX4=
Expand Down
10 changes: 7 additions & 3 deletions schema_source/jetstream/api/v1/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,22 @@
},
"placement": {
"type": "object",
"description": "Placement requirements for a stream",
"description": "Placement requirements for a Stream or asset leader",
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
31 changes: 26 additions & 5 deletions schemas/jetstream/api/v1/consumer_create_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,32 @@
"type": "string",
"format": "date-time"
},
"pinned_ids": {
"description": "The IDs pinned by each consumer priority group",
"type": "object",
"additionalProperties": {
"type": "string"
"priority_groups": {
"description": "The state of Priority Groups",
"type": "array",
"items": {
"required": [
"group"
],
"type": "object",
"description": "Status of a specific consumer priority group",
"properties": {
"group": {
"type": "string",
"description": "The group this status is for",
"minLength": 1
},
"pinned_client_id": {
"type": "string",
"description": "The generated ID of the pinned client"
},
"pinned_ts": {
"description": "The timestamp when the client was pinned",
"$comment": "A point in time in RFC3339 format including timezone, though typically in UTC",
"type": "string",
"format": "date-time"
}
}
}
}
}
Expand Down
31 changes: 26 additions & 5 deletions schemas/jetstream/api/v1/consumer_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,32 @@
"type": "string",
"format": "date-time"
},
"pinned_ids": {
"description": "The IDs pinned by each consumer priority group",
"type": "object",
"additionalProperties": {
"type": "string"
"priority_groups": {
"description": "The state of Priority Groups",
"type": "array",
"items": {
"required": [
"group"
],
"type": "object",
"description": "Status of a specific consumer priority group",
"properties": {
"group": {
"type": "string",
"description": "The group this status is for",
"minLength": 1
},
"pinned_client_id": {
"type": "string",
"description": "The generated ID of the pinned client"
},
"pinned_ts": {
"description": "The timestamp when the client was pinned",
"$comment": "A point in time in RFC3339 format including timezone, though typically in UTC",
"type": "string",
"format": "date-time"
}
}
}
}
}
Expand Down
31 changes: 26 additions & 5 deletions schemas/jetstream/api/v1/consumer_list_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,32 @@
"type": "string",
"format": "date-time"
},
"pinned_ids": {
"description": "The IDs pinned by each consumer priority group",
"type": "object",
"additionalProperties": {
"type": "string"
"priority_groups": {
"description": "The state of Priority Groups",
"type": "array",
"items": {
"required": [
"group"
],
"type": "object",
"description": "Status of a specific consumer priority group",
"properties": {
"group": {
"type": "string",
"description": "The group this status is for",
"minLength": 1
},
"pinned_client_id": {
"type": "string",
"description": "The generated ID of the pinned client"
},
"pinned_ts": {
"description": "The timestamp when the client was pinned",
"$comment": "A point in time in RFC3339 format including timezone, though typically in UTC",
"type": "string",
"format": "date-time"
}
}
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions schemas/jetstream/api/v1/meta_leader_stepdown_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
"properties": {
"placement": {
"type": "object",
"description": "Placement requirements for a stream",
"description": "Placement requirements for a Stream or asset leader",
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions schemas/jetstream/api/v1/stream_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,18 @@
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions schemas/jetstream/api/v1/stream_create_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,18 @@
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions schemas/jetstream/api/v1/stream_create_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,18 @@
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions schemas/jetstream/api/v1/stream_info_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,18 @@
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions schemas/jetstream/api/v1/stream_list_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,18 @@
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions schemas/jetstream/api/v1/stream_restore_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,18 @@
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
8 changes: 6 additions & 2 deletions schemas/jetstream/api/v1/stream_snapshot_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@
"properties": {
"cluster": {
"type": "string",
"description": "The desired cluster name to place the stream"
"description": "The desired cluster name"
},
"tags": {
"description": "Tags required on servers hosting this stream",
"description": "Tags required on servers hosting this stream or leader",
"type": "array",
"items": {
"type": "string"
}
},
"preferred": {
"description": "A preferred server name to move the leader to",
"type": "string"
}
}
},
Expand Down
Loading

0 comments on commit 8b9ee4d

Please sign in to comment.