@@ -445,7 +445,8 @@ tuned(info, Msg, StateData) ->
445
445
end ).
446
446
447
447
state_timeout (State , Transport , Socket ) ->
448
- rabbit_log_connection :warning (" Closing connection because of timeout in state '~s ' likely due to lack of client action." ,
448
+ rabbit_log_connection :warning (" Closing connection because of timeout in state "
449
+ " '~s ' likely due to lack of client action." ,
449
450
[State ]),
450
451
close_immediately (Transport , Socket ),
451
452
stop .
@@ -524,7 +525,8 @@ transition_to_opened(Transport,
524
525
config = Configuration }}.
525
526
526
527
invalid_transition (Transport , Socket , From , To ) ->
527
- rabbit_log_connection :warning (" Closing socket ~w . Invalid transition from ~s to ~s ." ,
528
+ rabbit_log_connection :warning (" Closing socket ~w . Invalid transition from ~s "
529
+ " to ~s ." ,
528
530
[Socket , From , To ]),
529
531
close_immediately (Transport , Socket ),
530
532
stop .
@@ -882,8 +884,7 @@ open(cast,
882
884
Ids ->
883
885
Acc #{PublisherId => [PublishingId | Ids ]}
884
886
end ;
885
- false ->
886
- Acc
887
+ false -> Acc
887
888
end
888
889
end ,
889
890
#{}, CorrelationList ),
@@ -963,7 +964,8 @@ open(cast,
963
964
{queue_event , # resource {name = StreamName },
964
965
{osiris_offset , _QueueResource , - 1 }},
965
966
_StatemData ) ->
966
- rabbit_log :debug (" Stream protocol connection received osiris offset event for ~p with offset ~p " ,
967
+ rabbit_log :debug (" Stream protocol connection received osiris offset "
968
+ " event for ~p with offset ~p " ,
967
969
[StreamName , - 1 ]),
968
970
keep_state_and_data ;
969
971
open (cast ,
@@ -982,11 +984,14 @@ open(cast,
982
984
{Connection1 , State1 } =
983
985
case maps :get (StreamName , StreamSubscriptions , undefined ) of
984
986
undefined ->
985
- rabbit_log :debug (" Stream protocol connection: osiris offset event for ~p , but no subscription (leftover messages after unsubscribe?)" ,
987
+ rabbit_log :debug (" Stream protocol connection: osiris offset event "
988
+ " for ~p , but no subscription (leftover messages "
989
+ " after unsubscribe?)" ,
986
990
[StreamName ]),
987
991
{Connection , State };
988
992
[] ->
989
- rabbit_log :debug (" Stream protocol connection: osiris offset event for ~p , but no registered consumers!" ,
993
+ rabbit_log :debug (" Stream protocol connection: osiris offset event "
994
+ " for ~p , but no registered consumers!" ,
990
995
[StreamName ]),
991
996
{Connection # stream_connection {stream_subscriptions =
992
997
maps :remove (StreamName ,
@@ -999,15 +1004,15 @@ open(cast,
999
1004
# consumer {credit = Credit } = Consumer ,
1000
1005
Consumer1 =
1001
1006
case Credit of
1002
- 0 ->
1003
- Consumer ;
1007
+ 0 -> Consumer ;
1004
1008
_ ->
1005
1009
case send_chunks (Transport ,
1006
1010
Consumer ,
1007
1011
SendFileOct )
1008
1012
of
1009
1013
{error , closed } ->
1010
- rabbit_log_connection :info (" Stream protocol connection has been closed by peer" ,
1014
+ rabbit_log_connection :info (" Stream protocol connection has been closed by "
1015
+ " peer" ,
1011
1016
[]),
1012
1017
throw ({stop , normal });
1013
1018
{error , Reason } ->
@@ -1058,7 +1063,8 @@ close_sent(state_timeout, close,
1058
1063
# statem_data {transport = Transport ,
1059
1064
connection = # stream_connection {socket = Socket },
1060
1065
connection_state = State }) ->
1061
- rabbit_log_connection :warning (" Closing connection because of timeout in state '~s ' likely due to lack of client action." ,
1066
+ rabbit_log_connection :warning (" Closing connection because of timeout in state "
1067
+ " '~s ' likely due to lack of client action." ,
1062
1068
[? FUNCTION_NAME ]),
1063
1069
close (Transport , Socket , State ),
1064
1070
stop ;
@@ -1089,13 +1095,15 @@ close_sent(info, {tcp_closed, S}, _StatemData) ->
1089
1095
stop ;
1090
1096
close_sent (info , {tcp_error , S , Reason },
1091
1097
# statem_data {transport = Transport , connection_state = State }) ->
1092
- rabbit_log_connection :error (" Stream protocol connection socket error: ~p [~w ] [~w ]" ,
1098
+ rabbit_log_connection :error (" Stream protocol connection socket error: ~p [~w ] "
1099
+ " [~w ]" ,
1093
1100
[Reason , S , self ()]),
1094
1101
close (Transport , S , State ),
1095
1102
stop ;
1096
1103
close_sent (info , {resource_alarm , IsThereAlarm },
1097
1104
StatemData = # statem_data {connection = Connection }) ->
1098
- rabbit_log :warning (" Stream protocol connection ignored a resource alarm ~p in state ~s " ,
1105
+ rabbit_log :warning (" Stream protocol connection ignored a resource "
1106
+ " alarm ~p in state ~s " ,
1099
1107
[IsThereAlarm , ? FUNCTION_NAME ]),
1100
1108
{keep_state ,
1101
1109
StatemData # statem_data {connection =
@@ -1828,7 +1836,8 @@ handle_frame_post_auth(Transport,
1828
1836
SendFileOct )
1829
1837
of
1830
1838
{error , closed } ->
1831
- rabbit_log_connection :info (" Stream protocol connection has been closed by peer" ,
1839
+ rabbit_log_connection :info (" Stream protocol connection has been closed by "
1840
+ " peer" ,
1832
1841
[]),
1833
1842
throw ({stop , normal });
1834
1843
{{segment , Segment1 }, {credit , Credit1 }} ->
@@ -1909,7 +1918,8 @@ handle_frame_post_auth(Transport,
1909
1918
SendFileOct )
1910
1919
of
1911
1920
{error , closed } ->
1912
- rabbit_log_connection :info (" Stream protocol connection has been closed by peer" ,
1921
+ rabbit_log_connection :info (" Stream protocol connection has been closed by "
1922
+ " peer" ,
1913
1923
[]),
1914
1924
throw ({stop , normal });
1915
1925
{{segment , Segment1 }, {credit , Credit1 }} ->
@@ -2061,7 +2071,8 @@ handle_frame_post_auth(Transport,
2061
2071
{ok ,
2062
2072
#{leader_node := LeaderPid ,
2063
2073
replica_nodes := ReturnedReplicas }} ->
2064
- rabbit_log :debug (" Created stream cluster with leader on ~p and replicas on ~p " ,
2074
+ rabbit_log :debug (" Created stream cluster with leader on ~p and "
2075
+ " replicas on ~p " ,
2065
2076
[LeaderPid , ReturnedReplicas ]),
2066
2077
response_ok (Transport ,
2067
2078
Connection ,
@@ -2222,8 +2233,7 @@ handle_frame_post_auth(Transport,
2222
2233
NodesAcc )
2223
2234
end ,
2224
2235
Acc1 , ReplicaNodes );
2225
- {error , _ } ->
2226
- Acc
2236
+ {error , _ } -> Acc
2227
2237
end
2228
2238
end ,
2229
2239
#{}, Streams ),
@@ -2235,16 +2245,13 @@ handle_frame_post_auth(Transport,
2235
2245
lists :foldr (fun (Node , Acc ) ->
2236
2246
PortFunction =
2237
2247
case TransportLayer of
2238
- tcp ->
2239
- port ;
2240
- ssl ->
2241
- tls_port
2248
+ tcp -> port ;
2249
+ ssl -> tls_port
2242
2250
end ,
2243
2251
Host = rpc :call (Node , rabbit_stream , host , []),
2244
2252
Port = rpc :call (Node , rabbit_stream , PortFunction , []),
2245
2253
case {is_binary (Host ), is_integer (Port )} of
2246
- {true , true } ->
2247
- Acc #{Node => {Host , Port }};
2254
+ {true , true } -> Acc #{Node => {Host , Port }};
2248
2255
_ ->
2249
2256
rabbit_log :warning (" Error when retrieving broker metadata: ~p ~p " ,
2250
2257
[Host , Port ]),
@@ -2256,25 +2263,21 @@ handle_frame_post_auth(Transport,
2256
2263
Metadata =
2257
2264
lists :foldl (fun (Stream , Acc ) ->
2258
2265
case maps :get (Stream , Topology ) of
2259
- {error , Err } ->
2260
- Acc #{Stream => Err };
2266
+ {error , Err } -> Acc #{Stream => Err };
2261
2267
{ok ,
2262
2268
#{leader_node := LeaderNode ,
2263
2269
replica_nodes := Replicas }} ->
2264
2270
LeaderInfo =
2265
2271
case NodeEndpoints of
2266
- #{LeaderNode := Info } ->
2267
- Info ;
2268
- _ ->
2269
- undefined
2272
+ #{LeaderNode := Info } -> Info ;
2273
+ _ -> undefined
2270
2274
end ,
2271
2275
ReplicaInfos =
2272
2276
lists :foldr (fun (Replica , A ) ->
2273
2277
case NodeEndpoints of
2274
2278
#{Replica := I } ->
2275
2279
[I | A ];
2276
- _ ->
2277
- A
2280
+ _ -> A
2278
2281
end
2279
2282
end ,
2280
2283
[], Replicas ),
@@ -2301,16 +2304,21 @@ handle_frame_post_auth(Transport,
2301
2304
case rabbit_stream_manager :route (RoutingKey , VirtualHost , SuperStream )
2302
2305
of
2303
2306
{ok , no_route } ->
2304
- {? RESPONSE_CODE_OK , <<(- 1 ):16 >>};
2305
- {ok , Stream } ->
2306
- StreamSize = byte_size (Stream ),
2307
- {? RESPONSE_CODE_OK ,
2308
- <<StreamSize :16 , Stream :StreamSize /binary >>};
2307
+ {? RESPONSE_CODE_OK , <<0 :32 >>};
2308
+ {ok , Streams } ->
2309
+ StreamCount = length (Streams ),
2310
+ Bin = lists :foldl (fun (Stream , Acc ) ->
2311
+ StreamSize = byte_size (Stream ),
2312
+ <<Acc /binary , StreamSize :16 ,
2313
+ Stream :StreamSize /binary >>
2314
+ end ,
2315
+ <<StreamCount :32 >>, Streams ),
2316
+ {? RESPONSE_CODE_OK , Bin };
2309
2317
{error , _ } ->
2310
2318
rabbit_global_counters :increase_protocol_counter (stream ,
2311
2319
? STREAM_DOES_NOT_EXIST ,
2312
2320
1 ),
2313
- {? RESPONSE_CODE_STREAM_DOES_NOT_EXIST , <<( - 1 ): 16 >>}
2321
+ {? RESPONSE_CODE_STREAM_DOES_NOT_EXIST , <<0 : 32 >>}
2314
2322
end ,
2315
2323
2316
2324
Frame =
@@ -2362,7 +2370,8 @@ handle_frame_post_auth(Transport,
2362
2370
State ,
2363
2371
{request , CorrelationId ,
2364
2372
{close , ClosingCode , ClosingReason }}) ->
2365
- rabbit_log :debug (" Stream protocol reader received close command ~p ~p " ,
2373
+ rabbit_log :debug (" Stream protocol reader received close command "
2374
+ " ~p ~p " ,
2366
2375
[ClosingCode , ClosingReason ]),
2367
2376
Frame =
2368
2377
rabbit_stream_core :frame ({response , CorrelationId ,
@@ -2485,8 +2494,7 @@ clean_state_after_stream_deletion_or_failure(Stream,
2485
2494
PubId ),
2486
2495
{maps :remove (PubId , Pubs ),
2487
2496
maps :remove ({Stream , Ref }, PubToIds )};
2488
- _ ->
2489
- {Pubs , PubToIds }
2497
+ _ -> {Pubs , PubToIds }
2490
2498
end
2491
2499
end ,
2492
2500
{Publishers , PublisherToIds }, Publishers ),
@@ -2603,8 +2611,7 @@ demonitor_stream(Stream,
2603
2611
Stream ->
2604
2612
demonitor (MonitorRef , [flush ]),
2605
2613
Acc ;
2606
- _ ->
2607
- maps :put (MonitorRef , Strm , Acc )
2614
+ _ -> maps :put (MonitorRef , Strm , Acc )
2608
2615
end
2609
2616
end ,
2610
2617
#{}, Monitors0 ),
@@ -2625,10 +2632,8 @@ stream_has_publishers(Stream,
2625
2632
# stream_connection {publishers = Publishers }) ->
2626
2633
lists :any (fun (# publisher {stream = S }) ->
2627
2634
case S of
2628
- Stream ->
2629
- true ;
2630
- _ ->
2631
- false
2635
+ Stream -> true ;
2636
+ _ -> false
2632
2637
end
2633
2638
end ,
2634
2639
maps :values (Publishers )).
0 commit comments