Notification API

Piko's notification service sends messages to chat platforms, incident tools, and ad-hoc webhooks. Callers send notifications synchronously or queue them through a dispatcher that retries with backoff and routes undeliverable messages to a dead-letter queue. For task recipes see the notifications how-to. Source of truth: wdk/notification/facade.go.

Service

FunctionReturns
notification.NewService() ServiceConstructs a new service.
notification.GetDefaultService() (Service, error)Returns the bootstrap-configured service.

Builder

func NewNotificationBuilder(service Service) (*NotificationBuilder, error)
func NewNotificationBuilderFromDefault() (*NotificationBuilder, error)

Fluent methods: .Title(...), .Message(...), .Field(key, value), .Fields(map), .Image(url), .Priority(...), .Type(...), .Source(...), .Environment(...), .Service(...), .TraceID(...), .Provider(name), .ToProviders(names...), .ProviderOption(key, value), .ProviderOptions(map), .Do(ctx).

Types

TypePurpose
ServiceManages providers.
ProviderPortInterface a provider implements.
DispatcherPortInterface for async dispatchers.
SendParamsFull parameter struct.
NotificationContentCore content: title, body, attachments.
ProviderCapabilitiesDeclares feature support per provider.
DispatcherConfigBackoff, concurrency, DLQ.
DispatcherStatsLive dispatcher counters.
RetryConfigBackoff parameters.
DeadLetterEntryA message the dispatcher failed to deliver.

Constants

GroupValues
PriorityPriorityLow, PriorityNormal, PriorityHigh, PriorityCritical
TypeTypePlain, TypeRich, TypeTemplated
Provider nameProviderSlack, ProviderDiscord, ProviderPagerDuty, ProviderTeams, ProviderGoogleChat, ProviderNtfy, ProviderWebhook, ProviderStdout

Providers

The wdk/notification package exposes the service facade, dispatcher, builder, and ProviderPort interface. The provider implementations themselves live in the Piko-internal package internal/notification/notification_adapters/driver_providers and are not directly importable from user code. Instead, callers register their own ProviderPort implementations via WithNotificationProvider.

Piko auto-registers a built-in stdout provider as the default when callers configure no custom provider. Piko exports the provider name constant ProviderStdout (along with ProviderSlack, ProviderDiscord, ProviderPagerDuty, ProviderTeams, ProviderGoogleChat, ProviderNtfy, ProviderWebhook) for convenience when selecting a registered provider through the builder's .Provider(name) method or WithDefaultNotificationProvider.

To send to other destinations (Slack webhooks, PagerDuty events, internal HTTP endpoints, and so on), implement ProviderPort in your application and register it with the service. Keep the destination logic in your application code, and share it across services as needed.

Bootstrap options

OptionPurpose
piko.WithNotificationProvider(name, provider)Registers a provider.
piko.WithDefaultNotificationProvider(name)Marks the default.

See also