Skip to content

Fix type spec for AMQP 1.0 address #13696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions deps/amqp10_client/src/amqp10_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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().

Expand All @@ -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,
Expand Down Expand Up @@ -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) ->
Expand All @@ -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) ->
Expand All @@ -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).
Expand All @@ -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) ->
Expand All @@ -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) ->
Expand Down
12 changes: 8 additions & 4 deletions deps/amqp10_client/src/amqp10_client_session.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,22 @@
-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]
-type input_handle() :: link_handle().

-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()}.
Expand Down Expand Up @@ -112,6 +115,7 @@
terminus_durability/0,
attach_args/0,
attach_role/0,
terminus_address/0,
target_def/0,
source_def/0,
filter/0,
Expand Down