Reactor.Process.Step.StartChild (reactor_process v0.5.0)

View Source

Adds a child specification to a supervisor and starts that child.

See the documentation for Supervisor.start_child/2 for more information.

Result

The step returns a Reactor.Process.Step.StartChild.Result. The pid field is the child process. The id field is the id from the child spec. The started? field records whether this step started the child.

When fail_on_already_started? is false and the child is already started, the step returns that child with started?: false.

When fail_on_already_present? is false and the child spec is present but the child is stopped, the step restarts the child with restart_child/2 and returns it with started?: true. If the supervisor module does not export restart_child/2, the step fails with {:error, :already_present}.

Undo

Undo only acts on a child that this step started. Undo does not touch a child with started?: false.

When terminate_on_undo? is true, undo terminates the child with terminate_child/2, waits for it to exit, and then removes the child spec with delete_child/2. This returns the supervisor to the state it had before the step ran. If the supervisor module does not export delete_child/2, the child spec stays in the supervisor.

Arguments

  • :supervisor - Required. The supervisor to query

  • :child_spec - Required. The child spec

Options

  • :module (module/0) - The supervisor module. Must export start_child/2 and terminate_child/2. restart_child/2 and delete_child/2 are called when exported The default value is Supervisor.

  • :fail_on_already_present? (boolean/0) - Whether the step should fail if the child spec is already present in the supervisor The default value is true.

  • :fail_on_already_started? (boolean/0) - Whether the step should fail if the start function returns an already started error The default value is true.

  • :terminate_on_undo? (boolean/0) - Whether to terminate the started process when the Reactor is undoing changes The default value is true.

  • :termination_timeout (timeout/0) - How long to wait for a process to terminate The default value is 5000.