Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("webhook not found")
ErrNotFound is returned when a webhook config does not exist.
Functions ¶
func FormatGeneric ¶
FormatGeneric wraps the incident in a simple envelope and marshals it to JSON.
func FormatPagerDuty ¶
FormatPagerDuty formats an incident event as a PagerDuty Events API v2 payload.
Types ¶
type Config ¶
type Config struct {
ID string `json:"id"`
URL string `json:"url"`
Type string `json:"type"` // "slack", "pagerduty", "generic"
Events []string `json:"events"` // "incident.created", "incident.resolved"
Headers map[string]string `json:"headers,omitempty"`
Active bool `json:"active"`
}
Config holds the configuration for a single outbound webhook.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher fires outbound HTTP webhooks for incident events.
func NewDispatcher ¶
func NewDispatcher(store Store) *Dispatcher
NewDispatcher creates a Dispatcher backed by the given store. A default HTTP client with a 10-second timeout is used.
func (*Dispatcher) Fire ¶
Fire sends the payload to all active webhooks registered for the given event. It queries the store for matching configs, formats the payload per webhook type, and POSTs to each URL. Errors are logged but do not fail the caller (best-effort delivery).
func (*Dispatcher) FireToConfig ¶
FireToConfig sends a payload directly to a single webhook config, bypassing the store lookup. Useful for test deliveries.
func (*Dispatcher) Store ¶
func (d *Dispatcher) Store() Store
Store returns the underlying webhook store.
type Store ¶
type Store interface {
Save(ctx context.Context, cfg *Config) error
Get(ctx context.Context, id string) (*Config, error)
List(ctx context.Context) ([]Config, error)
Delete(ctx context.Context, id string) error
ListByEvent(ctx context.Context, event string) ([]Config, error)
}
Store persists and retrieves webhook configs.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dynamostore implements webhook.Store backed by DynamoDB via the generic dynamostore package.
|
Package dynamostore implements webhook.Store backed by DynamoDB via the generic dynamostore package. |