AshHooks.OutboundBinding (AshHooks v2.0.2)

Copy Markdown View Source

Builds the versioned, opaque identifiers stored in outbound delivery rows.

Migration code may use source/3, direct_source/2, and route/2 to backfill the same identifiers that dispatch and worker execution validate. Store returned identifiers as-is. They are versioned data descriptors, not serialized executable terms. Treat their byte format as opaque.

Summary

Functions

Returns the source identifier for a direct delivery driver configuration.

Returns the route identifier for a named two-argument enqueue callback.

Returns the route identifier for an enqueue callback.

Returns the source identifier for an outbound declaration and endpoint resource.

Functions

direct_source(deliveries, endpoints)

@spec direct_source(module(), module()) :: String.t()

Returns the source identifier for a direct delivery driver configuration.

named_route(module, function)

@spec named_route(module(), atom()) :: String.t()

Returns the route identifier for a named two-argument enqueue callback.

Use this directly when a migration already stores the callback module and function separately. It returns the same identifier as route/2 receives from {module, function} or an external function capture.

route(callback, opts)

@spec route(nil | {module(), atom()} | (term(), term() -> term()), keyword()) ::
  {:ok, String.t()} | {:error, :invalid_enqueue_key | :invalid_enqueuer}

Returns the route identifier for an enqueue callback.

Named {module, function} callbacks and external captures normalize to the same identifier. Anonymous callbacks require a stable, nonempty binary (up to 512 bytes) or atom :enqueue_key for automatic recovery; without it they receive an explicit unresolved marker. A nil callback receives the distinct unbound marker that reconciliation may bind once to a later named or keyed route. Invalid callback and key shapes return an error.

source(emitter, declaration, endpoint_resource)

@spec source(module(), atom(), module()) :: String.t()

Returns the source identifier for an outbound declaration and endpoint resource.