Documentation
¶
Overview ¶
Package webhook delivers events to registered HTTP endpoints.
Matching events are written to a durable queue (store.webhook_deliveries) before any network I/O, so deliveries survive restarts. Workers POST each event with an HMAC signature and retry failures with backoff.
Index ¶
Constants ¶
const ( HeaderSignature = "X-Imsgd-Signature" HeaderEvent = "X-Imsgd-Event" HeaderEventID = "X-Imsgd-Event-Id" HeaderDelivery = "X-Imsgd-Delivery" )
Headers sent with each delivery.
Variables ¶
var MaxAttempts = len(retryDelays) + 1
MaxAttempts is the number of attempts before a delivery is marked failed.
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func New ¶
func New(o Options) *Dispatcher
func (*Dispatcher) Invalidate ¶
func (d *Dispatcher) Invalidate()
Invalidate reloads the webhook list on the next event (call after CRUD).
func (*Dispatcher) Run ¶
func (d *Dispatcher) Run(ctx context.Context)
Run consumes events and delivers them until ctx is done.
func (*Dispatcher) SendTest ¶
func (d *Dispatcher) SendTest(ctx context.Context, w *store.Webhook) TestResult
SendTest posts a webhook.test event to w immediately (not queued).
type Options ¶
type Options struct {
Store *store.Store
Bus *events.Bus
Version string
Client *http.Client // default: 10s timeout
Workers int // concurrent deliveries; default 4
Retention time.Duration
Now func() time.Time
// KeyExists reports whether an API key name is still configured;
// webhooks owned by revoked keys are not delivered. Nil allows all.
KeyExists func(name string) bool
}