Helpers for SnakeBridge example projects.
Provides failure tracking to hard-fail on unexpected errors in demo scripts,
and telemetry-based dispatch monitoring to deterministically wait for pool
dispatch events instead of using Process.sleep.
Summary
Functions
Raises if any failures were recorded in the current process.
Raises if result is an {:error, reason} tuple.
Attaches a telemetry handler that forwards [:snakepit, :pool, :call, :dispatched]
events to the calling process as {:call_dispatched, metadata} messages.
Waits for a {:call_dispatched, metadata} message from an attached dispatch monitor.
Detaches a previously attached dispatch monitor by handler ID.
Returns the current per-process failure count.
Increments the per-process failure counter by one.
Resets the per-process failure counter to zero.
Functions
@spec assert_no_failures!() :: :ok
Raises if any failures were recorded in the current process.
@spec assert_script_ok(term()) :: :ok
Raises if result is an {:error, reason} tuple.
Attaches a telemetry handler that forwards [:snakepit, :pool, :call, :dispatched]
events to the calling process as {:call_dispatched, metadata} messages.
Returns the handler ID, which should be passed to detach_dispatch_monitor/1
when monitoring is no longer needed.
Waits for a {:call_dispatched, metadata} message from an attached dispatch monitor.
Options
:timeout- maximum wait time in milliseconds (default:2_000):command- if set, only matches dispatches for the given command
Returns the dispatch metadata map, or nil on timeout.
@spec detach_dispatch_monitor(String.t()) :: :ok | {:error, :not_found}
Detaches a previously attached dispatch monitor by handler ID.
@spec failure_count() :: non_neg_integer()
Returns the current per-process failure count.
@spec record_failure() :: :ok
Increments the per-process failure counter by one.
@spec reset_failures() :: :ok
Resets the per-process failure counter to zero.