Documentation
¶
Index ¶
- Constants
- type DescribeWebHookRequest
- type QueryWebHookRequest
- type STATUS
- type Service
- type WebHook
- func (w *WebHook) Failed(err error) *WebHook
- func (e *WebHook) LoadFromEvent(event *bus.Event) error
- func (h *WebHook) Run(ctx context.Context)
- func (h *WebHook) SetDefault()
- func (w *WebHook) Success() *WebHook
- func (h *WebHook) TableName() string
- func (e *WebHook) ToBusEvent(topic string) *bus.Event
- type WebHookSpec
- type WebHookStatus
Constants ¶
View Source
const (
APP_NAME = "webhooks"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DescribeWebHookRequest ¶ added in v0.0.21
type DescribeWebHookRequest struct {
Id string
}
func NewDescribeWebHookRequest ¶ added in v0.0.21
func NewDescribeWebHookRequest(id string) *DescribeWebHookRequest
type QueryWebHookRequest ¶
type QueryWebHookRequest struct { // 关联Task RefTaskId string `json:"ref_task_id"` }
func NewQueryWebHookRequest ¶
func NewQueryWebHookRequest() *QueryWebHookRequest
func (*QueryWebHookRequest) SetRefTaskId ¶
func (r *QueryWebHookRequest) SetRefTaskId(taskId string) *QueryWebHookRequest
type Service ¶
type Service interface { // 执行WebHook, 触发执行, 执行状态通过HookId查询 Run(context.Context, *WebHookSpec) (*WebHook, error) // 查询WebHook具体执行状态 DescribeWebHook(context.Context, *DescribeWebHookRequest) (*WebHook, error) // 查询WebHook执行记录列表 QueryWebHook(context.Context, *QueryWebHookRequest) (*types.Set[*WebHook], error) }
func GetService ¶
func GetService() Service
type WebHook ¶
type WebHook struct { // WebHook 的唯一标识 Id string `json:"id"` // 创建时间 CreatedAt time.Time `` /* 126-byte string literal not displayed */ // WebHook定义 WebHookSpec // 状态与统计 WebHookStatus }
任务回调
func NewWebHook ¶
func NewWebHook(spec WebHookSpec) *WebHook
func (*WebHook) LoadFromEvent ¶ added in v0.0.21
func (*WebHook) SetDefault ¶
func (h *WebHook) SetDefault()
type WebHookSpec ¶
type WebHookSpec struct { // WebHook 名称 Name string `json:"name"` // 描述 Description string `json:"description"` // 关联Task RefTaskId string `json:"ref_task_id"` // 目标配置 // 接收 HTTP 请求的 URL TargetURL string `json:"target_url"` // HTTP 方法,如 POST、GET 等 Method string `json:"method"` // 自定义请求头 Headers map[string]string `json:"headers" gorm:"column:headers;type:json;serializer:json;"` // 安全验证 // 用于签名验证的密钥(HMAC) Secret string `json:"secret"` // 签名头的名称,如 "X-Hub-Signature" SignatureHeader string `json:"signature_header"` // 哪些条件下触发 Conditions []string `json:"conditions" gorm:"column:conditions;type:json;serializer:json;"` // 请求内容配置 // 请求体类型,如 "application/json" ContentType string `json:"content_type"` // 自定义请求体模板(可选) Payload string `json:"payload"` // 重试与超时 // 失败重试次数 RetryCount int `json:"retry_count"` // 请求超时时间(毫秒) Timeout int `json:"timeout"` }
func NewWebHookSpec ¶ added in v0.0.21
func NewWebHookSpec() *WebHookSpec
func (*WebHookSpec) AddCondtion ¶
func (s *WebHookSpec) AddCondtion(conditions ...string)
func (*WebHookSpec) IsCondtionOk ¶
func (s *WebHookSpec) IsCondtionOk(condition string) bool
type WebHookStatus ¶
type WebHookStatus struct { // 更新时间 UpdateAt *time.Time `json:"update_at" gorm:"column:update_at;type:timestamp;default:current_timestamp;not null;index;" description:"更新时间"` // 状态与统计 Status STATUS `json:"status" gorm:"column:status;type:varchar(32);not null;" description:"状态"` // 失败信息 Message string `json:"message" gorm:"column:message;type:text;" description:"失败信息"` }
func NewWebHookStatus ¶
func NewWebHookStatus() *WebHookStatus
func (*WebHookStatus) SetUpdateAt ¶ added in v0.0.21
func (w *WebHookStatus) SetUpdateAt(v time.Time) *WebHookStatus
func (WebHookStatus) String ¶ added in v0.0.21
func (w WebHookStatus) String() string
func (WebHookStatus) TableName ¶ added in v0.0.21
func (w WebHookStatus) TableName() string
Click to show internal directories.
Click to hide internal directories.