Runic.Workflow.FactResolver (Runic v0.1.0-alpha.7)

Copy Markdown View Source

Runtime resolver that hydrates FactRef structs via a Store adapter.

Maintains a process-local cache to avoid repeated store round-trips. The cache lives in the Worker process memory and is cleared on Worker stop.

Summary

Functions

Creates a new FactResolver backed by the given store tuple.

Batch-loads a list of fact hashes into the resolver's cache.

Resolves a Fact or FactRef to a full Fact with its value.

Like resolve/2 but raises on error.

Types

t()

@type t() :: %Runic.Workflow.FactResolver{
  cache: %{optional(term()) => term()},
  store: {module(), term()}
}

Functions

new(store)

@spec new({module(), term()}) :: t()

Creates a new FactResolver backed by the given store tuple.

preload(resolver, fact_hashes)

@spec preload(t(), [term()]) :: t()

Batch-loads a list of fact hashes into the resolver's cache.

Hashes already present in the cache are skipped. Returns an updated resolver with the newly loaded values in its cache.

resolve(fact, resolver)

@spec resolve(Runic.Workflow.Fact.t() | Runic.Workflow.FactRef.t(), t()) ::
  {:ok, Runic.Workflow.Fact.t()} | {:error, term()}

Resolves a Fact or FactRef to a full Fact with its value.

  • Full Fact structs with a value are returned as-is (passthrough).
  • FactRef structs are resolved by checking the cache first, then falling back to the store's load_fact/2.

Returns {:ok, %Fact{}} or {:error, reason}.

resolve!(fact_or_ref, resolver)

Like resolve/2 but raises on error.