# StatifierRouter v0.3.0 - Table of Contents

> A Broadway front and a binding, addressing and delivery layer that routes external events to durable statifier executions, creating them when absent

## Pages

- [StatifierRouter](readme.md)
- [Changelog](changelog.md)

## Modules

- [StatifierRouter](StatifierRouter.md): Routes external events to durable statifier executions, creating them when
absent.
- [StatifierRouter.Addresses](StatifierRouter.Addresses.md): 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.
- [StatifierRouter.Binding](StatifierRouter.Binding.md): A binding: the declaration that routes an event from a source to one
execution of one document, as ADR-0001 fixes it.
- [StatifierRouter.Broadway](StatifierRouter.Broadway.md): The Broadway front: a pipeline that hands every message its producer
emits to `StatifierRouter.route/3`.
- [StatifierRouter.Config](StatifierRouter.Config.md): 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.
- [StatifierRouter.Contracts](StatifierRouter.Contracts.md): The receiver contract at publish: whether the event a sender or a
binding names is one the receiving document accepts (ADR-0008).
- [StatifierRouter.Dedupe](StatifierRouter.Dedupe.md): Dedupe on `(binding_id, message_id)`, with a row expiry (ADR-0003,
section 6).
- [StatifierRouter.Delivery](StatifierRouter.Delivery.md): 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).
- [StatifierRouter.Migrations](StatifierRouter.Migrations.md): 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.
- [StatifierRouter.Migrations.V01](StatifierRouter.Migrations.V01.md): 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.
- [StatifierRouter.Migrations.V02](StatifierRouter.Migrations.V02.md): 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.
- [StatifierRouter.PinSource](StatifierRouter.PinSource.md): The address table's vote on a chart retirement:
`StatifierPersistence.PinSource` implemented over the address rows.
- [StatifierRouter.Resolver](StatifierRouter.Resolver.md): The host's answer to which chart a new execution of a document starts on
(ADR-0002, section 4).
- [StatifierRouter.Resolver.Static](StatifierRouter.Resolver.Static.md): A resolver over a fixed map of compiled charts, for tests and for a host
whose charts are compiled at boot.
- [StatifierRouter.Route](StatifierRouter.Route.md): 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.
- [StatifierRouter.Routes](StatifierRouter.Routes.md): The publish-time checks a host runs over a chart before it lets that
chart reach a route (ADR-0005, decision 7).
- [StatifierRouter.Schema](StatifierRouter.Schema.md): The Ecto schemas over this package's four tables, one per table
`StatifierRouter.Migrations.V01` and `StatifierRouter.Migrations.V02`
create
- [StatifierRouter.Schema.Address](StatifierRouter.Schema.Address.md): 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).
- [StatifierRouter.Schema.Dedupe](StatifierRouter.Schema.Dedupe.md): 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.
- [StatifierRouter.Schema.Ledger](StatifierRouter.Schema.Ledger.md): 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.
- [StatifierRouter.Schema.Subscription](StatifierRouter.Schema.Subscription.md): 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.
- [StatifierRouter.SendHandler](StatifierRouter.SendHandler.md): 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.
- [StatifierRouter.SourceInvoke](StatifierRouter.SourceInvoke.md): 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.
- [StatifierRouter.TimerQueue](StatifierRouter.TimerQueue.md): The behaviour a host implements for the durable timer queue a delayed
route send is recorded on (ADR-0005, decision 5).
- [StatifierRouter.Webhook](StatifierRouter.Webhook.md): 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.

