Botica.Runner.CheckRunner (Botica v2.2.0)

Copy Markdown View Source

Runs a single health check in an isolated process with timeout and monitoring.

This module handles the low-level execution of a check function inside a monitored child process. It is used by Botica.Runner.Executor for both parallel and sequential execution modes.

Summary

Functions

Resolves a raw check result into a structured result map.

Runs a single check in an unlinked, monitored process with timeout.

Converts any term to an Exception struct for Result.from_exception.

Functions

resolve_result(check, other, timeout)

@spec resolve_result(Botica.Types.check_def(), term(), non_neg_integer()) ::
  Botica.Types.result()

Resolves a raw check result into a structured result map.

run_check(check, timeout \\ 5000)

@spec run_check(Botica.Types.check_def(), timeout :: non_neg_integer()) ::
  {:ok, Botica.Types.result()} | {:error, :timeout} | {:error, :task_crashed}

Runs a single check in an unlinked, monitored process with timeout.

Two safety mechanisms at play:

  1. :link is NOT in the spawn_opt list. An exit/1 inside the check propagates only to the child, not to the caller.
  2. The result message is tagged with a unique tag_ref (make_ref/0) so that stale messages from a previous (timed-out) check cannot be matched by the next receive.

to_exception(term)

@spec to_exception(term()) :: Exception.t()

Converts any term to an Exception struct for Result.from_exception.