@@ -33,30 +33,40 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
3333 { :validation_failure , :too_many_args }
3434 end
3535
36- def validate ( [ _ , s ] , _ )
36+ def validate ( args = [ n , s ] , opts ) do
37+ case Integer . parse ( n ) do
38+ { cluster_size , _ } when is_integer ( cluster_size ) ->
39+ do_validate ( [ cluster_size , s ] , opts )
40+
41+ :error ->
42+ do_validate ( args , opts )
43+ end
44+ end
45+
46+ def do_validate ( [ _ , s ] , _ )
3747 when not ( s == "all" or
3848 s == "even" ) do
3949 { :validation_failure , "strategy '#{ s } ' is not recognised." }
4050 end
4151
42- def validate ( [ n , _ ] , _ )
52+ def do_validate ( [ n , _ ] , _ )
4353 when ( is_integer ( n ) and n <= 0 ) do
4454 { :validation_failure , "target quorum cluster size '#{ n } ' must be greater than 0." }
4555 end
4656
47- def validate ( [ n , _ ] , % { membership: m } )
57+ def do_validate ( [ n , _ ] , % { membership: m } )
4858 when ( is_integer ( n ) and not ( m == "voter" or m == "promotable" ) ) do
4959 { :validation_failure , "voter status '#{ m } ' must be 'voter' or 'promotable' to grow to target quorum cluster size '#{ n } '." }
5060 end
5161
52- def validate ( _ , % { membership: m } )
62+ def do_validate ( _ , % { membership: m } )
5363 when not ( m == "promotable" or
5464 m == "non_voter" or
5565 m == "voter" ) do
5666 { :validation_failure , "voter status '#{ m } ' is not recognised." }
5767 end
5868
59- def validate ( _ , _ ) do
69+ def do_validate ( _ , _ ) do
6070 :ok
6171 end
6272
@@ -65,10 +75,12 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
6575 [
6676 & Validators . rabbit_is_running / 2 ,
6777 fn args = [ n , _ ] , opts ->
68- if is_integer ( n ) do
69- :ok
70- else
71- Validators . existing_cluster_member ( args , opts )
78+ case Integer . parse ( n ) do
79+ { cluster_size , _ } when is_integer ( cluster_size ) ->
80+ :ok
81+
82+ :error ->
83+ Validators . existing_cluster_member ( args , opts )
7284 end
7385 end
7486 ] ,
@@ -85,10 +97,12 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
8597 } ) do
8698
8799 node_or_quorum_cluster_size =
88- if is_integer ( node_or_quorum_cluster_size ) do
89- node_or_quorum_cluster_size
90- else
91- to_atom ( node_or_quorum_cluster_size )
100+ case Integer . parse ( node_or_quorum_cluster_size ) do
101+ { cluster_size , _ } when is_integer ( cluster_size ) ->
102+ cluster_size
103+
104+ :error ->
105+ to_atom ( node_or_quorum_cluster_size )
92106 end
93107
94108 args = [ node_or_quorum_cluster_size , vhost_pat , queue_pat , to_atom ( strategy ) ]
@@ -160,8 +174,14 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
160174 do:
161175 "Grows quorum queue clusters by adding a member (replica) on the specified node for all matching queues"
162176
163- def banner ( [ node , strategy ] , _ ) do
164- "Growing #{ strategy } quorum queues on #{ node } ..."
177+ def banner ( [ node_or_quorum_cluster_size , strategy ] , % { queue_pattern: queue_pattern } ) do
178+ case Integer . parse ( node_or_quorum_cluster_size ) do
179+ { cluster_size , _ } when is_integer ( cluster_size ) ->
180+ "Growing #{ strategy } quorum queues matching '#{ queue_pattern } ' to a target cluster size of '#{ cluster_size } '..."
181+
182+ :error ->
183+ "Growing #{ strategy } quorum queues matching '#{ queue_pattern } ' to #{ node_or_quorum_cluster_size } ..."
184+ end
165185 end
166186
167187 #
0 commit comments