Parent.Client (parent v0.12.0) View Source

Functions for interacting with parent's children from other processes.

All of these functions issue a call to the parent process. Therefore, they can't be used from inside the parent process. Use functions from the Parent module instead to interact with the children from within the process.

Likewise these functions can't be invoked inside the child process during its initialization. Defer interacting with the parent to GenServer.handle_continue/2, or if you're using another behaviour which doesn't support such callback, send yourself a message to safely do the post-init interaction with the parent.

If parent is configured with the registry?: true option, some query functions, such as child_pid/2 will perform an ETS lookup instead of issuing a call, so the caveats above won't apply.

Link to this section Summary

Link to this section Functions

Link to this function

child_meta(parent, child_ref)

View Source

Specs

child_meta(GenServer.server(), Parent.child_ref()) ::
  {:ok, Parent.child_meta()} | :error

Client interface to Parent.child_meta/1.

If the parent is a registry, the result will be obtained from the ETS table.

Link to this function

child_pid(parent, child_id)

View Source

Specs

child_pid(GenServer.server(), Parent.child_id()) :: {:ok, pid()} | :error

Client interface to Parent.child_pid/1.

If the parent is a registry, the result will be obtained from the ETS table.

Specs

children(GenServer.server()) :: [Parent.child()]

Client interface to Parent.children/0.

If the parent is a registry, the result will be obtained from the ETS table.

Link to this function

restart_child(parent, child_ref)

View Source

Specs

restart_child(GenServer.server(), Parent.child_ref()) :: :ok | :error

Client interface to Parent.restart_child/1.

Link to this function

return_children(parent, stopped_children)

View Source

Specs

return_children(GenServer.server(), Parent.stopped_children()) :: :ok

Client interface to Parent.return_children/1.

Link to this function

shutdown_all(server, reason \\ :shutdown)

View Source

Specs

shutdown_all(GenServer.server(), any()) :: Parent.stopped_children()

Client interface to Parent.shutdown_all/1.

Link to this function

shutdown_child(parent, child_ref)

View Source

Specs

shutdown_child(GenServer.server(), Parent.child_ref()) ::
  {:ok, Parent.stopped_children()} | :error

Client interface to Parent.shutdown_child/1.

Link to this function

start_child(parent, child_spec, overrides \\ [])

View Source

Specs

Client interface to Parent.start_child/2.

Link to this function

update_child_meta(parent, child_ref, updater)

View Source

Specs

update_child_meta(
  GenServer.server(),
  Parent.child_id(),
  (Parent.child_meta() -> Parent.child_meta())
) :: :ok | :error

Client interface to Parent.update_child_meta/2.