summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-05-19 15:26:15 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-05-19 15:26:15 +0200
commitd6653888550e5fae9f19bd204b0d4f40dc086f4c (patch)
tree2d2a4513c14b293094b23fa9e1b04c429a3b55a1
parent18e02f2889c5af640744cb122a349c588c973eee (diff)
downloadrabbitmq-server-git-d6653888550e5fae9f19bd204b0d4f40dc086f4c.tar.gz
Fix several type specs
Most of them are imported from `master`.
-rw-r--r--src/amqqueue.erl26
-rw-r--r--src/rabbit_amqqueue.erl4
-rw-r--r--src/rabbit_channel.erl11
3 files changed, 20 insertions, 21 deletions
diff --git a/src/amqqueue.erl b/src/amqqueue.erl
index 46e7f488ac..7458756805 100644
--- a/src/amqqueue.erl
+++ b/src/amqqueue.erl
@@ -91,6 +91,8 @@
macros/0]).
-define(record_version, amqqueue_v1).
+-define(is_backwards_compat_classic(T),
+ (T =:= classic orelse T =:= ?amqqueue_v1_type)).
-type amqqueue() :: amqqueue_v1().
-type amqqueue_v1() :: #amqqueue{
@@ -105,7 +107,7 @@
recoverable_slaves :: [atom()] | none,
policy :: binary() | none | undefined,
operator_policy :: binary() | none | undefined,
- gm_pids :: [pid()] | none,
+ gm_pids :: [{pid(), pid()}] | none,
decorators :: [atom()] | none | undefined,
state :: atom() | none,
policy_version :: non_neg_integer(),
@@ -184,7 +186,7 @@ new(#resource{kind = queue} = Name,
rabbit_framing:amqp_table(),
rabbit_types:vhost() | undefined,
map(),
- ?amqqueue_v1_type) -> amqqueue().
+ ?amqqueue_v1_type | classic) -> amqqueue().
new(#resource{kind = queue} = Name,
Pid,
@@ -194,14 +196,15 @@ new(#resource{kind = queue} = Name,
Args,
VHost,
Options,
- ?amqqueue_v1_type)
+ Type)
when (is_pid(Pid) orelse Pid =:= none) andalso
is_boolean(Durable) andalso
is_boolean(AutoDelete) andalso
(is_pid(Owner) orelse Owner =:= none) andalso
is_list(Args) andalso
(is_binary(VHost) orelse VHost =:= undefined) andalso
- is_map(Options) ->
+ is_map(Options) andalso
+ ?is_backwards_compat_classic(Type) ->
new(
Name,
Pid,
@@ -256,7 +259,7 @@ new_with_version(?record_version,
rabbit_framing:amqp_table(),
rabbit_types:vhost() | undefined,
map(),
- ?amqqueue_v1_type) -> amqqueue().
+ ?amqqueue_v1_type | classic) -> amqqueue().
new_with_version(?record_version,
#resource{kind = queue} = Name,
@@ -267,14 +270,15 @@ new_with_version(?record_version,
Args,
VHost,
Options,
- ?amqqueue_v1_type)
+ Type)
when (is_pid(Pid) orelse Pid =:= none) andalso
is_boolean(Durable) andalso
is_boolean(AutoDelete) andalso
(is_pid(Owner) orelse Owner =:= none) andalso
is_list(Args) andalso
(is_binary(VHost) orelse VHost =:= undefined) andalso
- is_map(Options) ->
+ is_map(Options) andalso
+ ?is_backwards_compat_classic(Type) ->
new_with_version(
?record_version,
Name,
@@ -333,11 +337,11 @@ get_exclusive_owner(#amqqueue{exclusive_owner = Owner}) -> Owner.
% gm_pids
--spec get_gm_pids(amqqueue()) -> [{pid(), pid()} | pid()] | none.
+-spec get_gm_pids(amqqueue()) -> [{pid(), pid()}] | none.
get_gm_pids(#amqqueue{gm_pids = GMPids}) -> GMPids.
--spec set_gm_pids(amqqueue(), [{pid(), pid()} | pid()] | none) -> amqqueue().
+-spec set_gm_pids(amqqueue(), [{pid(), pid()}] | none) -> amqqueue().
set_gm_pids(#amqqueue{} = Queue, GMPids) ->
Queue#amqqueue{gm_pids = GMPids}.
@@ -497,8 +501,8 @@ is_classic(Queue) ->
-spec is_quorum(amqqueue()) -> boolean().
-is_quorum(Queue) ->
- get_type(Queue) =:= quorum.
+is_quorum(Queue) when ?is_amqqueue(Queue) ->
+ false.
fields() -> fields(?record_version).
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index a3a72e7146..77b91f836b 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -196,9 +196,9 @@
-spec is_mirrored(rabbit_types:amqqueue()) -> boolean().
-spec pid_of(rabbit_types:amqqueue()) ->
- {'ok', pid()} | rabbit_types:error('not_found').
+ pid().
-spec pid_of(rabbit_types:vhost(), rabbit_misc:resource_name()) ->
- {'ok', pid()} | rabbit_types:error('not_found').
+ pid() | rabbit_types:error('not_found').
%%----------------------------------------------------------------------------
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 43b313e2df..8262a89fdc 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -1991,19 +1991,14 @@ send_confirms_and_nacks(State) ->
send_nacks([], _, State) ->
State;
-send_nacks(_Rs, _, State = #ch{state = closing,
- tx = none}) -> %% optimisation
+send_nacks(_Rs, _, State = #ch{state = closing}) -> %% optimisation
State;
-send_nacks(Rs, Cs, State = #ch{tx = none}) ->
+send_nacks(Rs, Cs, State) ->
coalesce_and_send(Rs, Cs,
fun(MsgSeqNo, Multiple) ->
#'basic.nack'{delivery_tag = MsgSeqNo,
multiple = Multiple}
- end, State);
-send_nacks(_MXs, _, State = #ch{state = closing}) -> %% optimisation
- State#ch{tx = failed};
-send_nacks(_, _, State) ->
- maybe_complete_tx(State#ch{tx = failed}).
+ end, State).
send_confirms([], _, State) ->
State;