Skip to content

Commit a1a22b0

Browse files
committed
Fix type spec for AMQP 1.0 address
The target address can be null which denotes the anonymous terminus. https://docs.oasis-open.org/amqp/anonterm/v1.0/anonterm-v1.0.html
1 parent 6f5c8e0 commit a1a22b0

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

deps/amqp10_client/src/amqp10_client.erl

+7-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
-type terminus_durability() :: amqp10_client_session:terminus_durability().
4949

50+
-type terminus_address() :: amqp10_client_session:terminus_address().
5051
-type target_def() :: amqp10_client_session:target_def().
5152
-type source_def() :: amqp10_client_session:source_def().
5253

@@ -64,6 +65,7 @@
6465
snd_settle_mode/0,
6566
rcv_settle_mode/0,
6667
terminus_durability/0,
68+
terminus_address/0,
6769
target_def/0,
6870
source_def/0,
6971
attach_role/0,
@@ -170,7 +172,7 @@ attach_sender_link_sync(Session, Name, Target) ->
170172
%% @doc Synchronously attach a link on 'Session'.
171173
%% This is a convenience function that awaits attached event
172174
%% for the link before returning.
173-
-spec attach_sender_link_sync(pid(), binary(), binary(),
175+
-spec attach_sender_link_sync(pid(), binary(), terminus_address(),
174176
snd_settle_mode()) ->
175177
{ok, link_ref()} | link_timeout.
176178
attach_sender_link_sync(Session, Name, Target, SettleMode) ->
@@ -179,7 +181,7 @@ attach_sender_link_sync(Session, Name, Target, SettleMode) ->
179181
%% @doc Synchronously attach a link on 'Session'.
180182
%% This is a convenience function that awaits attached event
181183
%% for the link before returning.
182-
-spec attach_sender_link_sync(pid(), binary(), binary(),
184+
-spec attach_sender_link_sync(pid(), binary(), terminus_address(),
183185
snd_settle_mode(), terminus_durability()) ->
184186
{ok, link_ref()} | link_timeout.
185187
attach_sender_link_sync(Session, Name, Target, SettleMode, Durability) ->
@@ -199,7 +201,7 @@ attach_sender_link_sync(Session, Name, Target, SettleMode, Durability) ->
199201
%% This is asynchronous and will notify completion of the attach request to the
200202
%% caller using an amqp10_event of the following format:
201203
%% {amqp10_event, {link, LinkRef, attached | {detached, Why}}}
202-
-spec attach_sender_link(pid(), binary(), binary()) -> {ok, link_ref()}.
204+
-spec attach_sender_link(pid(), binary(), terminus_address()) -> {ok, link_ref()}.
203205
attach_sender_link(Session, Name, Target) ->
204206
% mixed should work with any type of msg
205207
attach_sender_link(Session, Name, Target, mixed).
@@ -208,7 +210,7 @@ attach_sender_link(Session, Name, Target) ->
208210
%% This is asynchronous and will notify completion of the attach request to the
209211
%% caller using an amqp10_event of the following format:
210212
%% {amqp10_event, {link, LinkRef, attached | {detached, Why}}}
211-
-spec attach_sender_link(pid(), binary(), binary(),
213+
-spec attach_sender_link(pid(), binary(), terminus_address(),
212214
snd_settle_mode()) ->
213215
{ok, link_ref()}.
214216
attach_sender_link(Session, Name, Target, SettleMode) ->
@@ -218,7 +220,7 @@ attach_sender_link(Session, Name, Target, SettleMode) ->
218220
%% This is asynchronous and will notify completion of the attach request to the
219221
%% caller using an amqp10_event of the following format:
220222
%% {amqp10_event, {link, LinkRef, attached | {detached, Why}}}
221-
-spec attach_sender_link(pid(), binary(), binary(),
223+
-spec attach_sender_link(pid(), binary(), terminus_address(),
222224
snd_settle_mode(), terminus_durability()) ->
223225
{ok, link_ref()}.
224226
attach_sender_link(Session, Name, Target, SettleMode, Durability) ->

deps/amqp10_client/src/amqp10_client_session.erl

+8-4
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,22 @@
6565
-define(INITIAL_DELIVERY_COUNT, ?UINT_MAX - 2).
6666

6767
-type link_name() :: binary().
68-
-type link_address() :: binary().
68+
%% https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-address-string
69+
%% or
70+
%% https://docs.oasis-open.org/amqp/anonterm/v1.0/anonterm-v1.0.html
71+
-type terminus_address() :: binary() | null.
6972
-type link_role() :: sender | receiver.
70-
-type link_target() :: {pid, pid()} | binary() | undefined.
73+
-type link_target() :: {pid, pid()} | terminus_address() | undefined.
7174
%% "The locally chosen handle is referred to as the output handle." [2.6.2]
7275
-type output_handle() :: link_handle().
7376
%% "The remotely chosen handle is referred to as the input handle." [2.6.2]
7477
-type input_handle() :: link_handle().
7578

7679
-type terminus_durability() :: none | configuration | unsettled_state.
7780

78-
-type target_def() :: #{address => link_address(),
81+
-type target_def() :: #{address => terminus_address(),
7982
durable => terminus_durability()}.
80-
-type source_def() :: #{address => link_address(),
83+
-type source_def() :: #{address => terminus_address(),
8184
durable => terminus_durability()}.
8285

8386
-type attach_role() :: {sender, target_def()} | {receiver, source_def(), pid()}.
@@ -112,6 +115,7 @@
112115
terminus_durability/0,
113116
attach_args/0,
114117
attach_role/0,
118+
terminus_address/0,
115119
target_def/0,
116120
source_def/0,
117121
filter/0,

0 commit comments

Comments
 (0)