Hassock.Supervisor (hassock v0.3.0)

Copy Markdown View Source

Optional convenience supervisor that wires a Hassock.Connection, (optionally) a Hassock.Cache and (optionally) a Hassock.RegistryCache together under a one_for_all strategy — if any crashes, all 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)
  • :registries — when true, also start a Hassock.RegistryCache (default: false)
  • :controller — pid that should receive events from the topmost layer (the cache if present, else the connection) and from the registry cache. 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)
  • :registry_cache_name — register the registry cache under this name (default: Hassock.RegistryCache)

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)