webhook

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webhook provides the webhook delivery system for Kora extensions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRetrySchedule

func DefaultRetrySchedule() []time.Duration

DefaultRetrySchedule returns the standard 8-attempt retry schedule.

func GenerateSecret

func GenerateSecret() (string, error)

GenerateSecret creates a new cryptographically random webhook signing secret.

func Sign

func Sign(secret string, body []byte, timestamp int64) string

Sign computes an HMAC-SHA256 signature for a webhook payload. Format: X-Kora-Signature: t={unix_timestamp},v1={hex_signature}

func Verify

func Verify(body []byte, header string, secrets []string, tolerance time.Duration) error

Verify checks a webhook signature against one or more secrets. Supports multi-secret verification for zero-downtime rotation. tolerance is the maximum age of the timestamp (default: 5 minutes).

Types

type Extension

type Extension struct {
	Name                string
	EndpointURL         string
	Secret              string
	TimeoutSec          int
	ConsecutiveFailures int
}

Extension represents a registered webhook extension.

type Subscription

type Subscription struct {
	Event  string             `json:"event"`
	Filter SubscriptionFilter `json:"filter,omitempty"`
}

Subscription defines an event filter for an extension.

type SubscriptionFilter

type SubscriptionFilter struct {
	DocType      string   `json:"doctype,omitempty"`
	ToState      []string `json:"to_state,omitempty"`
	FieldChanged []string `json:"field_changed,omitempty"`
}

SubscriptionFilter narrows which events are delivered.

type Worker

type Worker struct {
	DB   *sql.DB
	Bus  *analytics.MultiBus
	Site string

	// RetrySchedule defines the backoff for failed deliveries.
	RetrySchedule []time.Duration
	// MaxConsecutiveFailures before auto-disabling an extension.
	MaxConsecutiveFailures int
	// contains filtered or unexported fields
}

Worker delivers webhooks to extension endpoints. It subscribes to the analytics event bus and dispatches matching events.

func NewWorker

func NewWorker(db *sql.DB, bus *analytics.MultiBus, site string) *Worker

NewWorker creates a webhook delivery worker.

func (*Worker) RetryDeadLetters

func (w *Worker) RetryDeadLetters() error

RetryDeadLetters reattempts delivery of dead-lettered webhooks. Called by the scheduler's JobWebhook handler.

func (*Worker) Start

func (w *Worker) Start()

Start begins listening for events and delivering webhooks.

func (*Worker) Stop

func (w *Worker) Stop()

Stop shuts down the worker and removes its listener from the event bus.

Jump to

Keyboard shortcuts

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