webhooks

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher manages webhooks and dispatches events to matching URLs.

func New

func New(db *sql.DB, bus *events.Bus, logger *slog.Logger) *Dispatcher

New creates a new webhook Dispatcher.

func (*Dispatcher) Delete

func (d *Dispatcher) Delete(ctx context.Context, id string) error

Delete removes a webhook by ID.

func (*Dispatcher) Get

func (d *Dispatcher) Get(ctx context.Context, id string) (*Webhook, error)

Get retrieves a webhook by ID.

func (*Dispatcher) List

func (d *Dispatcher) List(ctx context.Context) ([]Webhook, error)

List returns all webhooks.

func (*Dispatcher) Register

func (d *Dispatcher) Register(ctx context.Context, id, url string, patterns []string, secret string) (*Webhook, error)

Register adds a new webhook. Returns the created webhook.

func (*Dispatcher) Start

func (d *Dispatcher) Start()

Start subscribes to all events and dispatches to matching webhooks.

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

Stop shuts down the dispatcher.

func (*Dispatcher) TestFire

func (d *Dispatcher) TestFire(ctx context.Context, id string) error

TestFire sends a test event payload to a specific webhook.

type Webhook

type Webhook struct {
	ID        string    `json:"id"`
	URL       string    `json:"url"`
	Patterns  []string  `json:"patterns"`
	Secret    string    `json:"secret,omitempty"`
	Active    bool      `json:"active"`
	CreatedAt time.Time `json:"created_at"`
	LastFired time.Time `json:"last_fired,omitempty"`
	FailCount int       `json:"fail_count"`
}

Webhook represents a registered webhook.

Jump to

Keyboard shortcuts

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