webhook

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 15 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeSignature

func ComputeSignature(secret string, ts int64, eventID, event string, body []byte) string

Types

type DeliveryRepository

type DeliveryRepository interface {
	GetNextToProcess(ctx context.Context, limit int) ([]*database.WebhookDeliveryItem, error)
	GetRetryable(ctx context.Context, limit int) ([]*database.WebhookDeliveryItem, error)
	MarkDelivered(ctx context.Context, id int64, responseStatus int, responseHeaders map[string]string, responseBody string) error
	MarkFailed(ctx context.Context, id int64, err error, shouldRetry bool) error
	CleanupOld(ctx context.Context, olderThan time.Duration) (int64, error)
}

DeliveryRepository is the minimal interface used by the worker

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer abstracts http.Client for testing

type Worker

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

Worker sends webhook deliveries asynchronously

func NewWorker

func NewWorker(repo DeliveryRepository, httpClient HTTPDoer, cfg WorkerConfig, parentCtx context.Context, db *sql.DB, tenants tenant.Provider) *Worker

func (*Worker) Start

func (w *Worker) Start() error

func (*Worker) Stop

func (w *Worker) Stop() error

type WorkerConfig

type WorkerConfig struct {
	BatchSize       int
	PollInterval    time.Duration
	CleanupInterval time.Duration
	CleanupAge      time.Duration
	MaxConcurrent   int
	RequestTimeout  time.Duration
}

WorkerConfig controls batch, concurrency and timings

func DefaultWorkerConfig

func DefaultWorkerConfig() WorkerConfig

Jump to

Keyboard shortcuts

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