summaryrefslogtreecommitdiff
path: root/src/amqqueue.erl
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2019-06-13 11:56:14 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2019-06-13 11:57:39 +0200
commitb7f3fd9a8edfcb5a8c818493440363ce0cc7c790 (patch)
tree71f06767d7b15d7babacdffda3b401cedd6de04f /src/amqqueue.erl
parent1f5f8bb0863a3ddf14d2044bab5834ef8adba4b1 (diff)
downloadrabbitmq-server-git-b7f3fd9a8edfcb5a8c818493440363ce0cc7c790.tar.gz
amqqueue*: Uniformize API
Now, both modules export the same set of functions. This will help with the backport to `v3.7.x` and thus the life of plugin developers who will not have to have one copy of their plugin per RabbitMQ version.
Diffstat (limited to 'src/amqqueue.erl')
-rw-r--r--src/amqqueue.erl83
1 files changed, 80 insertions, 3 deletions
diff --git a/src/amqqueue.erl b/src/amqqueue.erl
index dda2642c34..35e7f0c4c4 100644
--- a/src/amqqueue.erl
+++ b/src/amqqueue.erl
@@ -19,7 +19,9 @@
-include_lib("rabbit_common/include/rabbit.hrl").
-include("amqqueue.hrl").
--export([new/9,
+-export([new/8,
+ new/9,
+ new_with_version/9,
new_with_version/10,
fields/0,
fields/1,
@@ -184,6 +186,40 @@
pid() | none,
rabbit_framing:amqp_table(),
rabbit_types:vhost() | undefined,
+ map()) -> amqqueue().
+
+new(#resource{kind = queue} = Name,
+ Pid,
+ Durable,
+ AutoDelete,
+ Owner,
+ Args,
+ VHost,
+ Options)
+ when (is_pid(Pid) orelse is_tuple(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) ->
+ new(Name,
+ Pid,
+ Durable,
+ AutoDelete,
+ Owner,
+ Args,
+ VHost,
+ Options,
+ ?amqqueue_v1_type).
+
+-spec new(rabbit_amqqueue:name(),
+ pid() | ra_server_id() | none,
+ boolean(),
+ boolean(),
+ pid() | none,
+ rabbit_framing:amqp_table(),
+ rabbit_types:vhost() | undefined,
map(),
atom()) -> amqqueue().
@@ -238,6 +274,44 @@ new(#resource{kind = queue} = Name,
pid() | none,
rabbit_framing:amqp_table(),
rabbit_types:vhost() | undefined,
+ map()) -> amqqueue().
+
+new_with_version(RecordVersion,
+ #resource{kind = queue} = Name,
+ Pid,
+ Durable,
+ AutoDelete,
+ Owner,
+ Args,
+ VHost,
+ Options)
+ when (is_pid(Pid) orelse is_tuple(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) ->
+ new_with_version(RecordVersion,
+ Name,
+ Pid,
+ Durable,
+ AutoDelete,
+ Owner,
+ Args,
+ VHost,
+ Options,
+ ?amqqueue_v1_type).
+
+-spec new_with_version
+(amqqueue_v1 | amqqueue_v2,
+ rabbit_amqqueue:name(),
+ pid() | ra_server_id() | none,
+ boolean(),
+ boolean(),
+ pid() | none,
+ rabbit_framing:amqp_table(),
+ rabbit_types:vhost() | undefined,
map(),
atom()) -> amqqueue().
@@ -359,6 +433,8 @@ get_exclusive_owner(#amqqueue{exclusive_owner = Owner}) ->
get_exclusive_owner(Queue) ->
amqqueue_v1:get_exclusive_owner(Queue).
+% gm_pids
+
-spec get_gm_pids(amqqueue()) -> [{pid(), pid()} | pid()] | none.
get_gm_pids(#amqqueue{gm_pids = GMPids}) ->
@@ -421,7 +497,7 @@ get_pid(#amqqueue{pid = Pid}) -> Pid;
get_pid(Queue) -> amqqueue_v1:get_pid(Queue).
-spec set_pid
-(amqqueue_v2(), pid() | ra_server_id() | none) -> amqqueue_v2();
+(amqqueue_v2(), pid() | ra_server_id() | none) -> amqqueue_v2();
(amqqueue_v1:amqqueue_v1(), pid() | none) -> amqqueue_v1:amqqueue_v1().
set_pid(#amqqueue{} = Queue, Pid) ->
@@ -509,7 +585,8 @@ set_slave_pids(Queue, SlavePids) ->
-spec get_slave_pids_pending_shutdown(amqqueue()) -> [pid()].
-get_slave_pids_pending_shutdown(#amqqueue{slave_pids_pending_shutdown = Slaves}) ->
+get_slave_pids_pending_shutdown(
+ #amqqueue{slave_pids_pending_shutdown = Slaves}) ->
Slaves;
get_slave_pids_pending_shutdown(Queue) ->
amqqueue_v1:get_slave_pids_pending_shutdown(Queue).