API Reference hourglass v#0.1.0

Copy Markdown View Source

Modules

Hourglass — a standalone Elixir SDK for Temporal (https://temporal.io).

Activity-side use macro. Activities are plain Elixir modules — no determinism constraint. Each activity module implements execute(input) and is dispatched by the runner based on its module name (the activity_type). The runner calls execute/1 with the deserialized input.

Behaviour activities implement to be dispatched by Hourglass.ActivityRunner.

Per-dispatch context the runner threads through Hourglass.Activity.info/0.

Behaviour for classifying an activity failure into a Temporal retry verdict.

Permissive default classifier: every failure is :retryable. Hosts that need non-retryable verdicts for specific error shapes configure their own module via config :hourglass, :retry_classifier.

Raised by execute_activity!/2,3 when an activity fails (after retries).

Application-level shared DynamicSupervisor for ephemeral activity executor Tasks. Each child wraps Hourglass.ActivityRunner.run/3 (called via the 2-arg form, which fills in the default complete_fn arg pointing at BridgeHolder.complete_activity_task/2).

Runs a single activity task. Spawned by the Hourglass.ActivityExecutor.DynamicSupervisor as a Task; invokes <activity_module>.handle(name, args); classifies the outcome through Hourglass.Activity.RetryClassifier; wraps the result into an ActivityTaskCompletion proto; ships back via Hourglass.BridgeHolder.complete_activity_task/2.

OTP Application entry point for the Hourglass Temporal SDK.

Rustler NIF wrapper for the hourglass crate.

Tagged failure values returned from the bridge layer.

Application-level resource manager for per-task-queue Temporal-bridge worker handles. A single long-lived GenServer started under Hourglass.Application that owns every bridge handle in the VM and mediates every NIF call against them.

Client-side workflow operations. Wraps Hourglass.Bridge.client_* NIFs; translates %Bridge.Error{} to higher-level %Error{} reasons.

Behaviour describing the cluster-facing operations Hourglass code issues through Hourglass.Client.

Production Hourglass.Client.Backend implementation. Wraps the Bridge NIFs to round-trip real Temporal Server.

The typed-payload boundary for Hourglass workflow/activity I/O.

Higher-level error returned from Hourglass.* facade calls. Distinct from Hourglass.Bridge.Error (low-level wire error); facade functions translate Bridge.Error to this type.

Boot-time supervisor child that ensures the configured Temporal namespace exists. Returns :ignore from start_link/0 so no process is kept around after the check; the supervisor's child-startup ordering guarantees later children (notably Hourglass.Subsystem, which hosts Workers) don't start until this succeeds.

Returned from Hourglass.Replayer.replay_history/2 on workflow nondeterminism.

Replays a captured workflow history against the current workflow code, detecting nondeterminism (the workflow producing different commands than what the original execution produced).

One-per-application GenServer holding the CoreRuntime resource. Workers share the resource via handle/0. Constructing more than one CoreRuntime is wasteful (each spins up its own Tokio runtime).

use Hourglass.Schema defines a typed Hourglass payload.

:rest_for_one supervisor wrapping the five Temporal children whose lifetimes are tied to the bridge-handle registry

Canonical :telemetry events emitted by Hourglass. Attach your own handlers to project these into your application's audit/event model. See Hourglass.Telemetry.LoggerHandler for an opt-in default.

Opt-in default handler that logs every Hourglass.Telemetry event. Off by default; call attach/0 (e.g. from your application start) to enable.

Per-task-queue Worker — a GenServer that owns the bridge-handle registration for one task queue and runs a small inner Supervisor hosting the two poll loops driving Temporal Core.

Per-Worker Task that drives BridgeHolder.poll_activity_task/1 in a tight loop. Each {:ok, bytes} is decoded into a Coresdk.ActivityTask.ActivityTask and dispatched directly to Hourglass.ActivityExecutor.DynamicSupervisor.start_child/1 (the shared Application-level executor DynSup).

DynamicSupervisor of per-task-queue Hourglass.Worker GenServers.

Per-activation ephemeral evaluator. Spawned via Hourglass.WorkflowEvaluator.DynamicSupervisor (restart: :temporary) once per workflow activation.

Per-Worker Task that drives BridgeHolder.poll_workflow_activation/1 in a tight loop. On each {:ok, bytes} result it dispatches the activation directly to the shared Hourglass.WorkflowEvaluator.DynamicSupervisor, spawning a fresh ephemeral evaluator Task per activation. The evaluator runs once and exits :normal; Core handles redelivery on crashes.

Per-(task_queue, run_id) cache of Hourglass.Workflow.State between activations.

Maps a Temporal Core WorkflowActivation to the Elixir workflow module that should evaluate it.

Boot-time supervisor child that starts the default Elixir Temporal worker — the one that polls the "default" task queue.

Registry mapping task-queue names to their Worker GenServer PIDs.

Workflow-side API. use Hourglass.Workflow declares the module is a workflow.

Callback required by all workflow modules.

Process-dict-keyed mutable accumulator that the pure-function evaluator uses while re-executing a workflow body.

Pure recursive evaluator for Hourglass workflows. Per activation

Per-activation context the evaluator exposes via Hourglass.Workflow.info/0.

Identifier for an in-flight workflow execution.

Snapshot of a workflow execution's current state. Returned by Hourglass.status/2.

Mix Tasks

Regenerate committed protobuf modules from proto/.