Documentation
¶
Index ¶
Constants ¶
View Source
const MaxConsecutiveFailures = 10
MaxConsecutiveFailures is the threshold at which a webhook is auto-disabled.
Variables ¶
View Source
var ValidEventTypes = map[string]bool{ "*": true, event.ContainerStateChanged: true, event.EndpointStatusChanged: true, event.HeartbeatStatusChanged: true, event.CertificateStatusChanged: true, event.AlertFired: true, event.AlertResolved: true, }
ValidEventTypes is the set of all valid event type values for webhook subscriptions.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher subscribes to SSE events and fans out to webhook subscriptions using the existing alert.Notifier worker pool.
func NewDispatcher ¶
func NewDispatcher(store WebhookSubscriptionStore, notifier *alert.Notifier, logger *slog.Logger) *Dispatcher
NewDispatcher creates a new webhook dispatcher.
func (*Dispatcher) HandleEvent ¶
func (d *Dispatcher) HandleEvent(ctx context.Context, eventType string, data interface{})
HandleEvent processes a single SSE event and dispatches to matching webhooks. Called from main.go when SSE events are broadcast.
type WebhookEvent ¶
type WebhookEvent struct {
Type string `json:"type"`
Timestamp string `json:"timestamp"`
Data interface{} `json:"data"`
}
WebhookEvent is the payload delivered to webhook URLs.
type WebhookSubscription ¶
type WebhookSubscription struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Secret string `json:"secret,omitempty"`
EventTypes []string `json:"event_types"`
IsActive bool `json:"is_active"`
LastDeliveryStatus *string `json:"last_delivery_status"`
LastDeliveryAt *time.Time `json:"last_delivery_at"`
FailureCount int `json:"failure_count"`
CreatedAt time.Time `json:"created_at"`
}
WebhookSubscription represents a registered webhook URL.
type WebhookSubscriptionStore ¶
type WebhookSubscriptionStore interface {
List(ctx context.Context) ([]*WebhookSubscription, error)
GetByID(ctx context.Context, id string) (*WebhookSubscription, error)
Create(ctx context.Context, sub *WebhookSubscription) error
Delete(ctx context.Context, id string) error
UpdateDeliveryStatus(ctx context.Context, id string, status string, failureCount int) error
ListActive(ctx context.Context) ([]*WebhookSubscription, error)
}
WebhookSubscriptionStore defines the persistence interface for webhook subscriptions.
Click to show internal directories.
Click to hide internal directories.