Documentation
¶
Overview ¶
Package webhooks provides HTTP webhook notification system for task events
Index ¶
- func VerifySignature(payload []byte, signature, secret string) bool
- type DeliveryResult
- type DeliveryTask
- type EventType
- type Manager
- func (m *Manager) Disable(id string) error
- func (m *Manager) Emit(event EventType, data map[string]interface{})
- func (m *Manager) EmitTaskBlocked(taskID, title string)
- func (m *Manager) EmitTaskClaimed(taskID, title, workerID string)
- func (m *Manager) EmitTaskCompleted(taskID, title string, durationMS int64)
- func (m *Manager) EmitTaskCreated(taskID, title, epicID string)
- func (m *Manager) EmitTaskFailed(taskID, title, errorMsg string, attempts int)
- func (m *Manager) EmitTaskPaused(taskID, title string)
- func (m *Manager) EmitTaskResumed(taskID, title string)
- func (m *Manager) EmitTaskStarted(taskID, title, workerID string)
- func (m *Manager) EmitWorkerStarted(workerID string, workerIndex int)
- func (m *Manager) EmitWorkerStopped(workerID string, workerIndex, taskCount int)
- func (m *Manager) Enable(id string) error
- func (m *Manager) Get(id string) (*Webhook, error)
- func (m *Manager) GetDeliveryHistory(limit int) []*DeliveryResult
- func (m *Manager) List() []*Webhook
- func (m *Manager) Register(webhook *Webhook) error
- func (m *Manager) SetLogger(logger *log.Logger)
- func (m *Manager) SetTimeout(timeout time.Duration)
- func (m *Manager) Start(workers int)
- func (m *Manager) Stop(ctx context.Context) error
- func (m *Manager) Unregister(id string) error
- type Payload
- type TaskEventData
- type Webhook
- type WorkerEventData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifySignature ¶
VerifySignature verifies an HMAC signature
Types ¶
type DeliveryResult ¶
type DeliveryResult struct {
WebhookID string
DeliveryID string
Event EventType
StatusCode int
Success bool
Error string
DurationMS int64
Timestamp int64
}
DeliveryResult represents the result of a webhook delivery attempt
type DeliveryTask ¶
type DeliveryTask struct {
// contains filtered or unexported fields
}
DeliveryTask represents a webhook delivery task
type EventType ¶
type EventType string
EventType represents the type of event that triggered the webhook
const ( EventTaskCreated EventType = "task.created" EventTaskClaimed EventType = "task.claimed" EventTaskStarted EventType = "task.started" EventTaskPaused EventType = "task.paused" EventTaskResumed EventType = "task.resumed" EventTaskBlocked EventType = "task.blocked" EventTaskCompleted EventType = "task.completed" EventTaskFailed EventType = "task.failed" EventWorkerStarted EventType = "worker.started" EventWorkerStopped EventType = "worker.stopped" )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages webhook registration and delivery
func (*Manager) EmitTaskBlocked ¶
EmitTaskBlocked emits a task blocked event
func (*Manager) EmitTaskClaimed ¶
EmitTaskClaimed emits a task claimed event
func (*Manager) EmitTaskCompleted ¶
EmitTaskCompleted emits a task completed event
func (*Manager) EmitTaskCreated ¶
EmitTaskCreated emits a task created event
func (*Manager) EmitTaskFailed ¶
EmitTaskFailed emits a task failed event
func (*Manager) EmitTaskPaused ¶
EmitTaskPaused emits a task paused event
func (*Manager) EmitTaskResumed ¶
EmitTaskResumed emits a task resumed event
func (*Manager) EmitTaskStarted ¶
EmitTaskStarted emits a task started event
func (*Manager) EmitWorkerStarted ¶
EmitWorkerStarted emits a worker started event
func (*Manager) EmitWorkerStopped ¶
EmitWorkerStopped emits a worker stopped event
func (*Manager) GetDeliveryHistory ¶
func (m *Manager) GetDeliveryHistory(limit int) []*DeliveryResult
GetDeliveryHistory returns recent delivery results
func (*Manager) SetTimeout ¶
SetTimeout sets the HTTP client timeout
func (*Manager) Unregister ¶
Unregister removes a webhook
type Payload ¶
type Payload struct {
Event EventType `json:"event"`
Timestamp int64 `json:"timestamp"`
WebhookID string `json:"webhook_id"`
DeliveryID string `json:"delivery_id"` // Unique ID for each delivery attempt
Data map[string]interface{} `json:"data"`
}
Payload represents the webhook payload sent to endpoints
type TaskEventData ¶
type TaskEventData struct {
TaskID string `json:"task_id"`
Title string `json:"title"`
EpicID string `json:"epic_id,omitempty"`
Status string `json:"status"`
WorkerID string `json:"worker_id,omitempty"`
Error string `json:"error,omitempty"`
Attempts int `json:"attempts,omitempty"`
DurationMS int64 `json:"duration_ms,omitempty"`
}
TaskEventData contains task-related event data
type Webhook ¶
type Webhook struct {
ID string `json:"id"`
URL string `json:"url"`
Secret string `json:"secret,omitempty"` // HMAC secret for verification
Events []EventType `json:"events"` // Events to subscribe to
Headers map[string]string `json:"headers,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt int64 `json:"created_at"`
}
Webhook represents a configured webhook endpoint
type WorkerEventData ¶
type WorkerEventData struct {
WorkerID string `json:"worker_id"`
WorkerIndex int `json:"worker_index"`
TaskCount int `json:"task_count"`
}
WorkerEventData contains worker-related event data