Documentation
¶
Index ¶
- Constants
- func ClassifyHTTPStatus(statusCode int) (retryable bool, message string)
- func ComputeBackoff(attempt int, baseDelay, maxBackoff time.Duration) time.Duration
- func Deliver(ctx context.Context, client *http.Client, d Delivery, log logrus.FieldLogger) error
- func IsNonRetryable(err error) bool
- func NewClient() *http.Client
- func NonRetryable(err error) error
- func NonRetryablef(format string, args ...any) error
- type Config
- type Delivery
- type NonRetryableError
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ClassifyHTTPStatus ¶
ClassifyHTTPStatus determines whether an HTTP response status code is retryable and returns a human-readable description.
func ComputeBackoff ¶
ComputeBackoff calculates exponential backoff with a cap.
func Deliver ¶
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 ¶
IsNonRetryable reports whether err (or any wrapped error) is non-retryable.
func NewClient ¶
NewClient creates an HTTP client configured for webhook delivery: TLS verification enabled, redirects disabled.
func NonRetryable ¶
NonRetryable returns a NonRetryableError wrapping err.
func NonRetryablef ¶
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 ¶
WithDefaults returns a copy with zero / non-positive fields filled from package defaults.
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