webhookdelivery

package
v1.5.0-main Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 11 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

Index

Constants

View Source
const (
	DefaultMaxAttempts  = 5
	DefaultDeadline     = 10 * time.Minute
	DefaultMaxBackoff   = 2 * time.Minute
	DefaultBackoffDelay = 2 * time.Second
	DefaultTimeout      = 30 * time.Second
)

Variables

This section is empty.

Functions

func ClassifyHTTPStatus

func ClassifyHTTPStatus(statusCode int) (retryable bool, message string)

ClassifyHTTPStatus determines whether an HTTP response status code is retryable and returns a human-readable description.

func ComputeBackoff

func ComputeBackoff(attempt int, baseDelay, maxBackoff time.Duration) time.Duration

ComputeBackoff calculates exponential backoff with a cap.

func Deliver

func Deliver(ctx context.Context, client *http.Client, d Delivery, log logrus.FieldLogger) error

Deliver POSTs JSON to Config.URL with retry, delivery headers, and optional bearer auth. It returns nil on 2xx success. Non-HTTPS URLs are rejected as non-retryable.

func IsNonRetryable

func IsNonRetryable(err error) bool

IsNonRetryable reports whether err (or any wrapped error) is non-retryable.

func NewClient

func NewClient() *http.Client

NewClient creates an HTTP client configured for webhook delivery: TLS verification enabled, redirects disabled.

func NonRetryable

func NonRetryable(err error) error

NonRetryable returns a NonRetryableError wrapping err.

func NonRetryablef

func NonRetryablef(format string, args ...any) error

NonRetryablef returns a NonRetryableError with a formatted message.

Types

type Config

type Config struct {
	URL          string
	Timeout      time.Duration
	MaxAttempts  int
	Deadline     time.Duration
	MaxBackoff   time.Duration
	BackoffDelay time.Duration
}

Config holds destination and retry settings for a webhook delivery. Zero / non-positive duration and attempt fields fall back to defaults.

func (Config) WithDefaults

func (c Config) WithDefaults() Config

WithDefaults returns a copy with zero / non-positive fields filled from package defaults.

type Delivery

type Delivery struct {
	Config      Config
	BearerToken string
	Payload     []byte
	DeliveryID  string
}

Delivery is a single outbound webhook POST.

type NonRetryableError

type NonRetryableError struct {
	Err error
}

NonRetryableError wraps an error that must not be retried by Deliver.

func (*NonRetryableError) Error

func (e *NonRetryableError) Error() string

func (*NonRetryableError) Unwrap

func (e *NonRetryableError) Unwrap() error

Jump to

Keyboard shortcuts

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