View Source FLAME.Pool (flame v0.1.8)
Manages a pool of FLAME.Runner's.
Pools support elastic growth and shrinking of the number of runners.
Examples
children = [
...,
{FLAME.Pool, name: MyRunner, min: 1, max: 10, max_concurrency: 100}
]See start_link/1 for supported options.
TODO
[ ] interface to configure min/max at runtime
Summary
Functions
Calls a function in a remote runner for the given FLAME.Pool.
Casts a function to a remote runner for the given FLAME.Pool.
Returns a specification to start this module under a supervisor.
See FLAME.place_child/3 for more information.
Starts a pool of runners.
Functions
Calls a function in a remote runner for the given FLAME.Pool.
See FLAME.call/3 for more information.
Casts a function to a remote runner for the given FLAME.Pool.
See FLAME.cast/2 for more information.
Returns a specification to start this module under a supervisor.
See Supervisor.
See FLAME.place_child/3 for more information.
Starts a pool of runners.
Options
:name- The name of the pool, for example:MyApp.FFMPegRunner:min- The minimum number of runners to keep in the pool at all times. For "scale to zero" behavior you may pass0. When starting as a flame child, the:minwill be forced to zero to avoid recursively starting backend resources.:max- The maximum number of runners to elastically grow to in the pool.:max_concurrency- The maximum number of concurrent executions per runner before booting new runners or queueing calls. Defaults to100.:single_use- iftrue, runners will be terminated after each call completes. Defaultsfalse.:backend- The backend to use. Defaults to the configured:flame, :backendorFLAME.LocalBackendif not configured.:log- The log level to use for verbose logging. Defaults tofalse.:timeout- The time to allow functions to execute on a remote node. Defaults to 30 seconds. This value is also used as the defaultFLAME.call/3timeout for the caller.:boot_timeout- The time to allow for booting and connecting to a remote node. Defaults to 30 seconds.:shutdown_timeout- The time to allow for graceful shutdown on the remote node. Defaults to 30 seconds.:idle_shutdown_after- The amount of time and function check to idle a remote node down after a period of inactivity. Defaults to 30 seconds. A tuple may also be passed to check a specific condition, for example:{10_000, fn -> Supervisor.which_children(MySup) == []}:min_idle_shutdown_after- The same behavior of:idle_shutdown_after, but applied to the the:minpool runners. Defaults to:infinity.:on_grow_start- The optional function to be called when the pool starts booting a new runner beyond the configured:min. The function receives a map with the following metadata::name- The name of the pool:count- The number of runners the pool is attempting to grow to:pid- The pid of the async process that is booting the new runner
:on_grow_end- The optional 2-arty function to be called when the pool growth process completes. The 2-arity function receives either:okor{:exit, reason}, and map with the following metadata::name- The name of the pool:count- The number of runners the pool is now at:pid- The pid of the async process that attempted to boot the new runner
:on_shrink- The optional function to be called when the pool shrinks. The function receives a map with the following metadata::name- The name of the pool:count- The number of runners the pool is attempting to shrink to