Documentation
¶
Index ¶
- Variables
- type Condition
- type DefaultUnit
- type DictValueType
- type ExecutionState
- type FormatFunction
- type IJob
- type IJobPolicy
- type IStage
- type Job
- type JobPolicy
- type JobStatus
- type JobUnit
- type Joiner
- type Line
- type Operator
- type OperatorStr
- type Pipeline
- func (p *Pipeline) ApplyState(state PipelineState)
- func (p *Pipeline) LoadState() error
- func (p *Pipeline) Pause()
- func (p *Pipeline) Resume()
- func (p *Pipeline) Run(ctx context.Context, initialInput any) (any, error)
- func (p *Pipeline) RunWithCallback(ctx context.Context, initialInput any, callback StageCallback) (any, error)
- func (p *Pipeline) SaveState()
- func (p *Pipeline) Stop()
- type PipelineState
- type SortEnum
- type SortRO
- type Stage
- type StageCallback
- type StageStatus
- type StoryBoard
- type Unit
- type UnitOutput
- type UnitRegistry
- type UnitTemplate
Constants ¶
This section is empty.
Variables ¶
View Source
var ( LIKE = Operator{"LIKE", "文本包含", String, false, 10} IN_LIKE = Operator{"IN_LIKE", "文本包含", StringList, false, 20} IN = Operator{"IN", "IN", StringList, false, 30} NOT_IN = Operator{"NOT_IN", "非IN", StringList, false, 30} EQ = Operator{"EQ", "数值等于", Number, false, 100} NE = Operator{"NE", "数值不等于", Number, false, 200} GT = Operator{"GT", "数值大于", Number, false, 300} GTE = Operator{"GTE", "数值大于等于", Number, false, 400} LT = Operator{"LT", "数值小于", Number, false, 500} LTE = Operator{"LTE", "数值小于等于", Number, false, 600} EXISTS = Operator{"EXISTS", "存在", Single, false, 0} NON_EXISTS = Operator{"NON_EXISTS", "不存在", Single, false, 1} BETWEEN = Operator{"BETWEEN", "数值介于", NumberTuple, false, 700} )
预定义的 Operator 实例
Functions ¶
This section is empty.
Types ¶
type Condition ¶ added in v0.0.7
type Condition struct {
Key string `json:"key,omitempty"` // 条件键
Operator OperatorStr `json:"operator"` // 操作符
Value interface{} `json:"value,omitempty"` // 值
Label string `json:"label,omitempty"` // 标签
Script string `json:"script,omitempty"` // 脚本
JointNext Joiner `json:"joint_next,omitempty"`
Children []Condition `json:"children,omitempty"`
}
Condition 结构体
func NewCondition ¶ added in v0.0.7
func NewCondition(key string, operator OperatorStr, value interface{}) *Condition
NewCondition 创建一个新的 Condition
func (*Condition) MarshalJSON ¶ added in v0.0.7
MarshalJSON 自定义 JSON 序列化
type DefaultUnit ¶
type DefaultUnit struct {
Name string
Description string
// contains filtered or unexported fields
}
默认的Unit实现
type DictValueType ¶ added in v0.0.7
type DictValueType string
const ( String DictValueType = "STRING" StringList DictValueType = "STRING_LIST" Number DictValueType = "NUMBER" NumberTuple DictValueType = "NUMBER_TUPLE" Single DictValueType = "SINGLE" )
type ExecutionState ¶
type ExecutionState interface {
Save(state PipelineState) error
Load() (PipelineState, error)
}
type FormatFunction ¶ added in v0.0.7
type FormatFunction string
FormatFunction 枚举,用于表示不同格式类型
const ( BOOL FormatFunction = "bool" DATE FormatFunction = "date" TIME FormatFunction = "time" DATETIME FormatFunction = "datetime" INT FormatFunction = "int" NUMBER FormatFunction = "number" DECIMAL FormatFunction = "decimal" STRING FormatFunction = "string" )
type IJob ¶
type IJob[T any] interface { ID() string // 任务唯一标识 Status() JobStatus // 任务的整体状态 GetPolicy() IJobPolicy Execute(ctx context.Context, input any, current *Unit) (T, error) // }
IJob Job接口:每个单元固定绑定一个Job,实现输入->输出的逻辑
type IJobPolicy ¶
type IStage ¶
type IStage[T any] interface { Name() string // 阶段名称 Status() StageStatus // 阶段状态 DependsOn() []string // 依赖的阶段NAME(空表示第一个阶段) // contains filtered or unexported methods }
type Job ¶
type Job struct {
Name string // 任务名称
Results any // 存储阶段产物,key 为阶段名称
Output any // 输出可以是任意类型的数据
Input any // 输入也可以是任意类型的数据
Policy IJobPolicy //
Dependencies []*IJob[any] // 该任务依赖的其他任务, 用于构建依赖关系
Executor func(ctx context.Context, i any, current *Unit) (any, error) // 执行器
// contains filtered or unexported fields
}
func (*Job) GetPolicy ¶
func (j *Job) GetPolicy() IJobPolicy
type JobPolicy ¶
type JobPolicy struct {
// contains filtered or unexported fields
}
func (*JobPolicy) MaxRetries ¶
func (*JobPolicy) ReachMaxRetries ¶
func (*JobPolicy) RetryCount ¶
func (*JobPolicy) RetryDelay ¶
type JobUnit ¶
func NewJobUnit ¶
type Operator ¶ added in v0.0.7
type Operator struct {
Value string `json:"value"`
Desc string `json:"desc"`
ValueType DictValueType `json:"value_type"`
Disabled bool `json:"disabled"`
Order int `json:"order"`
}
Operator 枚举
type OperatorStr ¶ added in v0.0.7
type OperatorStr = string
type Pipeline ¶
type Pipeline struct {
ID string
Status string // "pending", "running", "completed", "failed", "terminal", "retry", "resume","paused"
StartTime time.Time
EndTime time.Time
StateStore ExecutionState
Results map[string]any
// contains filtered or unexported fields
}
Pipeline 是整个 CI/CD 流水线,包含多个阶段
func NewPipeline ¶
func NewPipeline(StateStore ExecutionState, stages ...*Stage) *Pipeline
func (*Pipeline) ApplyState ¶
func (p *Pipeline) ApplyState(state PipelineState)
func (*Pipeline) RunWithCallback ¶ added in v0.0.5
type PipelineState ¶
type SortRO ¶ added in v0.0.7
type SortRO struct {
Column string `json:"column"`
Desc bool `json:"desc"` // 默认为 false
Format FormatFunction `json:"format"` // 格式函数
}
SortRO 结构体
type Stage ¶
type Stage struct {
Name string `json:"name"` // 阶段名称
DependsOn string `json:"depends_on"` // 依赖的阶段NAME(空表示第一个阶段)
Status StageStatus `json:"status"` // 阶段状态
// contains filtered or unexported fields
}
type StageCallback ¶ added in v0.0.5
type StageCallback func(stage *Stage, status StageStatus, self *Pipeline, err error) bool
type StageStatus ¶
type StageStatus string
const ( StagePending StageStatus = "PENDING" StageRunning StageStatus = "RUNNING" StageCompleted StageStatus = "COMPLETED" StageFailed StageStatus = "FAILED" StageNeedTerminate StageStatus = "BREAK" ALLStageCompleted StageStatus = "ALL:COMPLETED" )
type StoryBoard ¶ added in v0.0.5
type StoryBoard struct {
Stages []*Stage //这里不是真正的Stage , 需要套一层UI-Data ,StageVo -》 Stage
Lines []*Line
}
故事版跟Pipeline的相似度处: 1. 都有Stage[] 2. 都有Stage关系 从StoryBoard创建Pipeline,只要有连线,校验通过
func (*StoryBoard) Build ¶ added in v0.0.5
func (u *StoryBoard) Build() (p *Pipeline, e error)
type Unit ¶
type Unit interface {
ID() string // Unit的ID,每次实例化可能不一样
Run(ctx context.Context, input any, current *Unit) (any, error) // 执行单元的主要逻辑,会产出结果输出
}
Unit 表示具体的单元,由模板实例化而来。 一个Unit有输入输出的Channel描述、有执行Job的逻辑等
type UnitOutput ¶
type UnitRegistry ¶
type UnitTemplate ¶
type UnitTemplate interface {
Name() string
Description() string
// Instantiate 由Storyboard在构建Stage时调用,用于根据模板创建对应的Unit实例(单元)
Instantiate() Unit
}
UnitTemplate 是零件模板接口,通过它可以实例化出对应的Unit。 不同的UnitTemplate可以定义不同的处理逻辑、输入输出类型等。
Click to show internal directories.
Click to hide internal directories.