PhoenixGenApi.WorkerPool.Worker (PhoenixGenApi v1.1.2)
View SourceIndividual worker process for executing tasks.
Workers are managed by the WorkerPool and execute tasks one at a time. When a task completes, the worker notifies the pool that it's available for more work.
Lifecycle
- Worker starts in idle state
- Pool assigns a task via
execute/2 - Worker executes the task
- Worker notifies pool when done
- Returns to idle state
Error Handling
If a task raises an exception, the worker catches it, logs the error, and continues running. The pool is notified that the worker is done even if the task failed.
Summary
Functions
Returns a specification to start this module under a supervisor.
Executes a task on this worker.
Starts a worker process.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Executes a task on this worker.
Parameters
worker_pid- The worker process PIDtask- A zero-arity function to execute
Starts a worker process.
Parameters
opts- Keyword list with::pool_name- Name of the parent pool (required)