Skip to content

xtr_notifier.bundle

The xtr-dependency-injection bundle for xtr-notifier.

AdminRecipientConfig dataclass

AdminRecipientConfig(email: str, phone: str = '')

An administrator the application's own failures are reported to.

Attributes:

  • email (str) –

    Where to write to them; required, so every administrator stays reachable once an email channel exists.

  • phone (str) –

    Their phone number, international form with no spaces, for the SMS channel; "" when they have none.

NotifierBundle

Bases: Bundle[NotifierConfig]

Wires the notifier, its channels, its senders and their transports to the container.

build

build(builder: ContainerBuilder) -> None

Have every transport factory the application registers serve both kinds.

load_extension

load_extension(config: NotifierConfig, services: ServiceConfigurator, builder: ContainerBuilder) -> None

Register the notifier, and the senders and channels of each configured kind.

Raises:

  • LogicError –

    When failed messages are to be reported without the messenger or the event dispatcher bundle active.

process

process(builder: ContainerBuilder) -> None

Hand the transport builders their tagged factories, and the notifier its channels.

A factory tagged for one kind is aliased for that kind alone; one only autoconfiguration tagged serves both. A channel tagged :data:CHANNEL_TAG joins the notifier under its channel name.

NotifierConfig dataclass

NotifierConfig(chatter_transports: Mapping[str, str] = _no_transports(), texter_transports: Mapping[str, str] = _no_transports(), channel_policy: Mapping[str, Sequence[str]] = _no_policy(), admin_recipients: Sequence[AdminRecipientConfig] = (), notification_on_failed_messages: bool = False, http_client: str | None = None, include_traceback: bool = False)

Values the bundle builds the notifier, its channels and its senders from.

Buildable with no arguments: the zero-config notifier has no channel, so it builds, boots and refuses to send until transports are configured.

Attributes:

  • chatter_transports (Mapping[str, str]) –

    The chat transports, by name, each a DSN — or several joined by || (failover) or && (round robin). Configuring any brings the chat channel and the chatter. Pass a DSN through env("..."): it carries credentials.

  • texter_transports (Mapping[str, str]) –

    The SMS and push transports, the same way. Configuring any brings the sms and push channels and the texter.

  • channel_policy (Mapping[str, Sequence[str]]) –

    The channels each importance goes to, for a notification naming none, keyed by the importance's value ("urgent").

  • admin_recipients (Sequence[AdminRecipientConfig]) –

    The administrators the application's own failures are reported to.

  • notification_on_failed_messages (bool) –

    Whether a message the bus gave up on is reported to the administrators. Needs the messenger and event dispatcher bundles.

  • http_client (str | None) –

    The qualifier of the HTTP client providers are reached through — a scoped client of the HTTP client configuration; None means the default one.

  • include_traceback (bool) –

    Whether a failure reported to the administrators carries the error's traceback. Off by default: a traceback may hold the failed message's own data.

The transport DSNs are left out of the configuration's repr: each carries its provider's credentials.