1111-include (" rabbit_amqp.hrl" ).
1212
1313% % client API
14- -export ([start_link /3 ,
14+ -export ([start_link /2 ,
1515 send_command /3 ,
1616 send_command /4 ,
1717 send_command_sync /3 ,
2727
2828-record (state , {
2929 sock :: rabbit_net :socket (),
30- max_frame_size :: unlimited | pos_integer (),
3130 reader :: rabbit_types :connection (),
3231 pending :: iolist (),
3332 % % This field is just an optimisation to minimize the cost of erlang:iolist_size/1
4645% %% client API %%%
4746% %%%%%%%%%%%%%%%%%
4847
49- -spec start_link (rabbit_net :socket (), non_neg_integer (), pid ()) ->
48+ -spec start_link (rabbit_net :socket (), pid ()) ->
5049 rabbit_types :ok (pid ()).
51- start_link (Sock , MaxFrame , ReaderPid ) ->
52- Args = {Sock , MaxFrame , ReaderPid },
50+ start_link (Sock , ReaderPid ) ->
51+ Args = {Sock , ReaderPid },
5352 Opts = [{hibernate_after , ? HIBERNATE_AFTER }],
5453 gen_server :start_link (? MODULE , Args , Opts ).
5554
@@ -96,9 +95,8 @@ internal_send_command(Sock, Performative, Protocol) ->
9695% %% gen_server callbacks %%%
9796% %%%%%%%%%%%%%%%%%%%%%%%%%%%
9897
99- init ({Sock , MaxFrame , ReaderPid }) ->
98+ init ({Sock , ReaderPid }) ->
10099 State = # state {sock = Sock ,
101- max_frame_size = MaxFrame ,
102100 reader = ReaderPid ,
103101 pending = [],
104102 pending_size = 0 ,
@@ -142,12 +140,10 @@ format_status(Status) ->
142140 maps :update_with (
143141 state ,
144142 fun (# state {sock = Sock ,
145- max_frame_size = MaxFrame ,
146143 reader = Reader ,
147144 pending = Pending ,
148145 pending_size = PendingSize }) ->
149146 #{socket => Sock ,
150- max_frame_size => MaxFrame ,
151147 reader => Reader ,
152148 % % Below 2 fields should always have the same value.
153149 pending => iolist_size (Pending ),
@@ -189,12 +185,11 @@ internal_send_command_async(Channel, Performative,
189185 pending_size = PendingSize + iolist_size (Frame )}).
190186
191187internal_send_command_async (Channel , Performative , Payload ,
192- State = # state {max_frame_size = MaxFrame ,
193- pending = Pending ,
188+ State = # state {pending = Pending ,
194189 pending_size = PendingSize }) ->
195- Frames = assemble_frame (Channel , Performative , Payload , MaxFrame ),
196- maybe_flush (State # state {pending = [Frames | Pending ],
197- pending_size = PendingSize + iolist_size (Frames )}).
190+ Frame = assemble_frame_with_payload (Channel , Performative , Payload ),
191+ maybe_flush (State # state {pending = [Frame | Pending ],
192+ pending_size = PendingSize + iolist_size (Frame )}).
198193
199194assemble_frame (Channel , Performative ) ->
200195 assemble_frame (Channel , Performative , amqp10_framing ).
@@ -210,8 +205,7 @@ assemble_frame(Channel, Performative, rabbit_amqp_sasl) ->
210205 PerfBin = amqp10_framing :encode_bin (Performative ),
211206 amqp10_binary_generator :build_frame (Channel , ? AMQP_SASL_FRAME_TYPE , PerfBin ).
212207
213- % %TODO respect MaxFrame
214- assemble_frame (Channel , Performative , Payload , _MaxFrame ) ->
208+ assemble_frame_with_payload (Channel , Performative , Payload ) ->
215209 ? TRACE (" channel ~b <-~n ~tp~n followed by ~tb bytes of payload" ,
216210 [Channel , amqp10_framing :pprint (Performative ), iolist_size (Payload )]),
217211 PerfIoData = amqp10_framing :encode_bin (Performative ),
0 commit comments