webhooks

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0, MIT Imports: 19 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 webhooks delivers the outbox: every process claims due deliveries from the store, sends them the way WAHA does (headers, HMAC, retries) and records the outcome. Unlike WAHA, which fires and forgets, a delivery survives a restart.

Index

Constants

View Source
const (
	DefaultDelaySeconds = 2
	DefaultAttempts     = 15
)

WAHA's retry defaults.

Variables

This section is empty.

Functions

func Backoff

func Backoff(policy string, delay time.Duration, n int, retryAfter time.Duration) time.Duration

Backoff is the wait before retry number n (1-based), as axios-retry computes it for WAHA: constant, linear (n times the delay) or exponential (2^n times the delay plus up to 20% jitter), never less than Retry-After.

func Headers

func Headers(d store.Delivery, wh waha.WebhookConfig) map[string]string

Headers are the headers WAHA sends with a webhook body.

func Sign

func Sign(key string, body []byte) string

Sign is WAHA's signature: lowercase hex HMAC-SHA512 of the exact body.

Types

type Worker

type Worker struct {
	Store   store.Store
	Worker  string
	Timeout time.Duration
	Client  *http.Client
	Log     *slog.Logger
	Now     func() time.Time
	// Poll is how often an idle worker looks for due deliveries.
	Poll time.Duration
	// Concurrency bounds the deliveries in flight; PerURL bounds those to
	// one URL.
	Concurrency, PerURL int
}

Worker delivers webhooks until its context ends.

func (*Worker) Run

func (w *Worker) Run(ctx context.Context)

Run claims and delivers until ctx ends, then waits for the deliveries in flight. Deliveries run in a pool of Concurrency, refilled as each one ends, and at most PerURL of them go to one URL at a time: a URL that hangs ties up its own share, never the other sessions' webhooks.

Jump to

Keyboard shortcuts

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