Documentation
¶
Overview ¶
Package webhook provides HTTP webhook client and types for external integrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client sends webhooks to external endpoints with retry logic.
type Config ¶
type Config struct {
Timeout time.Duration
MaxRetries int
RetryBackoff time.Duration
MaxConcurrent int
}
Config holds configuration for the webhook client.
type DeliveryResult ¶
type DeliveryResult struct {
WebhookID string `json:"webhook_id"`
StatusCode int `json:"status_code"`
ResponseBody string `json:"response_body,omitempty"`
Duration time.Duration `json:"duration_ms"`
Attempts int `json:"attempts"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
DeliveredAt time.Time `json:"delivered_at"`
}
DeliveryResult represents the outcome of a webhook delivery attempt.
type RetryPolicy ¶
type RetryPolicy struct {
MaxAttempts int `json:"max_attempts"`
InitialBackoff time.Duration `json:"initial_backoff"`
MaxBackoff time.Duration `json:"max_backoff"`
Multiplier float64 `json:"multiplier"`
}
RetryPolicy defines the retry behavior for failed webhook deliveries.
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() *RetryPolicy
DefaultRetryPolicy returns a sensible default retry policy.
func (*RetryPolicy) CalculateBackoff ¶
func (p *RetryPolicy) CalculateBackoff(attempt int) time.Duration
CalculateBackoff returns the backoff duration for the given attempt number.
type Webhook ¶
type Webhook struct {
ID string `json:"id"`
URL string `json:"url"`
EventType string `json:"event_type"`
EventID string `json:"event_id"`
Payload json.RawMessage `json:"payload"`
Headers map[string]string `json:"headers,omitempty"`
Secret string `json:"-"` // For HMAC signing, not serialized
Timeout time.Duration `json:"-"`
RetryPolicy *RetryPolicy `json:"-"`
}
Webhook represents a webhook request to be sent to an external endpoint.
Click to show internal directories.
Click to hide internal directories.