l8notify

Notifications

Multi-channel notification dispatch with throttling and escalation.

Overview

l8notify is a shared notification library, not a standalone service. Consumer projects import its Go packages and copy its l8ui components into their own web directories. It provides reusable packages for notification delivery, template rendering, throttling, and escalation scheduling.

l8notify never persists anything. The consumer project stores policies, rules, SMTP configs, webhook configs, and delivery logs in its own services. l8notify only provides the types and runtime behavior.

Channels

Email
SMTP with plain and TLS support
Webhook
HMAC-SHA256 signing with retry and exponential backoff
Slack
Incoming webhook integration
PagerDuty
Planned
Custom
Register your own Sender interface implementation

Go Packages

channel -- Dispatch Router

channel.Dispatch() routes a rendered message to the appropriate sender based on the target's channel type. Email sends via SMTP. Webhooks sign with HMAC-SHA256 and retry with exponential backoff (1s, 2s, 4s). Slack posts to an incoming webhook URL. Custom channels iterate all registered senders.

template -- Message Rendering

template.Render(tmpl, vars) replaces {{key}} placeholders with values from a map. Unknown placeholders are left as-is. RenderWithDefault replaces remaining placeholders with a default value.

throttle -- Rate Limiting

Thread-safe per-key cooldown and hourly rate limiter. Call IsThrottled() before dispatch, Record() after a successful send. Supports per-entity cooldown and per-policy hourly caps.

escalation -- Timed Step Chains

Schedules escalation chains for entities. Steps are sorted by order and fire after their configured delay via goroutine timers. Templates are rendered before calling the consumer's StepHandler. Active escalations can be cancelled when an entity is acknowledged or resolved.

Protobuf Types

All types are shared building blocks embedded in consumer-specific types. None are Prime Objects.

NotifyChannel
Enum: EMAIL, WEBHOOK, SLACK, PAGERDUTY, CUSTOM
DeliveryStatus
Enum: PENDING, SENT, FAILED, RETRYING
NotifyTarget
Delivery target (channel + endpoint + template)
SmtpConfig
SMTP connection settings
WebhookConfig
Webhook endpoint with HMAC secret, retry count, timeout
DeliveryResult
Result of a delivery attempt
EscalationStep
Single step in an escalation chain

l8ui Components

l8notify ships reusable UI components that consumers copy into their web directory:

SMTP Config
Form component for SMTP settings with test email support
Webhook Management
CRUD table and form for webhook endpoints
Delivery Log
Table viewer with detail popup for delivery results
Target Editor
Inline table definition for NotifyTarget arrays in policy forms
Shared Enums
Channel and delivery status enums with renderers

End-to-End Flow

  1. Entity event fires (POST/PUT/DELETE) in a ServiceCallback
  2. Consumer loads matching notification rules from its own service
  3. For each rule and target: build template vars, check throttle, render message, dispatch
  4. Record throttle on success, log delivery result
  5. For escalation policies: schedule on create/update, cancel on resolve/acknowledge

Dependencies

Go: google.golang.org/protobuf only. No l8orm, l8services, l8bus, or other Layer 8 infrastructure dependencies. l8ui components require the l8ui shared library already present in the consumer project.