Skip to main content

Notification orchestrator with pluggable providers (email, webhook, console) and template rendering.

Project description

bloque-notifications

Notification orchestrator with pluggable providers and template rendering.

Features

  • Template rendering - Jinja2 (optional) with str.format_map() fallback
  • Pluggable providers - WebhookProvider, ConsoleProvider, or any duck-typed provider
  • Multi-channel routing - Send one notification to multiple channels
  • Tenant-aware templates - Automatic tenant prefix via ulfblk-multitenant context
  • Async by design - All I/O operations are async

Installation

uv add bloque-notifications

# With Jinja2 template support
uv add bloque-notifications[templates]

Quick Start

from bloque_notifications import NotificationService, ConsoleProvider, Notification, Channel

service = NotificationService(
    providers={Channel.CONSOLE: ConsoleProvider()},
)

await service.start()

# Simple notification (no template)
result = await service.notify_simple(
    recipient="admin@example.com",
    subject="Deploy complete",
    body="Version 2.1.0 deployed successfully.",
    channels=[Channel.CONSOLE],
)

# Template-based notification
service.template_engine.register(
    "welcome",
    subject="Welcome, {name}!",
    body="Hello {name}, your account on {app} is ready.",
)

result = await service.notify(Notification(
    recipient="user@example.com",
    template_name="welcome",
    context={"name": "Alice", "app": "MyApp"},
    channels=[Channel.CONSOLE],
))

await service.stop()

Connecting ulfblk-channels as Email Provider

bloque-notifications does NOT depend on ulfblk-channels. You can connect any object that satisfies the NotificationProvider protocol via duck-typing:

from bloque_channels.email.client import EmailClient
from bloque_channels.models.settings import EmailSettings
from bloque_notifications import NotificationService, Channel
from bloque_notifications.protocol import NotificationProvider

class EmailAdapter:
    """Adapt EmailClient to NotificationProvider protocol."""

    def __init__(self, client: EmailClient) -> None:
        self._client = client

    async def send(self, recipient, subject, body, *, metadata=None):
        from bloque_channels.models.message import OutboundMessage
        msg = OutboundMessage(to=recipient, subject=subject, body=body)
        return await self._client.send_message(msg)

    async def health_check(self) -> bool:
        return await self._client.health_check()

# Usage
email = EmailClient(EmailSettings(host="smtp.example.com"))
service = NotificationService(
    providers={Channel.EMAIL: EmailAdapter(email)},
)

Providers

Provider Channel Description
ConsoleProvider CONSOLE Logs notifications via ulfblk-core logger
WebhookProvider WEBHOOK POSTs JSON payload to recipient URL

API

See source code docstrings for full API documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ulfblk_notifications-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ulfblk_notifications-0.1.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file ulfblk_notifications-0.1.0.tar.gz.

File metadata

  • Download URL: ulfblk_notifications-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ulfblk_notifications-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c17ae6b65401c1bfaf450a053a51038fef6045640c1535e080c51f55beb1a0af
MD5 66f193de39a1831ae98fbaa36855db37
BLAKE2b-256 09e48e8e61bf3f0c82e469f3ab9ef33d3d71c735385f666d09f5dbab6727697c

See more details on using hashes here.

File details

Details for the file ulfblk_notifications-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ulfblk_notifications-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ulfblk_notifications-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95a5599225ee1ed9364636c7921635472032c641f5f7610b4cf19aa5a03dc41b
MD5 b5848cfa801e3721fc37c9ee64453e81
BLAKE2b-256 2d9c8646d640c97f100eef20570999f5a63a314f3dc547de2e738a2d75aba65e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page