ExPool v0.1.1 ExPool.State.Factory

A factory of workers.

This module defines a ExPool.State.Factory struct and the main functions to create and destroy workers.

Fields

  • sup - simple_one_for_one supervisor to start and supervise workers
  • total - number of existing workers

Summary

Functions

Creates a new worker

Destroys a worker

Builds a new Factory struct with the given configuration

Informs the factory a worker is dead

Types

sup :: pid
t :: %ExPool.State.Factory{sup: sup, total: total}
total :: non_neg_integer
worker :: pid

Functions

create(factory)

Specs

create(t) :: {worker, t}

Creates a new worker.

destroy(factory, worker)

Specs

destroy(t, worker) :: {t}

Destroys a worker.

new(opts)

Specs

new(opts :: [Keyword]) :: t

Builds a new Factory struct with the given configuration.

Configuration options

  • :worker_mod - (Required) worker module that fits on a supervision tree
report_death(factory)

Specs

report_death(t) :: {t}

Informs the factory a worker is dead.