Documentation
¶
Index ¶
- type DefaultUnit
- type ExecutionState
- type IJob
- type IJobPolicy
- type IStage
- type Job
- type JobPolicy
- type JobStatus
- type JobUnit
- type Line
- 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 Stage
- type StageCallback
- type StageStatus
- type StoryBoard
- type Unit
- type UnitOutput
- type UnitRegistry
- type UnitTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultUnit ¶
type DefaultUnit struct {
Name string
Description string
// contains filtered or unexported fields
}
默认的Unit实现
type ExecutionState ¶
type ExecutionState interface {
Save(state PipelineState) error
Load() (PipelineState, error)
}
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 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 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.