Skip to content
This repository

poolboy:status/1 #11

Merged
merged 2 commits into from over 1 year ago

2 participants

James Golick Devin Torres
James Golick

Sometimes it's cool to know what's going on in your pools.

Devin Torres devinus merged commit 0e45be9 into from August 07, 2012
Devin Torres devinus closed this August 07, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
6  src/poolboy.erl
@@ -4,7 +4,7 @@
4 4
 -behaviour(gen_fsm).
5 5
 
6 6
 -export([checkout/1, checkout/2, checkout/3, checkin/2, transaction/2,
7  
-         child_spec/2, start_link/1, stop/1]).
  7
+         child_spec/2, start_link/1, stop/1, status/1]).
8 8
 -export([init/1, ready/2, ready/3, overflow/2, overflow/3, full/2, full/3,
9 9
          handle_event/3, handle_sync_event/4, handle_info/3, terminate/3,
10 10
          code_change/4]).
@@ -67,6 +67,10 @@ start_link(Args)  ->
67 67
 stop(Pool) ->
68 68
     gen_fsm:sync_send_all_state_event(Pool, stop).
69 69
 
  70
+-spec status(Pool :: node()) -> {state, integer(), integer(), integer()}.
  71
+status(Pool) ->
  72
+    gen_fsm:sync_send_all_state_event(Pool, status).
  73
+
70 74
 init(Args) ->
71 75
     process_flag(trap_exit, true),
72 76
     Waiting = queue:new(),
8  test/poolboy_tests.erl
@@ -50,6 +50,9 @@ pool_test_() ->
50 50
             },
51 51
             {<<"Worker checked-in after an exception in a transaction">>,
52 52
                 fun checkin_after_exception_in_transaction/0
  53
+            },
  54
+            {<<"Pool returns status">>,
  55
+                fun pool_returns_status/0
53 56
             }
54 57
         ]
55 58
     }.
@@ -363,6 +366,11 @@ checkin_after_exception_in_transaction() ->
363 366
     ?assertEqual(2, length(?sync(Pool, get_avail_workers))),
364 367
     ok = ?sync(Pool, stop).
365 368
 
  369
+pool_returns_status() ->
  370
+    {ok, Pool} = new_pool(2, 0),
  371
+    ?assertEqual({ready, 2, 0, 0}, poolboy:status(Pool)),
  372
+    ok = ?sync(Pool, stop).
  373
+
366 374
 new_pool(Size, MaxOverflow) ->
367 375
     poolboy:start_link([{name, {local, poolboy_test}},
368 376
                         {worker_module, poolboy_test_worker},
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.