populator v0.5.0 Populator

Summary

Functions

It will update the given supervisor until it has the population demanded by desired_children, either by creating new children or by killing existing ones

Functions

run(supervisor, child_spec, desired_children, opts \\ [])

It will update the given supervisor until it has the population demanded by desired_children, either by creating new children or by killing existing ones.

Every child created will be done so using the spec returned by child_spec, so the child_spec function should end with a call to Supervisor.Spec.worker/3. It should also register each worker with a unique name.

The desired_children function should return a list of children data, with all the state needed by the child_spec function for each of them. It should include a :name with the unique name for each child.

:ok will be returned.

  • supervisor is the supervisor name
  • child_spec is a function returning a children spec given its child data
  • desired_children is a function returning a list with data for each child
  • stationary can be given to avoid the actual execution, useful on testing environments, for example. :stationary will be returned.

    See README.md for further details.