API Reference StatifierRouter v#0.2.0

Copy Markdown View Source

Modules

Routes external events to durable statifier executions, creating them when absent.

The address table's own two functions: reap/2, which removes address rows whose execution finished longer ago than their horizon (ADR-0002, sections 5 and 6), and by_execution/2, which reads the row naming one execution.

A binding: the declaration that routes an event from a source to one execution of one document, as ADR-0001 fixes it.

The Broadway front: a pipeline that hands every message its producer emits to StatifierRouter.route/3.

The router's resolved configuration: the host's repo, where this package's tables live in it, the bindings events are routed by, the module each delivery is handed to, and what that module needs to reach statifier_persistence.

Dedupe on (binding_id, message_id), with a row expiry (ADR-0003, section 6).

The delivery module StatifierRouter.Config names by default: one binding's delivery of one event, as one transaction on the host's repo (ADR-0003, section 1).

Versioned migrations for this package's tables, in the shape statifier_persistence's StatifierPersistence.Ecto.Migrations uses: the host writes one ordinary migration that delegates here, and later package versions ship higher-numbered migration modules the same call picks up.

V01 of the package DDL: the three tables the decision records fix, each named by StatifierRouter.Config.table/2 under the host's table prefix and created in the host's Postgres schema when one is set.

V02 of the package DDL: the subscription table ADR-0007, section 6 fixes, named by StatifierRouter.Config.table/2 under the host's table prefix and created in the host's Postgres schema when one is set.

The address table's vote on a chart retirement: StatifierPersistence.PinSource implemented over the address rows.

The host's answer to which chart a new execution of a document starts on (ADR-0002, section 4).

A resolver over a fixed map of compiled charts, for tests and for a host whose charts are compiled at boot.

The behaviour a host implements for one named outbound destination (ADR-0005, decision 2). A chart names a route in a <send>'s target under a type the host registered, and StatifierRouter.SendHandler hands the built event to the module registered for that name.

The publish-time checks a host runs over a chart before it lets that chart reach a route (ADR-0005, decision 7).

The Ecto schemas over this package's four tables, one per table StatifierRouter.Migrations.V01 and StatifierRouter.Migrations.V02 create

A row of the address table: (scope, document, key) -> execution_id (ADR-0002, section 1). terminal_seen_at is empty until this package first sees the execution terminal (ADR-0002, section 5).

A row of the dedupe table: one (binding_id, message_id) pair and the time it stops counting, expires_at (ADR-0003, section 6). A row whose expires_at has passed counts as absent even before it is removed.

A row of the routing ledger: one recorded outcome of one routing attempt for one binding (ADR-0004, section 4). The ledger is append-only.

A row of the subscription table: one live source invocation, as (execution_id, binding_id, invoke_id), carrying the scope and key the subscription reads events under (ADR-0007, section 6). Both are resolved once, at subscribe time, from the execution's own address row.

The one module that serves both shapes a registered type's <send> reaches a host in (ADR-0005, decision 5). It implements Statifier.Send.Processor for a live Statifier.Session, and it offers handle_effect/3 for a process-less host to call from StatifierPersistence.Executor.execute/2. Both entry points compose the same key, resolve the same route name, and reach the same adapter, so there is no second implementation to keep in step.

The source invoke's two calls, as a host's invoke handler makes them: start/3 turns a %Statifier.Effect.Invoke{} into StatifierRouter.subscribe/3, and cancel/3 turns the %Statifier.Effect.CancelInvoke{} the engine emits on state exit into StatifierRouter.cancel/2 (ADR-0007, section 2). An invocation's lifetime is a subscription's, and the chart writes no cleanup for it.

The behaviour a host implements for the durable timer queue a delayed route send is recorded on (ADR-0005, decision 5).

The webhook front: a Plug-shaped helper that turns one already-verified webhook request into a routing attempt. This package verifies nothing. The host authenticates the request - typically a provider's signature over the raw body - and calls handle/3 only after that verification has passed. A request that reaches this module is one the host has already vouched for.