SmolBox.Store.RecordOps (SmolBox v0.1.0)

Copy Markdown View Source

Pure checks shared by store adapters. These functions provide no atomicity; adapters must hold the relevant record and worker transaction locks throughout.

Summary

Functions

cancel(record, now)

@spec cancel(SmolBox.Execution.t(), non_neg_integer()) ::
  {:ok, SmolBox.Execution.t()} | {:error, SmolBox.Error.t()}

claim(record, worker_lease, owner, now, ttl)

cursor(record)

due?(record, now)

empty_usage()

@spec empty_usage() :: SmolBox.Store.resources()

guard(record, arg2, worker_lease, now)

@spec guard(
  SmolBox.Execution.t(),
  SmolBox.Store.guard(),
  SmolBox.Store.lease() | nil,
  non_neg_integer()
) :: :ok | {:error, SmolBox.Error.t()}

initial(record)

@spec initial(SmolBox.Execution.t()) :: :ok | {:error, SmolBox.Error.t()}

lease(previous, owner, now, ttl)

@spec lease(SmolBox.Store.lease() | nil, String.t(), non_neg_integer(), pos_integer()) ::
  {:ok, SmolBox.Store.lease()} | {:error, SmolBox.Error.t()}

needs_work?(record)

@spec needs_work?(SmolBox.Execution.t()) :: boolean()

release(record, now)

@spec release(SmolBox.Execution.t(), non_neg_integer()) ::
  {:ok, SmolBox.Execution.t()} | {:error, SmolBox.Error.t()}

reservation(record, worker, machine, worker_lease, capacity, used, now)

resources(record)