Module notifier_dispatch

Turns a parsed notifier_event into per-device deliveries.

Description

Turns a parsed notifier_event into per-device deliveries.

  1. Resolve targets: the event's explicit tokens plus, when the token store is enabled, every token registered to its user_ids (restricted to the event's providers, minus exclude_device_ids). Duplicates are dropped.
  2. Deliver each target through its provider (notifier_fcm / notifier_apns) — either asynchronously through the worker pools (submit/1) or in parallel in the caller (submit_sync/1).
  3. Book-keep the outcome in the token store: stamp last_success on success, delete the token when the provider says it is dead (FCM UNREGISTERED, APNs 410, ...).

Data Types

outcome()

outcome() = ok | {dead, Status::atom(), Detail::term()} | {failed, Status::atom(), Detail::term()}

Function Index

deliver/2Deliver one event to one device and record the outcome.
resolve_targets/1The explicit tokens of an event plus the stored tokens of its users.
status_of/1The status atom of an outcome, as reported by the HTTP API.
submit/1Resolve targets and enqueue one asynchronous delivery per target.
submit_sync/1Resolve targets and deliver to all of them in parallel, waiting for every per-device outcome (bounded by a 30 s overall timeout).

Function Details

deliver/2

deliver(Event::notifier_event:event(), Target::notifier_event:target()) -> outcome()

Deliver one event to one device and record the outcome. Never raises: a crash inside a provider becomes {failed, internal_error, _}.

resolve_targets/1

resolve_targets(Event::notifier_event:event()) -> {ok, [notifier_event:target(), ...]} | {error, no_targets | token_store_disabled}

The explicit tokens of an event plus the stored tokens of its users.

status_of/1

status_of(X1::outcome()) -> atom()

The status atom of an outcome, as reported by the HTTP API.

submit/1

submit(Event::notifier_event:event()) -> {ok, #{id := binary(), targets := non_neg_integer()}} | {error, no_targets | token_store_disabled}

Resolve targets and enqueue one asynchronous delivery per target.

submit_sync/1

submit_sync(Event::notifier_event:event()) -> {ok, #{id := binary(), results := [{notifier_event:target(), outcome()}]}} | {error, no_targets | token_store_disabled}

Resolve targets and deliver to all of them in parallel, waiting for every per-device outcome (bounded by a 30 s overall timeout).


Generated by EDoc