Conqueuer.Pool
Use this mixin to define a poolboy pool and supervisor.
Given you want a pool named :resolvers and will define a worker named
MyApp.ResolverWorker:
defmodule MyApp.ResolversPoolSupervisor do
use Conqueuer.Pool, name: :resolvers,
worker: MyApp.ResolverWorker,
worker_args: [arg1: 1],
size: 10,
max_overflow: 20
end
The worker_args argument is used for set up the initial state of your
worker, as they are passed through to the worker’s start_link function and
eventually to the init function. The Worker module implements a default
init function sets the worker_args as the worker’s initial state. You may
override the init function and use the options to set up a more custom initial
state.
The size and max_overflow arguments are optional and if not provided the
defaults are size: 1 and max_overflow: 0. For more information on these
options please see the poolboy project’s documentation
or this article.
Now that the :resolvers pool and supervisor is defined you will need to add it to your
supervision tree.
defmodule Test do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
supervisor( MyApp.ResolversPoolSupervisor, [[], [name: :ResolversPoolSupervisor]] ),
...
]
Supervisor.start_link(children, opts)
end
end
The name of the supervisor process is very important as it’s collaborators infer its name through convention.