Snakepit.Internal.AsyncFallback (Snakepit v0.13.0)

Copy Markdown View Source

Supervised task helpers with automatic fallback to bare monitors.

When TaskSupervisor is unavailable (not yet started or crashed), these helpers fall back to spawn_monitor instead of crashing the caller.

Summary

Types

fallback_mode()

@type fallback_mode() :: :monitored | :fire_and_forget

fallback_reason()

@type fallback_reason() :: {:rescue, term()} | {:exit, term()}

monitored_task()

@type monitored_task() :: {:ok, pid(), reference()}

Functions

start_child_with_fallback(task_supervisor, fun, opts \\ [])

@spec start_child_with_fallback(
  Supervisor.supervisor(),
  (-> term()),
  keyword()
) :: :ok

start_monitored(fun)

@spec start_monitored((-> term())) :: monitored_task()

start_monitored_fire_and_forget(fun)

@spec start_monitored_fire_and_forget((-> term())) :: {pid(), reference()}