webhook

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

IsPrivateIP reports whether ip falls within a private or reserved range.

Types

type Config

type Config struct {
	Timeout         time.Duration
	MaxRetries      int
	RetryDelay      time.Duration
	RetryWindow     time.Duration // max duration to keep retrying from first attempt; 0 = no window limit
	MaxRetryDelay   time.Duration // cap on individual retry delay; 0 = no cap
	Heartbeat       time.Duration
	BatchSize       int
	RetentionPeriod time.Duration // how long to keep delivered entries; 0 = never clean up
	BlockPrivateIPs bool          // enable SSRF protection; blocks webhooks to private/reserved IPs (recommended for SaaS deployments)
}

Config holds configuration for the webhook Dispatcher.

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher manages durable webhook delivery using an outbox table. Instead of an in-memory channel, webhooks are persisted to a database outbox and delivered by a background worker that wakes on signal or heartbeat.

func NewDispatcher

func NewDispatcher(outbox store.OutboxStore, audits store.AuditStore, cfg Config) *Dispatcher

func (*Dispatcher) Enqueue

func (d *Dispatcher) Enqueue(ctx context.Context, outbox store.OutboxStore, webhooks store.WebhookStore, req *model.Request, approvals []model.Approval) error

Enqueue builds outbox entries for a resolved request and writes them using the provided stores. The caller should pass tx-bound stores so that the outbox writes are atomic with the status update.

func (*Dispatcher) SetMetrics

func (d *Dispatcher) SetMetrics(m *metrics.Metrics)

SetMetrics sets the optional Prometheus metrics collector.

func (*Dispatcher) Signal

func (d *Dispatcher) Signal()

Signal wakes the delivery worker to process pending outbox entries. Non-blocking: if a signal is already pending, this is a no-op.

func (*Dispatcher) Start

func (d *Dispatcher) Start(ctx context.Context)

Start begins the background delivery worker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL