Skip to content

Commit d55fe64

Browse files
committed
Allow assets to be found based on their leader
Signed-off-by: R.I.Pienaar <[email protected]>
1 parent 974a16e commit d55fe64

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

cli/consumer_command.go

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ type consumerCmd struct {
114114
fReplicas uint
115115
fInvert bool
116116
fExpression string
117+
fLeader string
117118
}
118119

119120
func configureConsumerCommand(app commandHost) {
@@ -206,6 +207,7 @@ func configureConsumerCommand(app commandHost) {
206207
consFind.Flag("idle", "Display consumers with no new deliveries for a period").DurationVar(&c.fIdle)
207208
consFind.Flag("created", "Display consumers created longer ago than duration").PlaceHolder("DURATION").DurationVar(&c.fCreated)
208209
consFind.Flag("replicas", "Display consumers with fewer or equal replicas than the value").PlaceHolder("REPLICAS").UintVar(&c.fReplicas)
210+
consFind.Flag("leader", "Display only clustered streams with a specific leader").PlaceHolder("SERVER").StringVar(&c.fLeader)
209211
consFind.Flag("invert", "Invert the check - before becomes after, with becomes without").BoolVar(&c.fInvert)
210212
consFind.Flag("expression", "Match consumers using an expression language").StringVar(&c.fExpression)
211213

@@ -332,6 +334,9 @@ func (c *consumerCmd) findAction(_ *fisk.ParseContext) error {
332334
if c.fExpression != "" {
333335
opts = append(opts, jsm.ConsumerQueryExpression(c.fExpression))
334336
}
337+
if c.fLeader != "" {
338+
opts = append(opts, jsm.ConsumerQueryLeaderServer(c.fLeader))
339+
}
335340

336341
found, err := stream.QueryConsumers(opts...)
337342
if err != nil {

cli/stream_command.go

+5
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ type streamCmd struct {
141141
fMirrored bool
142142
fMirroredSet bool
143143
fExpression string
144+
fLeader string
144145

145146
listNames bool
146147
vwStartId int
@@ -300,6 +301,7 @@ Finding streams with certain subjects configured:
300301
strFind.Flag("replicas", "Display streams with fewer or equal replicas than the value").PlaceHolder("REPLICAS").UintVar(&c.fReplicas)
301302
strFind.Flag("sourced", "Display that sources data from other streams").IsSetByUser(&c.fSourcedSet).UnNegatableBoolVar(&c.fSourced)
302303
strFind.Flag("mirrored", "Display that mirrors data from other streams").IsSetByUser(&c.fMirroredSet).UnNegatableBoolVar(&c.fMirrored)
304+
strFind.Flag("leader", "Display only clustered streams with a specific leader").PlaceHolder("SERVER").StringVar(&c.fLeader)
303305
strFind.Flag("names", "Show just the stream names").Short('n').UnNegatableBoolVar(&c.listNames)
304306
strFind.Flag("invert", "Invert the check - before becomes after, with becomes without").BoolVar(&c.fInvert)
305307
strFind.Flag("expression", "Match streams using an expression language").StringVar(&c.fExpression)
@@ -786,6 +788,9 @@ func (c *streamCmd) findAction(_ *fisk.ParseContext) (err error) {
786788
if c.fExpression != "" {
787789
opts = append(opts, jsm.StreamQueryExpression(c.fExpression))
788790
}
791+
if c.fLeader != "" {
792+
opts = append(opts, jsm.StreamQueryLeaderServer(c.fLeader))
793+
}
789794

790795
found, err := c.mgr.QueryStreams(opts...)
791796
if err != nil {

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
2121
github.com/klauspost/compress v1.17.9
2222
github.com/mattn/go-isatty v0.0.20
23-
github.com/nats-io/jsm.go v0.1.1-0.20240730140702-7412cdaa18da
23+
github.com/nats-io/jsm.go v0.1.1-0.20240805084700-bd1b67e6e31b
2424
github.com/nats-io/jwt/v2 v2.5.8
2525
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20240724152920-81805a2cd269
2626
github.com/nats-io/nats.go v1.36.0

go.sum

+5-4
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw
5050
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5151
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
5252
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
53+
github.com/google/go-tpm v0.9.0 h1:sQF6YqWMi+SCXpsmS3fd21oPy/vSddwZry4JnmltHVk=
5354
github.com/google/go-tpm v0.9.0/go.mod h1:FkNVkc6C+IsvDI9Jw1OveJmxGZUUaKxtrpOS47QWKfU=
54-
github.com/google/go-tpm v0.9.1 h1:0pGc4X//bAlmZzMKf8iz6IsDo1nYTbYJ6FZN/rg4zdM=
55-
github.com/google/go-tpm v0.9.1/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
5655
github.com/google/pprof v0.0.0-20240509144519-723abb6459b7 h1:velgFPYr1X9TDwLIfkV7fWqsFlf7TeP11M/7kPd/dVI=
5756
github.com/google/pprof v0.0.0-20240509144519-723abb6459b7/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
5857
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
@@ -105,8 +104,10 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
105104
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
106105
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
107106
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
108-
github.com/nats-io/jsm.go v0.1.1-0.20240730140702-7412cdaa18da h1:deLWy/tJeTJaP4xHaOxlaUW3MlJdNYKzYNDBx0kCMC8=
109-
github.com/nats-io/jsm.go v0.1.1-0.20240730140702-7412cdaa18da/go.mod h1:vjS4evCupAu70OOAxuj+GqdTNaERUHCbQ0GZ4z1gO8o=
107+
github.com/nats-io/jsm.go v0.1.1-0.20240730142126-363a3030eec1 h1:pcbtJWZ8NuXCyei4kFZYqhKVFb0Px15vADMMtACQRdY=
108+
github.com/nats-io/jsm.go v0.1.1-0.20240730142126-363a3030eec1/go.mod h1:vjS4evCupAu70OOAxuj+GqdTNaERUHCbQ0GZ4z1gO8o=
109+
github.com/nats-io/jsm.go v0.1.1-0.20240805084700-bd1b67e6e31b h1:s8iOxO6bLxKlyJcdLbbFxArwSgnvuyvcM6VpFgSL2fE=
110+
github.com/nats-io/jsm.go v0.1.1-0.20240805084700-bd1b67e6e31b/go.mod h1:vjS4evCupAu70OOAxuj+GqdTNaERUHCbQ0GZ4z1gO8o=
110111
github.com/nats-io/jwt/v2 v2.5.8 h1:uvdSzwWiEGWGXf+0Q+70qv6AQdvcvxrv9hPM0RiPamE=
111112
github.com/nats-io/jwt/v2 v2.5.8/go.mod h1:ZdWS1nZa6WMZfFwwgpEaqBV8EPGVgOTDHN/wTbz0Y5A=
112113
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20240724152920-81805a2cd269 h1:aZdINfGXdG+6xYLNrlxcdfKb9ttp9Ppk9rqD0d7KErs=

0 commit comments

Comments
 (0)