ExWapp.Session.Worker.Events (ExWapp v0.1.2)

Copy Markdown View Source

What the session tells the outside world: telemetry, lifecycle metadata and the QR notifications that carry an error.

These are the cross-cutting emissions every part of the session reaches for, so they live here rather than in any one concern. Emitting never fails the caller: a broken telemetry handler or subscriber must not take the session down with it.

Called from the session process, so self() in the lifecycle metadata is the session's own pid, exactly as when this lived inside the worker.

Summary

Functions

Emits a telemetry event, tagged with the session's current status.

The session snapshot carried by every lifecycle message to subscribers.

Notifies QR subscribers of a failure, counting it in telemetry.

Bumps one of the session's counters.

Functions

emit_telemetry(event, measurements, state, extra_metadata \\ %{})

@spec emit_telemetry(atom() | [atom()], map(), ExWapp.Session.Worker.t(), map()) ::
  :ok

Emits a telemetry event, tagged with the session's current status.

lifecycle_event_meta(state, extra \\ %{})

@spec lifecycle_event_meta(ExWapp.Session.Worker.t(), map() | keyword()) :: map()

The session snapshot carried by every lifecycle message to subscribers.

notify_qr(state, event)

@spec notify_qr(
  ExWapp.Session.Worker.t(),
  {:error, term()}
) :: :ok

Notifies QR subscribers of a failure, counting it in telemetry.

update_stats(state, key)

@spec update_stats(ExWapp.Session.Worker.t(), atom()) :: ExWapp.Session.Worker.t()

Bumps one of the session's counters.