Continuum.Runtime.Journal behaviour (continuum v0.5.0)

Copy Markdown View Source

Behaviour for the event-history journal.

Two adapters ship with v0.1:

All append operations carry a lease_token (or nil for unleased in-memory / pre-dispatch execution). The Postgres adapter rejects writes whose token does not match the run row's fencing token; nil only writes to unleased rows.

Summary

Functions

Returns the configured default journal adapter.

Callbacks

append!(instance, run_id, event, lease_token)

@callback append!(
  instance :: Continuum.Runtime.Instance.t(),
  run_id :: binary(),
  event :: map(),
  lease_token :: integer() | nil
) :: :ok

complete!(instance, run_id, result, lease_token)

@callback complete!(
  instance :: Continuum.Runtime.Instance.t(),
  run_id :: binary(),
  result :: term(),
  lease_token :: integer() | nil
) :: :ok

fail!(instance, run_id, error, lease_token)

@callback fail!(
  instance :: Continuum.Runtime.Instance.t(),
  run_id :: binary(),
  error :: term(),
  lease_token :: integer() | nil
) :: :ok

get_run(instance, run_id)

@callback get_run(instance :: Continuum.Runtime.Instance.t(), run_id :: binary()) ::
  nil | map()

Look up the run record. Returns nil if no such run, or a map with at least :state, :result, :error keys (atoms / terms — already decoded).

load(instance, run_id)

@callback load(instance :: Continuum.Runtime.Instance.t(), run_id :: binary()) :: [map()]

load_with_snapshot(instance, run_id, lease_token)

@callback load_with_snapshot(
  instance :: Continuum.Runtime.Instance.t(),
  run_id :: binary(),
  lease_token :: integer() | nil
) :: {Continuum.Snapshot.t() | nil, [map()]}

start_run(instance, run_id, workflow, input)

@callback start_run(
  instance :: Continuum.Runtime.Instance.t(),
  run_id :: binary(),
  workflow :: module(),
  input :: term()
) :: :ok | {:error, term()}

suspend!(instance, run_id, lease_token)

@callback suspend!(
  instance :: Continuum.Runtime.Instance.t(),
  run_id :: binary(),
  lease_token :: integer() | nil
) :: :ok

take_snapshot!(instance, snapshot)

@callback take_snapshot!(
  instance :: Continuum.Runtime.Instance.t(),
  snapshot :: Continuum.Snapshot.t()
) :: :ok

Functions

default()

Returns the configured default journal adapter.