Skip to content

Commit c328968

Browse files
committed
Remove unused code
1 parent 4209f3f commit c328968

File tree

4 files changed

+22
-46
lines changed

4 files changed

+22
-46
lines changed

deps/amqp10_common/src/amqp10_binary_parser.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
%% server_mode is a special parsing mode used by RabbitMQ when parsing
3535
%% AMQP message sections from an AMQP client. This mode:
36-
%% 1. stops parsing when the body is reached, and
36+
%% 1. stops parsing when the body starts, and
3737
%% 2. returns the start byte position of each parsed bare message section.
3838
-type opts() :: [server_mode].
3939

deps/rabbit/src/mc_amqp.erl

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@
1919
-import(rabbit_misc,
2020
[maps_put_truthy/3]).
2121

22-
-type message_section() ::
23-
#'v1_0.header'{} |
24-
#'v1_0.delivery_annotations'{} |
25-
#'v1_0.message_annotations'{} |
26-
#'v1_0.properties'{} |
27-
#'v1_0.application_properties'{} |
28-
#'v1_0.data'{} |
29-
#'v1_0.amqp_sequence'{} |
30-
#'v1_0.amqp_value'{} |
31-
#'v1_0.footer'{}.
32-
3322
-define(MESSAGE_ANNOTATIONS_GUESS_SIZE, 100).
3423

3524
-define(SIMPLE_VALUE(V),
@@ -50,7 +39,12 @@
5039
-type body_descriptor_code() :: ?DESCRIPTOR_CODE_DATA |
5140
?DESCRIPTOR_CODE_AMQP_SEQUENCE |
5241
?DESCRIPTOR_CODE_AMQP_VALUE.
53-
-type amqp_map() :: [{term(), term()}].
42+
%% §3.2.5
43+
-type application_properties() :: [{Key :: {utf8, binary()},
44+
Val :: term()}].
45+
%% §3.2.10
46+
-type amqp_annotations() :: [{Key :: {symbol, binary()} | {ulong, non_neg_integer()},
47+
Val :: term()}].
5448
-type opt(T) :: T | undefined.
5549

5650
%% This representation is used when the message was originally sent with
@@ -67,13 +61,13 @@
6761

6862
%% This representation is used when we received the message from
6963
%% an AMQP client or when we read the message from a stream.
70-
%% This message was parsed up to the section preceding the body.
64+
%% This message was parsed only until the start of the body.
7165
-record(msg_body_encoded,
7266
{
7367
header :: opt(#'v1_0.header'{}),
74-
message_annotations = [] :: amqp_map(),
68+
message_annotations = [] :: amqp_annotations(),
7569
properties :: opt(#'v1_0.properties'{}),
76-
application_properties = [] :: amqp_map(),
70+
application_properties = [] :: application_properties(),
7771
bare_and_footer = uninit :: uninit | binary(),
7872
bare_and_footer_application_properties_pos = ?OMITTED_SECTION :: non_neg_integer() | ?OMITTED_SECTION,
7973
bare_and_footer_body_pos = uninit :: uninit | non_neg_integer(),
@@ -92,7 +86,7 @@
9286
%% the future.
9387
-record(v1,
9488
{
95-
message_annotations = [] :: amqp_map(),
89+
message_annotations = [] :: amqp_annotations(),
9690
bare_and_footer :: binary(),
9791
bare_and_footer_properties_pos :: 0 | ?OMITTED_SECTION,
9892
bare_and_footer_application_properties_pos :: non_neg_integer() | ?OMITTED_SECTION,
@@ -102,19 +96,16 @@
10296

10397
-opaque state() :: #msg_body_decoded{} | #msg_body_encoded{} | #v1{}.
10498

105-
-export_type([
106-
state/0,
107-
message_section/0
108-
]).
99+
-export_type([state/0]).
109100

110-
init(Payload) when is_binary(Payload) ->
101+
init(Payload) ->
111102
Sections = amqp10_framing:decode_bin(Payload, [server_mode]),
112-
Msg = msg_body_encoded(Sections, Payload),
103+
Msg = msg_body_encoded(Sections, Payload, #msg_body_encoded{}),
113104
Anns = essential_properties(Msg),
114105
{Msg, Anns}.
115106

116107
convert_from(?MODULE, Sections, _Env) when is_list(Sections) ->
117-
msg_body_decoded(Sections);
108+
msg_body_decoded(Sections, #msg_body_decoded{});
118109
convert_from(_SourceProto, _, _Env) ->
119110
not_implemented.
120111

@@ -396,7 +387,8 @@ to_sections(H, MAC, Tail) ->
396387
[H | S]
397388
end.
398389

399-
-spec protocol_state_message_annotations(amqp_map(), mc:annotations()) -> amqp_map().
390+
-spec protocol_state_message_annotations(amqp_annotations(), mc:annotations()) ->
391+
amqp_annotations().
400392
protocol_state_message_annotations(MA, Anns) ->
401393
maps:fold(
402394
fun(?ANN_EXCHANGE, Exchange, L) ->
@@ -508,35 +500,29 @@ application_properties_as_simple_map0(Content, L) ->
508500
Acc
509501
end, L, Content).
510502

511-
msg_body_decoded(Sections) ->
512-
msg_body_decoded(Sections, #msg_body_decoded{}).
513-
514503
msg_body_decoded([], Acc) ->
515504
Acc;
516505
msg_body_decoded([#'v1_0.header'{} = H | Rem], Msg) ->
517506
msg_body_decoded(Rem, Msg#msg_body_decoded{header = H});
507+
msg_body_decoded([_Ignore = #'v1_0.delivery_annotations'{} | Rem], Msg) ->
508+
msg_body_decoded(Rem, Msg);
518509
msg_body_decoded([#'v1_0.message_annotations'{content = MAC} | Rem], Msg) ->
519510
msg_body_decoded(Rem, Msg#msg_body_decoded{message_annotations = MAC});
520511
msg_body_decoded([#'v1_0.properties'{} = P | Rem], Msg) ->
521512
msg_body_decoded(Rem, Msg#msg_body_decoded{properties = P});
522513
msg_body_decoded([#'v1_0.application_properties'{content = APC} | Rem], Msg) ->
523514
msg_body_decoded(Rem, Msg#msg_body_decoded{application_properties = APC});
524-
msg_body_decoded([_Ignore = #'v1_0.delivery_annotations'{} | Rem], Msg) ->
525-
msg_body_decoded(Rem, Msg);
526515
msg_body_decoded([#'v1_0.data'{} = D | Rem], #msg_body_decoded{data = Body} = Msg)
527516
when is_list(Body) ->
528517
msg_body_decoded(Rem, Msg#msg_body_decoded{data = Body ++ [D]});
529518
msg_body_decoded([#'v1_0.amqp_sequence'{} = D | Rem], #msg_body_decoded{data = Body} = Msg)
530519
when is_list(Body) ->
531520
msg_body_decoded(Rem, Msg#msg_body_decoded{data = Body ++ [D]});
532-
msg_body_decoded([#'v1_0.footer'{content = FC} | Rem], Msg) ->
533-
msg_body_decoded(Rem, Msg#msg_body_decoded{footer = FC});
534521
msg_body_decoded([#'v1_0.amqp_value'{} = B | Rem], #msg_body_decoded{} = Msg) ->
535522
%% an amqp value can only be a singleton
536-
msg_body_decoded(Rem, Msg#msg_body_decoded{data = B}).
537-
538-
msg_body_encoded(Sections, Payload) ->
539-
msg_body_encoded(Sections, Payload, #msg_body_encoded{}).
523+
msg_body_decoded(Rem, Msg#msg_body_decoded{data = B});
524+
msg_body_decoded([#'v1_0.footer'{content = FC} | Rem], Msg) ->
525+
msg_body_decoded(Rem, Msg#msg_body_decoded{footer = FC}).
540526

541527
msg_body_encoded([#'v1_0.header'{} = H | Rem], Payload, Msg) ->
542528
msg_body_encoded(Rem, Payload, Msg#msg_body_encoded{header = H});

deps/rabbit/src/rabbit_amqp_reader.erl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,6 @@ parse_frame_body(Body, _Channel) ->
367367
BytesBody = size(Body),
368368
{DescribedPerformative, BytesParsed} = amqp10_binary_parser:parse(Body),
369369
Performative = amqp10_framing:decode(DescribedPerformative),
370-
% ?DEBUG("~s Channel ~tp ->~n~tp~n~ts~n",
371-
% [?MODULE, _Channel, amqp10_framing:pprint(Performative),
372-
% case Payload of
373-
% <<>> -> <<>>;
374-
% _ -> rabbit_misc:format(
375-
% " followed by ~tb bytes of payload", [size(Payload)])
376-
% end]),
377370
if BytesParsed < BytesBody ->
378371
Payload = binary_part(Body, BytesParsed, BytesBody - BytesParsed),
379372
{Performative, Payload};

deps/rabbit/src/rabbit_amqp_session.erl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,6 @@ handle_deliver(ConsumerTag, AckRequired,
16231623
Mc1 = mc:convert(mc_amqp, Mc0),
16241624
Mc = mc:set_annotation(redelivered, Redelivered, Mc1),
16251625
Sections = mc:protocol_state(Mc),
1626-
% ?DEBUG("~s Outbound payload:~n ~tp~n",
1627-
% [?MODULE, [amqp10_framing:pprint(Section) ||
1628-
% Section <- amqp10_framing:decode_bin(iolist_to_binary(Sections))]]),
16291626
validate_message_size(Sections, MaxMessageSize),
16301627
Frames = transfer_frames(Transfer, Sections, MaxFrameSize),
16311628
messages_delivered(Redelivered, QType),

0 commit comments

Comments
 (0)