Documentation
¶
Overview ¶
Package event 定义 workflow 运行过程中产生的事件模型和事件下沉接口。
runtime 使用这些事件描述工作流、节点、日志和统计信息;存储到哪里由外部 sink 决定。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncSink ¶
type AsyncSink struct {
// contains filtered or unexported fields
}
AsyncSink 用后台 worker 异步转发事件,降低 runtime 写事件时的阻塞风险。
func NewAsyncSink ¶
func NewAsyncSink(sink Sink, opts AsyncSinkOptions) *AsyncSink
NewAsyncSink 创建异步 sink,并按需补齐安全默认值。
type AsyncSinkOptions ¶
type AsyncSinkOptions struct {
BufferSize int
Workers int
BatchSize int
FlushInterval time.Duration
DropOnFull bool
}
AsyncSinkOptions 配置异步事件 sink 的缓冲、并发和批量刷新行为。
type BatchSink ¶
type BatchSink interface {
EmitBatch(events []*Event)
}
BatchSink 是 sink 可选实现的批量导出接口。
type Event ¶
type Event struct {
Type Type `json:"type"`
Env string `json:"env"`
Workspace string `json:"workspace"`
TraceID string `json:"traceId"`
RunID string `json:"runId"`
ParentRunID string `json:"parentRunId"`
WorkflowID string `json:"workflowId"`
WorkflowVer string `json:"workflowVersion"`
NodeID string `json:"nodeId"`
NodeName string `json:"nodeName"`
ParentNodeID string `json:"parentNodeId"`
NodePath string `json:"nodePath"`
NodeDepth *int `json:"nodeDepth"`
NodeIndex *int `json:"nodeIndex"`
NodeType string `json:"nodeType"`
Status string `json:"status"`
NodeStatus string `json:"nodeStatus"`
Error string `json:"error"`
LogLevel string `json:"logLevel"`
Message string `json:"message"`
StartedAt time.Time `json:"startedAt"`
EndedAt time.Time `json:"endedAt"`
DurationMs int64 `json:"durationMs"`
Attrs map[string]interface{} `json:"attrs"`
Fields map[string]interface{} `json:"fields"`
}
Event 是 FlowLink runtime 执行过程和节点日志的统一事件记录。
type MemorySink ¶
type MemorySink struct {
// contains filtered or unexported fields
}
MemorySink 将事件保存在内存中,主要用于测试、debug 和一次性报告。
type Sanitizer ¶
type Sanitizer struct {
// contains filtered or unexported fields
}
Sanitizer 对事件中的错误、消息、attrs 和 fields 做安全清洗。
func NewSanitizer ¶
func NewSanitizer(opts SanitizerOptions) *Sanitizer
NewSanitizer 创建事件清洗器,并补齐默认限制和默认敏感 key。
func (*Sanitizer) SanitizeEvent ¶
SanitizeEvent 返回清洗后的事件副本。
type SanitizerOptions ¶
type SanitizerOptions struct {
Enabled bool
MaxStringLength int
MaxCollectionItems int
MaxDepth int
MaskedKeys []string
}
SanitizerOptions 配置事件脱敏、截断和嵌套深度限制。
type SanitizingSink ¶
type SanitizingSink struct {
// contains filtered or unexported fields
}
SanitizingSink 在写入下游 sink 前先清洗事件内容。
func (*SanitizingSink) EmitBatch ¶
func (s *SanitizingSink) EmitBatch(events []*Event)
EmitBatch 清洗并转发批量事件。
type Sink ¶
type Sink interface {
Emit(e *Event)
}
Sink 是 runtime 和 trace helper 使用的可插拔事件导出接口。
func NewSanitizingSink ¶
func NewSanitizingSink(sink Sink, opts SanitizerOptions) Sink
NewSanitizingSink 包装下游 sink,使事件写入前经过 Sanitizer。
type Type ¶
type Type string
Type 是 runtime 产生的标准执行事件类型。
const ( // WorkflowStarted 表示 workflow 开始执行。 WorkflowStarted Type = "WORKFLOW_STARTED" // WorkflowFinished 表示 workflow 完成执行。 WorkflowFinished Type = "WORKFLOW_FINISHED" // NodeStarted 表示节点开始执行。 NodeStarted Type = "NODE_STARTED" // NodeFinished 表示节点成功完成执行。 NodeFinished Type = "NODE_FINISHED" // NodeFailed 表示节点执行失败。 NodeFailed Type = "NODE_FAILED" // WorkflowLog 表示框架在 workflow 维度写出的运行日志。 WorkflowLog Type = "WORKFLOW_LOG" // NodeLog 表示节点通过 FlowContext 写出的日志。 NodeLog Type = "NODE_LOG" )