Merge pull request #13929 from rabbitmq/queue-checks
Trigger a 4.2.x alpha release build / trigger_alpha_build (push) Has been cancelled
Details
Test (make) / Build and Xref (1.17, 26) (push) Has been cancelled
Details
Test (make) / Build and Xref (1.17, 27) (push) Has been cancelled
Details
Test (make) / Test (1.17, 27, khepri) (push) Has been cancelled
Details
Test (make) / Test (1.17, 27, mnesia) (push) Has been cancelled
Details
Test (make) / Test mixed clusters (1.17, 27, khepri) (push) Has been cancelled
Details
Test (make) / Test mixed clusters (1.17, 27, mnesia) (push) Has been cancelled
Details
Test (make) / Type check (1.17, 27) (push) Has been cancelled
Details
Test Management UI with Selenium / selenium (chrome, 1.17.3, 27.3) (push) Has been cancelled
Details
Trigger a 4.2.x alpha release build / trigger_alpha_build (push) Has been cancelled
Details
Test (make) / Build and Xref (1.17, 26) (push) Has been cancelled
Details
Test (make) / Build and Xref (1.17, 27) (push) Has been cancelled
Details
Test (make) / Test (1.17, 27, khepri) (push) Has been cancelled
Details
Test (make) / Test (1.17, 27, mnesia) (push) Has been cancelled
Details
Test (make) / Test mixed clusters (1.17, 27, khepri) (push) Has been cancelled
Details
Test (make) / Test mixed clusters (1.17, 27, mnesia) (push) Has been cancelled
Details
Test (make) / Type check (1.17, 27) (push) Has been cancelled
Details
Test Management UI with Selenium / selenium (chrome, 1.17.3, 27.3) (push) Has been cancelled
Details
Use more idiomatic `maybe` feature
This commit is contained in:
commit
6dd7447b92
|
@ -12,7 +12,6 @@
|
|||
check_auto_delete/1,
|
||||
check_exclusive/1,
|
||||
check_non_durable/1,
|
||||
run_checks/2,
|
||||
erpc_call/5]).
|
||||
|
||||
-include_lib("rabbit_common/include/rabbit.hrl").
|
||||
|
@ -62,16 +61,6 @@ check_non_durable(Q) when not ?amqqueue_is_durable(Q) ->
|
|||
{protocol_error, precondition_failed, "invalid property 'non-durable' for ~ts",
|
||||
[rabbit_misc:rs(Name)]}.
|
||||
|
||||
run_checks([], _) ->
|
||||
ok;
|
||||
run_checks([C | Checks], Q) ->
|
||||
case C(Q) of
|
||||
ok ->
|
||||
run_checks(Checks, Q);
|
||||
Err ->
|
||||
Err
|
||||
end.
|
||||
|
||||
-spec erpc_call(node(), module(), atom(), list(), non_neg_integer() | infinity) ->
|
||||
term() | {error, term()}.
|
||||
erpc_call(Node, M, F, A, _Timeout)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
%%
|
||||
|
||||
-module(rabbit_quorum_queue).
|
||||
-feature(maybe_expr, enable).
|
||||
|
||||
-behaviour(rabbit_queue_type).
|
||||
-behaviour(rabbit_policy_validator).
|
||||
|
@ -248,15 +249,11 @@ handle_event(QName, {From, Evt}, QState) ->
|
|||
{new | existing, amqqueue:amqqueue()} |
|
||||
{protocol_error, Type :: atom(), Reason :: string(), Args :: term()}.
|
||||
declare(Q, _Node) when ?amqqueue_is_quorum(Q) ->
|
||||
case rabbit_queue_type_util:run_checks(
|
||||
[fun rabbit_queue_type_util:check_auto_delete/1,
|
||||
fun rabbit_queue_type_util:check_exclusive/1,
|
||||
fun rabbit_queue_type_util:check_non_durable/1],
|
||||
Q) of
|
||||
ok ->
|
||||
start_cluster(Q);
|
||||
Err ->
|
||||
Err
|
||||
maybe
|
||||
ok ?= rabbit_queue_type_util:check_auto_delete(Q),
|
||||
ok ?= rabbit_queue_type_util:check_exclusive(Q),
|
||||
ok ?= rabbit_queue_type_util:check_non_durable(Q),
|
||||
start_cluster(Q)
|
||||
end.
|
||||
|
||||
start_cluster(Q) ->
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
%%
|
||||
|
||||
-module(rabbit_stream_queue).
|
||||
-feature(maybe_expr, enable).
|
||||
|
||||
-include("mc.hrl").
|
||||
|
||||
-behaviour(rabbit_queue_type).
|
||||
|
@ -137,19 +139,14 @@ is_compatible(_, _, _) ->
|
|||
-spec declare(amqqueue:amqqueue(), node()) ->
|
||||
{'new' | 'existing', amqqueue:amqqueue()} |
|
||||
{protocol_error, Type :: atom(), Reason :: string(), Args :: term()}.
|
||||
declare(Q0, _Node) when ?amqqueue_is_stream(Q0) ->
|
||||
case rabbit_queue_type_util:run_checks(
|
||||
[fun rabbit_queue_type_util:check_auto_delete/1,
|
||||
fun rabbit_queue_type_util:check_exclusive/1,
|
||||
fun rabbit_queue_type_util:check_non_durable/1,
|
||||
fun check_max_segment_size_bytes/1,
|
||||
fun check_filter_size/1
|
||||
],
|
||||
Q0) of
|
||||
ok ->
|
||||
create_stream(Q0);
|
||||
Err ->
|
||||
Err
|
||||
declare(Q, _Node) when ?amqqueue_is_stream(Q) ->
|
||||
maybe
|
||||
ok ?= rabbit_queue_type_util:check_auto_delete(Q),
|
||||
ok ?= rabbit_queue_type_util:check_exclusive(Q),
|
||||
ok ?= rabbit_queue_type_util:check_non_durable(Q),
|
||||
ok ?= check_max_segment_size_bytes(Q),
|
||||
ok ?= check_filter_size(Q),
|
||||
create_stream(Q)
|
||||
end.
|
||||
|
||||
check_max_segment_size_bytes(Q) ->
|
||||
|
|
Loading…
Reference in New Issue