Documentation
¶
Index ¶
- func Register(name string, factory Factory)
- func ResolveTemplate(tmplStr string, n Notification) string
- type ChannelMetrics
- type Config
- type DiscordBotNotifier
- type DiscordWebhookNotifier
- type Dispatcher
- type Factory
- type Metrics
- type MultiNotifier
- type NoopNotifier
- type Notification
- type Notifier
- type RetryConfig
- type SlackNotifier
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveTemplate ¶
func ResolveTemplate(tmplStr string, n Notification) string
ResolveTemplate renders a Go template string with notification data. Provides {{.PayloadField "key.path"}} for accessing raw webhook JSON.
Types ¶
type ChannelMetrics ¶
ChannelMetrics holds counters for a single notifier channel.
type Config ¶
type Config struct {
Enabled []string `yaml:"enabled"`
Settings map[string]map[string]interface{} `yaml:"settings"`
}
Config holds the configuration for all supported notifiers.
type DiscordBotNotifier ¶
type DiscordBotNotifier struct {
GuildID string
CategoryID string
ChannelID string
NotifyChannelID string // dedicated channel ID to route all notifications to
// contains filtered or unexported fields
}
DiscordBotNotifier sends notifications using a native Discord Bot. The session is created once and reused. Channel IDs are cached per repo slug.
func (*DiscordBotNotifier) GetMetrics ¶
func (n *DiscordBotNotifier) GetMetrics() *Metrics
func (*DiscordBotNotifier) Name ¶
func (n *DiscordBotNotifier) Name() string
func (*DiscordBotNotifier) Notify ¶
func (n *DiscordBotNotifier) Notify(ctx context.Context, notification Notification) error
type DiscordWebhookNotifier ¶
type DiscordWebhookNotifier struct {
WebhookURL string
}
DiscordWebhookNotifier sends notifications to a Discord webhook.
func (*DiscordWebhookNotifier) GetMetrics ¶
func (n *DiscordWebhookNotifier) GetMetrics() *Metrics
func (*DiscordWebhookNotifier) Name ¶
func (n *DiscordWebhookNotifier) Name() string
func (*DiscordWebhookNotifier) Notify ¶
func (n *DiscordWebhookNotifier) Notify(ctx context.Context, notification Notification) error
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher handles asynchronous notification delivery via a buffered channel.
func NewDispatcher ¶
func NewDispatcher(n Notifier, bufSize int) *Dispatcher
NewDispatcher creates a Dispatcher with the given buffer size. It starts a background goroutine that drains the channel.
func (*Dispatcher) Close ¶
func (d *Dispatcher) Close()
Close signals the dispatcher to stop after draining remaining items.
func (*Dispatcher) Send ¶
func (d *Dispatcher) Send(ctx context.Context, n Notification)
Send queues a notification for async delivery. Non-blocking if buffer has room; drops the notification with a warning if the buffer is full.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics tracks notification send/fail/retry counts per notifier.
func (*Metrics) LogSummary ¶
func (m *Metrics) LogSummary()
LogSummary writes a summary of all channel metrics at info level.
func (*Metrics) RecordFailed ¶
RecordFailed increments the failed counter for the named notifier.
func (*Metrics) RecordRetried ¶
RecordRetried increments the retried counter for the named notifier.
func (*Metrics) RecordSent ¶
RecordSent increments the sent counter for the named notifier.
type MultiNotifier ¶
type MultiNotifier struct {
// contains filtered or unexported fields
}
MultiNotifier bundles multiple notifiers together with retry and metrics.
func (*MultiNotifier) GetMetrics ¶
func (m *MultiNotifier) GetMetrics() *Metrics
func (*MultiNotifier) Name ¶
func (m *MultiNotifier) Name() string
func (*MultiNotifier) Notify ¶
func (m *MultiNotifier) Notify(ctx context.Context, n Notification) error
type NoopNotifier ¶
type NoopNotifier struct {
// contains filtered or unexported fields
}
NoopNotifier does nothing.
func (*NoopNotifier) GetMetrics ¶
func (n *NoopNotifier) GetMetrics() *Metrics
func (*NoopNotifier) Name ¶
func (n *NoopNotifier) Name() string
func (*NoopNotifier) Notify ¶
func (n *NoopNotifier) Notify(ctx context.Context, notification Notification) error
type Notification ¶
type Notification struct {
Repo string
Event string
Action string
HookName string
Message string
Stdout string
Sender string
DeliveryID string
State string // success, failure, pending
RawPayload json.RawMessage // full GitHub webhook payload for template access
}
Notification represents a rich notification message.
type Notifier ¶
type Notifier interface {
Notify(ctx context.Context, n Notification) error
Ping(ctx context.Context) error
Name() string
// Metrics returns the metrics tracker for this notifier tree.
GetMetrics() *Metrics
}
Notifier is the interface for sending notifications.
func NewNotifier ¶
NewNotifier creates a MultiNotifier based on the enabled list and settings.
type RetryConfig ¶
RetryConfig controls retry behavior for notifications.
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns sensible retry defaults.
type SlackNotifier ¶
type SlackNotifier struct {
WebhookURL string
}
SlackNotifier sends notifications to a Slack webhook using Block Kit.
func (*SlackNotifier) GetMetrics ¶
func (n *SlackNotifier) GetMetrics() *Metrics
func (*SlackNotifier) Name ¶
func (n *SlackNotifier) Name() string
func (*SlackNotifier) Notify ¶
func (n *SlackNotifier) Notify(ctx context.Context, notification Notification) error