|
73 | 73 | -type rcv_settle_mode() :: first | second. |
74 | 74 |
|
75 | 75 | -type terminus_durability() :: none | configuration | unsettled_state. |
| 76 | +-type terminus_capabilities() :: none | binary() | list(). |
76 | 77 |
|
77 | 78 | -type target_def() :: #{address => link_address(), |
78 | | - durable => terminus_durability()}. |
| 79 | + durable => terminus_durability(), |
| 80 | + capabilities => terminus_capabilities()}. |
79 | 81 | -type source_def() :: #{address => link_address(), |
80 | | - durable => terminus_durability()}. |
| 82 | + durable => terminus_durability(), |
| 83 | + capabilities => terminus_capabilities()}. |
81 | 84 |
|
82 | 85 | -type attach_role() :: {sender, target_def()} | {receiver, source_def(), pid()}. |
83 | 86 |
|
|
109 | 112 | -export_type([snd_settle_mode/0, |
110 | 113 | rcv_settle_mode/0, |
111 | 114 | terminus_durability/0, |
| 115 | + terminus_capabilities/0, |
112 | 116 | attach_args/0, |
113 | 117 | attach_role/0, |
114 | 118 | target_def/0, |
@@ -713,20 +717,24 @@ make_source(#{role := {sender, _}}) -> |
713 | 717 | make_source(#{role := {receiver, #{address := Address} = Source, _Pid}, filter := Filter}) -> |
714 | 718 | Durable = translate_terminus_durability(maps:get(durable, Source, none)), |
715 | 719 | TranslatedFilter = translate_filters(Filter), |
| 720 | + Capabilities = translate_terminus_capabilities(maps:get(capabilities, Source, none)), |
716 | 721 | #'v1_0.source'{address = {utf8, Address}, |
717 | 722 | durable = {uint, Durable}, |
718 | | - filter = TranslatedFilter}. |
| 723 | + filter = TranslatedFilter, |
| 724 | + capabilities = Capabilities}. |
719 | 725 |
|
720 | 726 | make_target(#{role := {receiver, _Source, _Pid}}) -> |
721 | 727 | #'v1_0.target'{}; |
722 | 728 | make_target(#{role := {sender, #{address := Address} = Target}}) -> |
723 | 729 | Durable = translate_terminus_durability(maps:get(durable, Target, none)), |
| 730 | + Capabilities = translate_terminus_capabilities(maps:get(capabilities, Target, none)), |
724 | 731 | TargetAddr = case is_binary(Address) of |
725 | 732 | true -> {utf8, Address}; |
726 | 733 | false -> Address |
727 | 734 | end, |
728 | 735 | #'v1_0.target'{address = TargetAddr, |
729 | | - durable = {uint, Durable}}. |
| 736 | + durable = {uint, Durable}, |
| 737 | + capabilities = Capabilities}. |
730 | 738 |
|
731 | 739 | max_message_size(#{max_message_size := Size}) |
732 | 740 | when is_integer(Size) andalso |
@@ -771,6 +779,19 @@ filter_value_type({T, _} = V) when is_atom(T) -> |
771 | 779 | %% looks like an already tagged type, just pass it through |
772 | 780 | V. |
773 | 781 |
|
| 782 | +translate_terminus_capabilities(none) -> |
| 783 | + undefined; |
| 784 | +translate_terminus_capabilities(Capabilities) when is_binary(Capabilities) -> |
| 785 | + {symbol, Capabilities}; |
| 786 | +translate_terminus_capabilities(CapabilitiesList) when is_list(CapabilitiesList) -> |
| 787 | + {array, symbol, [filter_capability(V) || V <- CapabilitiesList]}. |
| 788 | + |
| 789 | +filter_capability(V) when is_binary(V) -> |
| 790 | + {symbol, V}; |
| 791 | +filter_capability({T, _} = V) when is_atom(T) -> |
| 792 | + %% looks like an already tagged type, just pass it through |
| 793 | + V. |
| 794 | + |
774 | 795 | % https://people.apache.org/~rgodfrey/amqp-1.0/apache-filters.html |
775 | 796 | translate_legacy_amqp_headers_binding(LegacyHeaders) -> |
776 | 797 | {map, |
@@ -847,7 +868,7 @@ send_attach(Send, #{name := Name, role := RoleTuple} = Args, {FromPid, _}, |
847 | 868 | target = Target, |
848 | 869 | max_message_size = MaxMessageSize}, |
849 | 870 | ok = Send(Attach, State), |
850 | | - |
| 871 | + |
851 | 872 | Ref = make_link_ref(Role, self(), OutHandle), |
852 | 873 | Link = #link{name = Name, |
853 | 874 | ref = Ref, |
|
0 commit comments