Hassock.Supervisor (hassock v0.2.0)

Copy Markdown View Source

Optional convenience supervisor that wires a Hassock.Connection and (optionally) a Hassock.Cache together under a one_for_all strategy — if either crashes, both restart from a clean slate.

Equivalent to writing the pair into your own supervision tree by hand. Use this when you don't need finer-grained control.

Options

  • :config — %Hassock.Config{} (required)
  • :cache — when true, also start a Hassock.Cache (default: false)
  • :controller — pid that should receive events from the topmost layer (the cache if present, else the connection). Default: caller of start_link/1.
  • :name — register the supervisor under this name (optional)
  • :connection_name — register the connection under this name (default: Hassock.Connection)
  • :cache_name — register the cache under this name (default: Hassock.Cache)

Example

{:ok, _sup} = Hassock.Supervisor.start_link(
  config: %Hassock.Config{url: "...", token: "..."},
  cache: true,
  controller: self()
)
receive do
  {:hassock_cache, _cache, :ready} -> :ok
end

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)