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
This commit is contained in:
David Ansari 2025-04-07 10:57:42 +02:00 committed by David Ansari
parent 35b5ab3cdc
commit 561376052e
2 changed files with 15 additions and 9 deletions

View File

@ -47,6 +47,7 @@
-type terminus_durability() :: amqp10_client_session:terminus_durability().
-type terminus_address() :: amqp10_client_session:terminus_address().
-type target_def() :: amqp10_client_session:target_def().
-type source_def() :: amqp10_client_session:source_def().
@ -64,6 +65,7 @@
snd_settle_mode/0,
rcv_settle_mode/0,
terminus_durability/0,
terminus_address/0,
target_def/0,
source_def/0,
attach_role/0,
@ -170,7 +172,7 @@ attach_sender_link_sync(Session, Name, Target) ->
%% @doc Synchronously attach a link on 'Session'.
%% This is a convenience function that awaits attached event
%% for the link before returning.
-spec attach_sender_link_sync(pid(), binary(), binary(),
-spec attach_sender_link_sync(pid(), binary(), terminus_address(),
snd_settle_mode()) ->
{ok, link_ref()} | link_timeout.
attach_sender_link_sync(Session, Name, Target, SettleMode) ->
@ -179,7 +181,7 @@ attach_sender_link_sync(Session, Name, Target, SettleMode) ->
%% @doc Synchronously attach a link on 'Session'.
%% This is a convenience function that awaits attached event
%% for the link before returning.
-spec attach_sender_link_sync(pid(), binary(), binary(),
-spec attach_sender_link_sync(pid(), binary(), terminus_address(),
snd_settle_mode(), terminus_durability()) ->
{ok, link_ref()} | link_timeout.
attach_sender_link_sync(Session, Name, Target, SettleMode, Durability) ->
@ -199,7 +201,7 @@ attach_sender_link_sync(Session, Name, Target, SettleMode, Durability) ->
%% This is asynchronous and will notify completion of the attach request to the
%% caller using an amqp10_event of the following format:
%% {amqp10_event, {link, LinkRef, attached | {detached, Why}}}
-spec attach_sender_link(pid(), binary(), binary()) -> {ok, link_ref()}.
-spec attach_sender_link(pid(), binary(), terminus_address()) -> {ok, link_ref()}.
attach_sender_link(Session, Name, Target) ->
% mixed should work with any type of msg
attach_sender_link(Session, Name, Target, mixed).
@ -208,7 +210,7 @@ attach_sender_link(Session, Name, Target) ->
%% This is asynchronous and will notify completion of the attach request to the
%% caller using an amqp10_event of the following format:
%% {amqp10_event, {link, LinkRef, attached | {detached, Why}}}
-spec attach_sender_link(pid(), binary(), binary(),
-spec attach_sender_link(pid(), binary(), terminus_address(),
snd_settle_mode()) ->
{ok, link_ref()}.
attach_sender_link(Session, Name, Target, SettleMode) ->
@ -218,7 +220,7 @@ attach_sender_link(Session, Name, Target, SettleMode) ->
%% This is asynchronous and will notify completion of the attach request to the
%% caller using an amqp10_event of the following format:
%% {amqp10_event, {link, LinkRef, attached | {detached, Why}}}
-spec attach_sender_link(pid(), binary(), binary(),
-spec attach_sender_link(pid(), binary(), terminus_address(),
snd_settle_mode(), terminus_durability()) ->
{ok, link_ref()}.
attach_sender_link(Session, Name, Target, SettleMode, Durability) ->

View File

@ -65,9 +65,12 @@
-define(INITIAL_DELIVERY_COUNT, ?UINT_MAX - 2).
-type link_name() :: binary().
-type link_address() :: binary().
%% https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-address-string
%% or
%% https://docs.oasis-open.org/amqp/anonterm/v1.0/anonterm-v1.0.html
-type terminus_address() :: binary() | null.
-type link_role() :: sender | receiver.
-type link_target() :: {pid, pid()} | binary() | undefined.
-type link_target() :: {pid, pid()} | terminus_address() | undefined.
%% "The locally chosen handle is referred to as the output handle." [2.6.2]
-type output_handle() :: link_handle().
%% "The remotely chosen handle is referred to as the input handle." [2.6.2]
@ -75,9 +78,9 @@
-type terminus_durability() :: none | configuration | unsettled_state.
-type target_def() :: #{address => link_address(),
-type target_def() :: #{address => terminus_address(),
durable => terminus_durability()}.
-type source_def() :: #{address => link_address(),
-type source_def() :: #{address => terminus_address(),
durable => terminus_durability()}.
-type attach_role() :: {sender, target_def()} | {receiver, source_def(), pid()}.
@ -112,6 +115,7 @@
terminus_durability/0,
attach_args/0,
attach_role/0,
terminus_address/0,
target_def/0,
source_def/0,
filter/0,