aboutsummaryrefslogtreecommitdiffstats
path: root/src/mysqlerl_sup.erl
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2012-02-09 14:38:16 -0500
committerBrian Cully <bjc@kublai.com>2012-02-09 14:38:54 -0500
commitba58faaa776b911c3ce74e49cf39a9f14bc436d1 (patch)
treefd91fb11d387226228ce4d18dd54528a73ab3216 /src/mysqlerl_sup.erl
parent8cd5a7f161743d6b6a995b92b1702909809b8cdc (diff)
downloadmysqlerl-ba58faaa776b911c3ce74e49cf39a9f14bc436d1.tar.gz
mysqlerl-ba58faaa776b911c3ce74e49cf39a9f14bc436d1.zip
Move functions from mysqlerl_sup to mysqlerl, and get rid of random_child/0.
Diffstat (limited to 'src/mysqlerl_sup.erl')
-rw-r--r--src/mysqlerl_sup.erl26
1 files changed, 5 insertions, 21 deletions
diff --git a/src/mysqlerl_sup.erl b/src/mysqlerl_sup.erl
index 361fe2b..9a3c4e8 100644
--- a/src/mysqlerl_sup.erl
+++ b/src/mysqlerl_sup.erl
@@ -3,25 +3,9 @@
-behavior(supervisor).
--export([start_link/0, init/1, connect/6, random_child/0]).
+-export([init/1]).
-start_link() ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-connect(Host, Port, Database, User, Password, Options) ->
- supervisor:start_child(?MODULE, [self(), Host, Port, Database,
- User, Password, Options]).
-
-random_child() ->
- case get_pids() of
- [] -> {error, no_connections};
- Pids -> lists:nth(erlang:phash(now(), length(Pids)), Pids)
- end.
-
-init([]) ->
- Connection = {undefined, {mysqlerl_connection, start_link, []},
- transient, 5, worker, [mysqlerl_connection]},
- {ok, {{simple_one_for_one, 10, 5}, [Connection]}}.
-
-get_pids() ->
- [Pid || {_Id, Pid, _Type, _Modules} <- supervisor:which_children(?MODULE)].
+init([Name]) ->
+ Connection = {Name, {mysqlerl_connection, start_link, []},
+ temporary, 7000, worker, [mysqlerl_connection]},
+ {ok, {{simple_one_for_one, 0, 3600}, [Connection]}}.