ASM.Extensions.Routing.HealthTracker (ASM v0.9.2)

Copy Markdown View Source

Provider health state machine with temporary exclusion windows.

Summary

Types

Per-provider health status.

Unique provider candidate identifier used by the router.

t()

Types

health_status()

@type health_status() :: %{
  status: :healthy | :degraded | :unhealthy,
  failures: non_neg_integer(),
  last_error: term() | nil,
  excluded_until_ms: integer() | nil,
  excluded?: boolean()
}

Per-provider health status.

provider_id()

@type provider_id() :: term()

Unique provider candidate identifier used by the router.

t()

@type t() :: %ASM.Extensions.Routing.HealthTracker{
  by_provider: %{required(provider_id()) => tracker_state()},
  failure_cooldown_ms: pos_integer()
}

Functions

available_provider_ids(tracker, now_ms)

@spec available_provider_ids(t(), integer()) :: [provider_id()]

mark_failure(tracker, provider_id, reason, now_ms)

@spec mark_failure(t(), provider_id(), term(), integer()) ::
  {:ok, t()} | {:error, ASM.Error.t()}

mark_success(tracker, provider_id, now_ms)

@spec mark_success(t(), provider_id(), integer()) ::
  {:ok, t()} | {:error, ASM.Error.t()}

new(provider_ids, opts \\ [])

@spec new(
  [provider_id()],
  keyword()
) :: {:ok, t()} | {:error, ASM.Error.t()}

refresh(tracker, now_ms)

@spec refresh(t(), integer()) :: t()

snapshot(tracker, now_ms)

@spec snapshot(t(), integer()) :: %{required(provider_id()) => health_status()}

status(tracker, provider_id, now_ms)

@spec status(t(), provider_id(), integer()) ::
  {:ok, health_status()} | {:error, ASM.Error.t()}