Ghoul v0.1.0 Ghoul

Link to this section Summary

Functions

Prevents a Ghoul from executing reap_in or on_death actions

Cancel a pending reap

Gets the current state of a Ghoul worker

Instruct the ghoul to kill the process after a delay. Each time this method is called for a process, previous reap_in directives are canceled. This lets the Ghoul act as a deadman switch for a process, killing it should it fail to progress in an expected manner

Sets the current state of a Ghoul worker

Summon a Ghoul to watch a process. When the pid terminates, the Ghoul will execute the function in the on_death option, passing in the process_key, the reason the pid exited, and the current ghoul_state

Time until a process is reaped

Link to this section Functions

Link to this function banish(process_key)

Prevents a Ghoul from executing reap_in or on_death actions.

Parameters

  • process_key - the process_key of the Ghoul to terminate
Link to this function cancel_reap(process_key)

Cancel a pending reap.

Parameters

  • process_key - the process_key of the Ghoul to prevent termination
Link to this function get_state(process_key)

Gets the current state of a Ghoul worker.

Parameters

  • process_key - the process_key of the Ghoul to terminate
Link to this function reap_in(process_key, reason, delay_ms)

Instruct the ghoul to kill the process after a delay. Each time this method is called for a process, previous reap_in directives are canceled. This lets the Ghoul act as a deadman switch for a process, killing it should it fail to progress in an expected manner.

Parameters

  • process_key - the process_key of the Ghoul to terminate
  • reason - the reason to pass to Process.exit/2
  • delay_ms - how long to wait until reaping the process. Any
Link to this function set_state(process_key, new_state)

Sets the current state of a Ghoul worker.

Parameters

  • process_key - the process_key of the Ghoul to terminate
  • new_state - the new value to use as the ghoul_state
Link to this function summon(process_key, opts \\ %{initial_state: nil, on_death: nil, pid: :self})

Summon a Ghoul to watch a process. When the pid terminates, the Ghoul will execute the function in the on_death option, passing in the process_key, the reason the pid exited, and the current ghoul_state.

Parameters

  • process_key - How this pid should be known to Ghoul. Will be passed to the on_death function as the first parameter.
  • opts - a keyword list or map with the following options:

    • :pid - which pid to have the Ghoul stalk. Defaults to the calling pid.
    • :on_death - a function to be executed after the process dies. Defaults to nil, and nothing will be executed. Expects 3-arity function, to be called as fun.(process_key, exit_reason, ghoul_state) by the Ghoul.
    • :initial_state - the initial ghoul_state for this worker. Defaults to nil. The ghoul_state will be passed to the on_death function as the third parameter, and can be queried using Ghoul.get_state/1 and changed using Ghoul.set_state/2
Link to this function ttl(process_key)

Time until a process is reaped.

Parameters

  • process_key - the process_key of the Ghoul to query