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

Copy Markdown View Source

Executes a %Runnable{} according to a %SchedulerPolicy{}, handling retries, timeouts, backoff, fallbacks, and failure modes.

The PolicyDriver is the bridge between the scheduler's declared execution policy and the actual invocation of a runnable's work function. It wraps Invokable.execute/2 with policy-driven retry loops, timeout enforcement, and fallback resolution.

Event Emission

When emit_events: true is passed in options, execute/3 returns {%Runnable{}, [event]} instead of just %Runnable{}. Events are:

  • %RunnableDispatched{} — emitted at each execution attempt
  • %RunnableCompleted{} — emitted on successful completion
  • %RunnableFailed{} — emitted on permanent failure (retries exhausted)

Summary

Functions

Execute a runnable according to the given scheduler policy.

Execute a runnable according to the given scheduler policy with options.

Functions

execute(runnable, policy)

Execute a runnable according to the given scheduler policy.

execute(runnable, policy, opts)

Execute a runnable according to the given scheduler policy with options.

Options

  • :deadline_at - monotonic time deadline (used by Phase 3, plumbed now)
  • :emit_events - when true, returns {%Runnable{}, [event]} instead of %Runnable{}