Documentation
¶
Index ¶
- Variables
- type DeliveryResult
- type Event
- type Manager
- func (m *Manager) AddHeader(id, key, value string) error
- func (m *Manager) Create(name, url, secret string, events []string) (*Webhook, error)
- func (m *Manager) Delete(id string) error
- func (m *Manager) Disable(id string) error
- func (m *Manager) Emit(eventType, source string, data map[string]interface{})
- func (m *Manager) EmitSync(eventType, source string, data map[string]interface{}) []*DeliveryResult
- func (m *Manager) Enable(id string) error
- func (m *Manager) Get(id string) *Webhook
- func (m *Manager) GetDeliveryHistory(webhookID string, limit int) []*DeliveryResult
- func (m *Manager) List() []*Webhook
- func (m *Manager) RemoveHeader(id, key string) error
- func (m *Manager) SetRetryPolicy(id string, policy RetryPolicy) error
- func (m *Manager) Test(id string) (*DeliveryResult, error)
- func (m *Manager) Update(id string, updates map[string]interface{}) error
- type RetryPolicy
- type Webhook
Constants ¶
This section is empty.
Variables ¶
View Source
var PredefinedEvents = []string{
"chat.message",
"chat.session_start",
"chat.session_end",
"tool.executed",
"skill.activated",
"skill.deactivated",
"error",
"warning",
"update.available",
"budget.exceeded",
"mcp.connected",
"mcp.disconnected",
}
PredefinedEvents 预定义事件类型
Functions ¶
This section is empty.
Types ¶
type DeliveryResult ¶
type DeliveryResult struct {
WebhookID string `json:"webhook_id"`
EventID string `json:"event_id"`
Timestamp time.Time `json:"timestamp"`
Success bool `json:"success"`
StatusCode int `json:"status_code,omitempty"`
Response string `json:"response,omitempty"`
Error string `json:"error,omitempty"`
Duration time.Duration `json:"duration"`
}
DeliveryResult 投递结果
type Event ¶
type Event struct {
ID string `json:"id"`
Type string `json:"type"`
Source string `json:"source"`
Timestamp time.Time `json:"timestamp"`
Data map[string]interface{} `json:"data"`
Retries int `json:"retries"`
}
Event 事件
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager Webhook 管理器
func (*Manager) EmitSync ¶
func (m *Manager) EmitSync(eventType, source string, data map[string]interface{}) []*DeliveryResult
EmitSync 同步触发事件(等待所有投递完成)
func (*Manager) GetDeliveryHistory ¶
func (m *Manager) GetDeliveryHistory(webhookID string, limit int) []*DeliveryResult
GetDeliveryHistory 获取投递历史
func (*Manager) RemoveHeader ¶
RemoveHeader 移除自定义 header
func (*Manager) SetRetryPolicy ¶
func (m *Manager) SetRetryPolicy(id string, policy RetryPolicy) error
SetRetryPolicy 设置重试策略
type RetryPolicy ¶
type RetryPolicy struct {
MaxRetries int `json:"max_retries"`
RetryDelay int `json:"retry_delay_seconds"`
BackoffMultiplier float64 `json:"backoff_multiplier"`
}
RetryPolicy retry policy
type Webhook ¶
type Webhook struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
Secret string `json:"secret,omitempty"`
Events []string `json:"events"` // 监听的事件类型
Active bool `json:"active"`
Headers map[string]string `json:"headers,omitempty"`
Timeout int `json:"timeout"` // 秒
RetryPolicy RetryPolicy `json:"retry_policy"`
CreatedAt time.Time `json:"created_at"`
LastTriggered time.Time `json:"last_triggered,omitempty"`
}
Webhook Webhook 配置
Click to show internal directories.
Click to hide internal directories.