@@ -447,7 +447,8 @@ tuned(info, Msg, StateData) ->
447
447
end ).
448
448
449
449
state_timeout (State , Transport , Socket ) ->
450
- rabbit_log_connection :warning (" Closing connection because of timeout in state '~s ' likely due to lack of client action." ,
450
+ rabbit_log_connection :warning (" Closing connection because of timeout in state "
451
+ " '~s ' likely due to lack of client action." ,
451
452
[State ]),
452
453
close_immediately (Transport , Socket ),
453
454
stop .
@@ -526,7 +527,8 @@ transition_to_opened(Transport,
526
527
config = Configuration }}.
527
528
528
529
invalid_transition (Transport , Socket , From , To ) ->
529
- rabbit_log_connection :warning (" Closing socket ~w . Invalid transition from ~s to ~s ." ,
530
+ rabbit_log_connection :warning (" Closing socket ~w . Invalid transition from ~s "
531
+ " to ~s ." ,
530
532
[Socket , From , To ]),
531
533
close_immediately (Transport , Socket ),
532
534
stop .
@@ -875,8 +877,7 @@ open(cast,
875
877
Ids ->
876
878
Acc #{PublisherId => [PublishingId | Ids ]}
877
879
end ;
878
- false ->
879
- Acc
880
+ false -> Acc
880
881
end
881
882
end ,
882
883
#{}, CorrelationList ),
@@ -956,7 +957,8 @@ open(cast,
956
957
{queue_event , # resource {name = StreamName },
957
958
{osiris_offset , _QueueResource , - 1 }},
958
959
_StatemData ) ->
959
- rabbit_log :debug (" Stream protocol connection received osiris offset event for ~p with offset ~p " ,
960
+ rabbit_log :debug (" Stream protocol connection received osiris offset "
961
+ " event for ~p with offset ~p " ,
960
962
[StreamName , - 1 ]),
961
963
keep_state_and_data ;
962
964
open (cast ,
@@ -975,11 +977,14 @@ open(cast,
975
977
{Connection1 , State1 } =
976
978
case maps :get (StreamName , StreamSubscriptions , undefined ) of
977
979
undefined ->
978
- rabbit_log :debug (" Stream protocol connection: osiris offset event for ~p , but no subscription (leftover messages after unsubscribe?)" ,
980
+ rabbit_log :debug (" Stream protocol connection: osiris offset event "
981
+ " for ~p , but no subscription (leftover messages "
982
+ " after unsubscribe?)" ,
979
983
[StreamName ]),
980
984
{Connection , State };
981
985
[] ->
982
- rabbit_log :debug (" Stream protocol connection: osiris offset event for ~p , but no registered consumers!" ,
986
+ rabbit_log :debug (" Stream protocol connection: osiris offset event "
987
+ " for ~p , but no registered consumers!" ,
983
988
[StreamName ]),
984
989
{Connection # stream_connection {stream_subscriptions =
985
990
maps :remove (StreamName ,
@@ -992,15 +997,15 @@ open(cast,
992
997
# consumer {credit = Credit } = Consumer ,
993
998
Consumer1 =
994
999
case Credit of
995
- 0 ->
996
- Consumer ;
1000
+ 0 -> Consumer ;
997
1001
_ ->
998
1002
case send_chunks (Transport ,
999
1003
Consumer ,
1000
1004
SendFileOct )
1001
1005
of
1002
1006
{error , closed } ->
1003
- rabbit_log_connection :info (" Stream protocol connection has been closed by peer" ,
1007
+ rabbit_log_connection :info (" Stream protocol connection has been closed by "
1008
+ " peer" ,
1004
1009
[]),
1005
1010
throw ({stop , normal });
1006
1011
{error , Reason } ->
@@ -1075,13 +1080,21 @@ close_sent(info, {tcp_closed, S}, _StatemData) ->
1075
1080
rabbit_log_connection :debug (" Stream protocol connection socket ~w closed [~w ]" ,
1076
1081
[S , self ()]),
1077
1082
stop ;
1083
+ <<<<<<< HEAD
1078
1084
close_sent (info , {tcp_error , S , Reason }, # statem_data {}) ->
1079
1085
rabbit_log_connection :error (" Stream protocol connection socket error: ~p [~w ] [~w ]" ,
1086
+ =======
1087
+ close_sent (info , {tcp_error , S , Reason },
1088
+ # statem_data {transport = Transport , connection_state = State }) ->
1089
+ rabbit_log_connection :error (" Stream protocol connection socket error: ~p [~w ] "
1090
+ " [~w ]" ,
1091
+ >>>>>>> master
1080
1092
[Reason , S , self ()]),
1081
1093
stop ;
1082
1094
close_sent (info , {resource_alarm , IsThereAlarm },
1083
1095
StatemData = # statem_data {connection = Connection }) ->
1084
- rabbit_log :warning (" Stream protocol connection ignored a resource alarm ~p in state ~s " ,
1096
+ rabbit_log :warning (" Stream protocol connection ignored a resource "
1097
+ " alarm ~p in state ~s " ,
1085
1098
[IsThereAlarm , ? FUNCTION_NAME ]),
1086
1099
{keep_state ,
1087
1100
StatemData # statem_data {connection =
@@ -1814,7 +1827,8 @@ handle_frame_post_auth(Transport,
1814
1827
SendFileOct )
1815
1828
of
1816
1829
{error , closed } ->
1817
- rabbit_log_connection :info (" Stream protocol connection has been closed by peer" ,
1830
+ rabbit_log_connection :info (" Stream protocol connection has been closed by "
1831
+ " peer" ,
1818
1832
[]),
1819
1833
throw ({stop , normal });
1820
1834
{{segment , Segment1 }, {credit , Credit1 }} ->
@@ -1895,7 +1909,8 @@ handle_frame_post_auth(Transport,
1895
1909
SendFileOct )
1896
1910
of
1897
1911
{error , closed } ->
1898
- rabbit_log_connection :info (" Stream protocol connection has been closed by peer" ,
1912
+ rabbit_log_connection :info (" Stream protocol connection has been closed by "
1913
+ " peer" ,
1899
1914
[]),
1900
1915
throw ({stop , normal });
1901
1916
{{segment , Segment1 }, {credit , Credit1 }} ->
@@ -2047,7 +2062,8 @@ handle_frame_post_auth(Transport,
2047
2062
{ok ,
2048
2063
#{leader_node := LeaderPid ,
2049
2064
replica_nodes := ReturnedReplicas }} ->
2050
- rabbit_log :debug (" Created stream cluster with leader on ~p and replicas on ~p " ,
2065
+ rabbit_log :debug (" Created stream cluster with leader on ~p and "
2066
+ " replicas on ~p " ,
2051
2067
[LeaderPid , ReturnedReplicas ]),
2052
2068
response_ok (Transport ,
2053
2069
Connection ,
@@ -2208,8 +2224,7 @@ handle_frame_post_auth(Transport,
2208
2224
NodesAcc )
2209
2225
end ,
2210
2226
Acc1 , ReplicaNodes );
2211
- {error , _ } ->
2212
- Acc
2227
+ {error , _ } -> Acc
2213
2228
end
2214
2229
end ,
2215
2230
#{}, Streams ),
@@ -2221,16 +2236,13 @@ handle_frame_post_auth(Transport,
2221
2236
lists :foldr (fun (Node , Acc ) ->
2222
2237
PortFunction =
2223
2238
case TransportLayer of
2224
- tcp ->
2225
- port ;
2226
- ssl ->
2227
- tls_port
2239
+ tcp -> port ;
2240
+ ssl -> tls_port
2228
2241
end ,
2229
2242
Host = rpc :call (Node , rabbit_stream , host , []),
2230
2243
Port = rpc :call (Node , rabbit_stream , PortFunction , []),
2231
2244
case {is_binary (Host ), is_integer (Port )} of
2232
- {true , true } ->
2233
- Acc #{Node => {Host , Port }};
2245
+ {true , true } -> Acc #{Node => {Host , Port }};
2234
2246
_ ->
2235
2247
rabbit_log :warning (" Error when retrieving broker metadata: ~p ~p " ,
2236
2248
[Host , Port ]),
@@ -2242,25 +2254,21 @@ handle_frame_post_auth(Transport,
2242
2254
Metadata =
2243
2255
lists :foldl (fun (Stream , Acc ) ->
2244
2256
case maps :get (Stream , Topology ) of
2245
- {error , Err } ->
2246
- Acc #{Stream => Err };
2257
+ {error , Err } -> Acc #{Stream => Err };
2247
2258
{ok ,
2248
2259
#{leader_node := LeaderNode ,
2249
2260
replica_nodes := Replicas }} ->
2250
2261
LeaderInfo =
2251
2262
case NodeEndpoints of
2252
- #{LeaderNode := Info } ->
2253
- Info ;
2254
- _ ->
2255
- undefined
2263
+ #{LeaderNode := Info } -> Info ;
2264
+ _ -> undefined
2256
2265
end ,
2257
2266
ReplicaInfos =
2258
2267
lists :foldr (fun (Replica , A ) ->
2259
2268
case NodeEndpoints of
2260
2269
#{Replica := I } ->
2261
2270
[I | A ];
2262
- _ ->
2263
- A
2271
+ _ -> A
2264
2272
end
2265
2273
end ,
2266
2274
[], Replicas ),
@@ -2287,16 +2295,21 @@ handle_frame_post_auth(Transport,
2287
2295
case rabbit_stream_manager :route (RoutingKey , VirtualHost , SuperStream )
2288
2296
of
2289
2297
{ok , no_route } ->
2290
- {? RESPONSE_CODE_OK , <<(- 1 ):16 >>};
2291
- {ok , Stream } ->
2292
- StreamSize = byte_size (Stream ),
2293
- {? RESPONSE_CODE_OK ,
2294
- <<StreamSize :16 , Stream :StreamSize /binary >>};
2298
+ {? RESPONSE_CODE_OK , <<0 :32 >>};
2299
+ {ok , Streams } ->
2300
+ StreamCount = length (Streams ),
2301
+ Bin = lists :foldl (fun (Stream , Acc ) ->
2302
+ StreamSize = byte_size (Stream ),
2303
+ <<Acc /binary , StreamSize :16 ,
2304
+ Stream :StreamSize /binary >>
2305
+ end ,
2306
+ <<StreamCount :32 >>, Streams ),
2307
+ {? RESPONSE_CODE_OK , Bin };
2295
2308
{error , _ } ->
2296
2309
rabbit_global_counters :increase_protocol_counter (stream ,
2297
2310
? STREAM_DOES_NOT_EXIST ,
2298
2311
1 ),
2299
- {? RESPONSE_CODE_STREAM_DOES_NOT_EXIST , <<( - 1 ): 16 >>}
2312
+ {? RESPONSE_CODE_STREAM_DOES_NOT_EXIST , <<0 : 32 >>}
2300
2313
end ,
2301
2314
2302
2315
Frame =
@@ -2348,7 +2361,8 @@ handle_frame_post_auth(Transport,
2348
2361
State ,
2349
2362
{request , CorrelationId ,
2350
2363
{close , ClosingCode , ClosingReason }}) ->
2351
- rabbit_log :debug (" Stream protocol reader received close command ~p ~p " ,
2364
+ rabbit_log :debug (" Stream protocol reader received close command "
2365
+ " ~p ~p " ,
2352
2366
[ClosingCode , ClosingReason ]),
2353
2367
Frame =
2354
2368
rabbit_stream_core :frame ({response , CorrelationId ,
@@ -2471,8 +2485,7 @@ clean_state_after_stream_deletion_or_failure(Stream,
2471
2485
PubId ),
2472
2486
{maps :remove (PubId , Pubs ),
2473
2487
maps :remove ({Stream , Ref }, PubToIds )};
2474
- _ ->
2475
- {Pubs , PubToIds }
2488
+ _ -> {Pubs , PubToIds }
2476
2489
end
2477
2490
end ,
2478
2491
{Publishers , PublisherToIds }, Publishers ),
@@ -2589,8 +2602,7 @@ demonitor_stream(Stream,
2589
2602
Stream ->
2590
2603
demonitor (MonitorRef , [flush ]),
2591
2604
Acc ;
2592
- _ ->
2593
- maps :put (MonitorRef , Strm , Acc )
2605
+ _ -> maps :put (MonitorRef , Strm , Acc )
2594
2606
end
2595
2607
end ,
2596
2608
#{}, Monitors0 ),
@@ -2611,10 +2623,8 @@ stream_has_publishers(Stream,
2611
2623
# stream_connection {publishers = Publishers }) ->
2612
2624
lists :any (fun (# publisher {stream = S }) ->
2613
2625
case S of
2614
- Stream ->
2615
- true ;
2616
- _ ->
2617
- false
2626
+ Stream -> true ;
2627
+ _ -> false
2618
2628
end
2619
2629
end ,
2620
2630
maps :values (Publishers )).
0 commit comments