Bedrock.Service.Worker (bedrock v0.5.3)

View Source

A worker is a GenServer that is started and stopped by a service director. It is expected to provide a set of facts about itself when requested along with other services (as befits the type of worker.)

Summary

Types

fact_name()

@type fact_name() :: :supported_info | :kind | :id | :health | :otp_name | :pid

fact_value()

@type fact_value() ::
  [fact_name()]
  | :log
  | :materializer
  | Bedrock.service_id()
  | health()
  | otp_name()
  | pid()

health()

@type health() :: {:ok, pid()} | :stopped | {:error, :timeout | :unavailable}

id()

@type id() :: Bedrock.service_id()

otp_name()

@type otp_name() :: atom()

ref()

@type ref() :: pid() | atom() | {atom(), node()}

timeout_in_ms()

@type timeout_in_ms() :: Bedrock.timeout_in_ms()

Functions

info(worker, fact_names, opts \\ [])

@spec info(
  worker_ref :: ref(),
  requested_facts :: [fact_name() | atom()],
  opts :: [{:timeout_in_ms, timeout_in_ms()}]
) ::
  {:ok, facts :: %{required(fact_name()) => fact_value()}}
  | {:error, :unavailable}

lock_for_recovery(worker, epoch, opts \\ [])

@spec lock_for_recovery(
  worker_ref :: ref(),
  recovery_epoch :: Bedrock.epoch(),
  opts :: [{:timeout_in_ms, timeout_in_ms()}]
) ::
  {:ok, worker_pid :: pid(),
   recovery_info :: [kind: :log | :materializer, version: Bedrock.version()]}
  | {:error, :newer_epoch_exists}
  | {:error, :timeout}

random_id()

@spec random_id() :: binary()