Skip to content

Commit f734d2c

Browse files
Add more logging details and capabilities (#126)
1 parent 54426ce commit f734d2c

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/mero.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ inc_state(St, Acc) ->
345345
Acc).
346346

347347
deep_state(ClusterName) ->
348-
F = fun({_, _, Pool, _}, Acc) ->
348+
F = fun({Host, Port, Pool, _}, Acc) ->
349349
St = mero_pool:state(Pool),
350-
[[{pool, Pool} | St] | Acc]
350+
[[{pool, Pool}, {host, Host}, {port, Port} | St] | Acc]
351351
end,
352352
lists:foldr(F, [], mero_cluster:child_definitions(ClusterName)).
353353

src/mero_pool.erl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,23 @@ pool_loop(State, Parent, Deb) ->
278278

279279
get_connection(#pool_st{free = Free} = State, From) when Free /= [] ->
280280
give(State, From);
281-
get_connection(State, {Pid, Ref} = _From) ->
281+
get_connection(#pool_st{callback_info = CallbackInfo} = State, {Pid, Ref} = _From) ->
282+
?LOG_EVENT(CallbackInfo, [socket, checkout, reject, {class, reject_class(State)}]),
282283
safe_send(Pid, {Ref, {reject, State}}),
283284
maybe_spawn_connect(State).
284285

286+
reject_class(#pool_st{num_failed_connecting = Failed}) when Failed > 0 ->
287+
degraded;
288+
reject_class(#pool_st{num_connected = Connected,
289+
num_connecting = 0,
290+
max_connections = Max})
291+
when Connected >= Max ->
292+
saturated;
293+
reject_class(#pool_st{num_connecting = Connecting}) when Connecting > 0 ->
294+
warming;
295+
reject_class(_State) ->
296+
under_capacity.
297+
285298
maybe_spawn_connect(#pool_st{free = Free,
286299
num_connecting = Connecting,
287300
num_connected = Connected,

0 commit comments

Comments
 (0)