webhook

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DispatchAsync

func DispatchAsync(
	ctx context.Context,
	d *Dispatcher,
	s store.Store,
	webhookLog *store.WebhookLog,
	delayMs int,
)

DispatchAsync fires a webhook in a goroutine and updates the WebhookLog. delayMs: milliseconds to wait before dispatching (0 = immediate).

The incoming ctx is detached from its parent's cancellation via context.WithoutCancel so the goroutine's DB writes and HTTP calls survive after the originating HTTP request has completed. The logger (and any trace-id) stored in ctx is preserved.

Types

type AttemptEntry

type AttemptEntry struct {
	Status      int
	DurationMs  int
	AttemptedAt time.Time
	Response    string // response body (capped at maxAttemptBodyBytes)
	Error       string // transport-level error; empty when an HTTP response was received
}

type DispatchResult

type DispatchResult struct {
	StatusCode  int
	Attempts    int
	AttemptLogs []AttemptEntry
}

type Dispatcher

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

func NewDispatcher

func NewDispatcher(maxAttempts int, baseDelay time.Duration) *Dispatcher

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(targetURL string, payload map[string]any) (*DispatchResult, error)

Jump to

Keyboard shortcuts

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