Packages
db_connection
0.2.3
2.10.2
2.10.1
2.10.0
2.9.0
2.8.1
2.8.0
2.7.0
2.6.0
2.5.0
2.4.3
2.4.2
2.4.1
2.4.0
2.3.1
2.3.0
2.2.2
2.2.1
2.2.0
2.1.1
2.1.0
2.0.6
2.0.5
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
2.0.0-rc.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
1.0.0-rc.5
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
1.0.0-rc.0
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Database connection behaviour for database transactions and connection pooling
Current section
Files
Jump to
Current section
Files
lib/db_connection/sojourn/pool.ex
defmodule DBConnection.Sojourn.Pool do
@moduledoc false
import Supervisor.Spec
def start_link(owner, mod, opts) do
children = [watcher(owner), conn_sup(mod, opts), starter(owner, opts)]
opts = [strategy: :rest_for_one, max_restarts: 0]
Supervisor.start_link(children, opts)
end
## Helpers
defp watcher(owner) do
worker(DBConnection.Watcher, [owner])
end
defp conn_sup(mod, opts) do
child_opts = Keyword.take(opts, [:shutdown])
conn = DBConnection.Connection.child_spec(mod, opts, :sojourn, child_opts)
sup_opts = Keyword.take(opts, [:max_restarts, :max_seconds])
sup_opts = [strategy: :simple_one_for_one] ++ sup_opts
supervisor(Supervisor, [[conn], sup_opts])
end
defp starter(owner, opts) do
worker(DBConnection.Sojourn.Starter, [owner, opts], [restart: :transient])
end
end