ExStorageService.Metadata.JobStore (ex_storage_service v0.6.3)

Copy Markdown View Source

Durable job persistence with atomic lease and fencing transitions.

A worker may mutate a running job only while it owns the current fencing token and an unexpired lease. Expired work can be reclaimed, which increments the fencing token and makes every stale worker transition fail.

Summary

Functions

claim(job_id, owner_node, now_ms, lease_ms, opts \\ [])

@spec claim(binary(), binary(), non_neg_integer(), pos_integer(), keyword()) ::
  {:ok, ExStorageService.Metadata.Models.Job.t()} | {:error, term()}

complete(job_id, owner_node, fencing_token, now_ms, opts \\ [])

@spec complete(binary(), binary(), non_neg_integer(), non_neg_integer(), keyword()) ::
  {:ok, ExStorageService.Metadata.Models.Job.t()} | {:error, term()}

fail(job_id, owner_node, fencing_token, reason, now_ms, opts \\ [])

@spec fail(
  binary(),
  binary(),
  non_neg_integer(),
  term(),
  non_neg_integer(),
  keyword()
) ::
  {:ok, ExStorageService.Metadata.Models.Job.t()} | {:error, term()}

get(job_id, opts \\ [])

@spec get(
  binary(),
  keyword()
) ::
  {:ok, ExStorageService.Metadata.Models.Job.t()}
  | {:error, :not_found | term()}

list_page(cursor \\ nil, limit \\ 100, opts \\ [])

@spec list_page(binary() | nil, pos_integer(), keyword()) ::
  {:ok,
   %{
     jobs: [ExStorageService.Metadata.Models.Job.t()],
     next_cursor: binary() | nil
   }}
  | {:error, term()}

renew(job_id, owner_node, fencing_token, now_ms, lease_ms, opts \\ [])