Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteEndpoint(ctx context.Context, db *sql.DB, ...) error
- func SignWebhookPayload(payload, secret string) (string, error)
- type QueueEmptyWebhookEventParams
- type WebhookClock
- type WebhookDeliveryAttempt
- type WebhookDeliveryEndpoint
- type WebhookDeliveryErrorClass
- type WebhookDeliveryEvidence
- type WebhookDeliveryRequest
- type WebhookDeliveryResult
- type WebhookDeliveryStatus
- type WebhookDeliveryStore
- type WebhookDeliveryWorker
- type WebhookEndpoint
- type WebhookEndpointCreateParams
- type WebhookEndpointCreateResult
- type WebhookEvent
- type WebhookEventType
- type WebhookHTTPClient
- type WebhookHTTPRequest
- type WebhookHTTPResponse
Constants ¶
View Source
const ( DefaultWebhookWorkspaceLimit = 10 MaxWebhookURLLength = 2048 )
Variables ¶
View Source
var ( ErrWebhookWorkspaceRequired = errors.New("goncho: workspace_id is required") ErrWebhookInvalidURL = errors.New("goncho: invalid webhook url") ErrWebhookLimitReached = errors.New("goncho: maximum webhook endpoints reached for workspace") ErrWebhookNotFound = errors.New("goncho: webhook endpoint not found") ErrWebhookSecretMissing = errors.New("goncho: webhook secret is required") )
Functions ¶
func DeleteEndpoint ¶
func SignWebhookPayload ¶
Types ¶
type WebhookClock ¶
type WebhookDeliveryAttempt ¶
type WebhookDeliveryAttempt struct {
EndpointID string
WorkspaceID string
EventType WebhookEventType
Attempt int
Status WebhookDeliveryStatus
StatusCode int
ErrorClass WebhookDeliveryErrorClass
Error string
Retry bool
NextRetryAt *time.Time
Evidence WebhookDeliveryEvidence
RecordedAt time.Time
}
type WebhookDeliveryEndpoint ¶
type WebhookDeliveryErrorClass ¶
type WebhookDeliveryErrorClass string
const ( WebhookDeliveryErrorNone WebhookDeliveryErrorClass = "" WebhookDeliveryErrorHTTPStatus WebhookDeliveryErrorClass = "http_status" WebhookDeliveryErrorNetwork WebhookDeliveryErrorClass = "network" WebhookDeliveryErrorSigning WebhookDeliveryErrorClass = "signing" WebhookDeliveryErrorStore WebhookDeliveryErrorClass = "store" WebhookDeliveryErrorDisabled WebhookDeliveryErrorClass = "endpoint_disabled" )
type WebhookDeliveryEvidence ¶
type WebhookDeliveryEvidence struct {
EndpointID string
EndpointURL string
WorkspaceID string
EventType WebhookEventType
Status WebhookDeliveryStatus
StatusCode int
ErrorClass WebhookDeliveryErrorClass
Attempt int
NextRetryAt *time.Time
}
type WebhookDeliveryRequest ¶
type WebhookDeliveryRequest struct {
WorkspaceID string
Event WebhookEvent
Attempt int
}
type WebhookDeliveryResult ¶
type WebhookDeliveryResult struct {
EndpointID string
WorkspaceID string
EventType WebhookEventType
Attempt int
Status WebhookDeliveryStatus
StatusCode int
ErrorClass WebhookDeliveryErrorClass
Error string
Retry bool
NextRetryAt *time.Time
Evidence WebhookDeliveryEvidence
}
type WebhookDeliveryStatus ¶
type WebhookDeliveryStatus string
const ( WebhookDeliveryDelivered WebhookDeliveryStatus = "delivered" WebhookDeliveryRetryable WebhookDeliveryStatus = "retryable" WebhookDeliveryFailed WebhookDeliveryStatus = "failed" WebhookDeliveryEndpointDisabled WebhookDeliveryStatus = "endpoint_disabled" WebhookDeliverySkipped WebhookDeliveryStatus = "skipped" )
type WebhookDeliveryStore ¶
type WebhookDeliveryStore interface {
ListWebhookDeliveryEndpoints(ctx context.Context, workspaceID string) ([]WebhookDeliveryEndpoint, error)
RecordWebhookDelivery(ctx context.Context, attempt WebhookDeliveryAttempt) error
DisableWebhookDeliveryEndpoint(ctx context.Context, endpoint WebhookDeliveryEndpoint, reason string, now time.Time) error
}
type WebhookDeliveryWorker ¶
type WebhookDeliveryWorker struct {
Store WebhookDeliveryStore
Client WebhookHTTPClient
Clock WebhookClock
Secret string
MaxAttempts int
Backoff func(attempt int) time.Duration
}
func (WebhookDeliveryWorker) Deliver ¶
func (w WebhookDeliveryWorker) Deliver(ctx context.Context, req WebhookDeliveryRequest) ([]WebhookDeliveryResult, error)
type WebhookEndpoint ¶
type WebhookEndpoint struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
URL string `json:"url"`
CreatedAt time.Time `json:"created_at"`
}
func ListEndpoints ¶
type WebhookEndpointCreateResult ¶
type WebhookEndpointCreateResult struct {
Endpoint WebhookEndpoint `json:"endpoint"`
Created bool `json:"created"`
}
func GetOrCreateEndpoint ¶
func GetOrCreateEndpoint(ctx context.Context, db *sql.DB, defaultWorkspaceID string, params WebhookEndpointCreateParams) (WebhookEndpointCreateResult, error)
type WebhookEvent ¶
type WebhookEvent struct {
Type WebhookEventType `json:"type"`
WorkspaceID string `json:"workspace_id"`
Data map[string]any `json:"data,omitempty"`
}
func NewQueueEmptyWebhookEvent ¶
func NewQueueEmptyWebhookEvent(params QueueEmptyWebhookEventParams) (WebhookEvent, error)
func NewTestWebhookEvent ¶
func NewTestWebhookEvent(workspaceID string) (WebhookEvent, error)
type WebhookEventType ¶
type WebhookEventType string
const ( WebhookEventQueueEmpty WebhookEventType = "queue.empty" WebhookEventTest WebhookEventType = "test.event" )
type WebhookHTTPClient ¶
type WebhookHTTPClient interface {
PostWebhook(ctx context.Context, req WebhookHTTPRequest) (WebhookHTTPResponse, error)
}
type WebhookHTTPRequest ¶
type WebhookHTTPResponse ¶
type WebhookHTTPResponse struct {
StatusCode int
}
Click to show internal directories.
Click to hide internal directories.