Continuum.Runtime.Context (continuum v0.5.0)

Copy Markdown View Source

Per-run effect context, kept in the workflow process's process dictionary.

The context holds the journal handle, the current cursor (how many events have been replayed so far), per-callsite command ordinals, the run id, and the lease token. It is established by Continuum.Runtime.Engine before invoking the user's run/1 and unset on suspend or completion.

Summary

Functions

Are we currently inside a workflow process?

Clear the context.

Read the current context, or nil if not in a workflow process.

Pop the next event from history if available; otherwise return :tail.

Set the current context for this process.

Types

t()

@type t() :: %Continuum.Runtime.Context{
  command_counts: map(),
  compensation_stack: [{term(), {module(), atom(), list()}}],
  cursor: non_neg_integer(),
  history: list(),
  history_count: non_neg_integer() | nil,
  history_index: :array.array() | nil,
  history_offset: non_neg_integer(),
  instance: Continuum.Runtime.Instance.t() | nil,
  journal: module(),
  lease_token: integer() | nil,
  run_id: binary(),
  snapshot_steps: map(),
  trace_context: binary() | nil,
  workflow_module: module()
}

Functions

active?()

Are we currently inside a workflow process?

clear()

Clear the context.

get()

Read the current context, or nil if not in a workflow process.

next_event()

Pop the next event from history if available; otherwise return :tail.

Advances the cursor on a successful pop.

put(ctx)

Set the current context for this process.