Skip to content

Commit

Permalink
Merge pull request #108 from ahovgaard/child-spec-map
Browse files Browse the repository at this point in the history
Support child_spec map format.
  • Loading branch information
Vagabond authored Aug 17, 2018
2 parents 79adfe5 + 1d68fb9 commit 0fe289b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ otp_release:
- 19.3
- 18.3
- 17.4
- R16B03-1
sudo: false
script:
- ./rebar3 do compile, dialyzer
21 changes: 18 additions & 3 deletions src/poolboy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
-behaviour(gen_server).

-export([checkout/1, checkout/2, checkout/3, checkin/2, transaction/2,
transaction/3, child_spec/2, child_spec/3, start/1, start/2,
start_link/1, start_link/2, stop/1, status/1]).
transaction/3, child_spec/2, child_spec/3, child_spec/4, start/1,
start/2, start_link/1, start_link/2, stop/1, status/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
code_change/3]).
-export_type([pool/0]).
Expand Down Expand Up @@ -96,8 +96,23 @@ child_spec(PoolId, PoolArgs) ->
WorkerArgs :: proplists:proplist())
-> supervisor:child_spec().
child_spec(PoolId, PoolArgs, WorkerArgs) ->
child_spec(PoolId, PoolArgs, WorkerArgs, tuple).

-spec child_spec(PoolId :: term(),
PoolArgs :: proplists:proplist(),
WorkerArgs :: proplists:proplist(),
ChildSpecFormat :: 'tuple' | 'map')
-> supervisor:child_spec().
child_spec(PoolId, PoolArgs, WorkerArgs, tuple) ->
{PoolId, {poolboy, start_link, [PoolArgs, WorkerArgs]},
permanent, 5000, worker, [poolboy]}.
permanent, 5000, worker, [poolboy]};
child_spec(PoolId, PoolArgs, WorkerArgs, map) ->
#{id => PoolId,
start => {poolboy, start_link, [PoolArgs, WorkerArgs]},
restart => permanent,
shutdown => 5000,
type => worker,
modules => [poolboy]}.

-spec start(PoolArgs :: proplists:proplist())
-> start_ret().
Expand Down

0 comments on commit 0fe289b

Please sign in to comment.