Documentation
¶
Overview ¶
Package longrunning 提供长时代理任务执行与恢复能力。
Index ¶
- type Checkpoint
- type Execution
- type ExecutionState
- type Executor
- func (e *Executor) CreateExecution(name string, steps []StepFunc) *Execution
- func (e *Executor) GetExecution(execID string) (*Execution, bool)
- func (e *Executor) ListExecutions() []*Execution
- func (e *Executor) LoadExecution(execID string) (*Execution, error)
- func (e *Executor) Pause(execID string) error
- func (e *Executor) Resume(execID string) error
- func (e *Executor) Start(ctx context.Context, execID string, initialState any) error
- type ExecutorConfig
- type StepFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checkpoint ¶
type Checkpoint struct {
ID string `json:"id"`
Step int `json:"step"`
State any `json:"state"`
Timestamp time.Time `json:"timestamp"`
Metadata map[string]any `json:"metadata,omitempty"`
}
检查站是一个可恢复的检查站。
type Execution ¶
type Execution struct {
ID string `json:"id"`
Name string `json:"name"`
State ExecutionState `json:"state"`
Progress float64 `json:"progress"`
CurrentStep int `json:"current_step"`
TotalSteps int `json:"total_steps"`
StartTime time.Time `json:"start_time"`
LastUpdate time.Time `json:"last_update"`
EndTime *time.Time `json:"end_time,omitempty"`
Checkpoints []Checkpoint `json:"checkpoints"`
Metadata map[string]any `json:"metadata,omitempty"`
Error string `json:"error,omitempty"`
}
处决是长期执行的代理人处决。
type ExecutionState ¶
type ExecutionState string
处决国是长期处决状态。
const ( StateInitialized ExecutionState = "initialized" StateRunning ExecutionState = "running" StatePaused ExecutionState = "paused" StateResuming ExecutionState = "resuming" StateCompleted ExecutionState = "completed" StateFailed ExecutionState = "failed" StateCancelled ExecutionState = "cancelled" )
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
执行官管理长期代理处决。
func NewExecutor ¶
func NewExecutor(config ExecutorConfig, logger *zap.Logger) *Executor
NewExecuters 创建一个新的长期执行器 。
func (*Executor) CreateExecution ¶
CreateExecution 创建了新的长期执行.
func (*Executor) GetExecution ¶
GetExecution 以 ID 检索执行 。
func (*Executor) ListExecutions ¶
ListExecutions 返回全部处决 。
func (*Executor) LoadExecution ¶
LoadExecution从检查站装入一个执行器.
type ExecutorConfig ¶
type ExecutorConfig struct {
CheckpointInterval time.Duration `json:"checkpoint_interval"`
CheckpointDir string `json:"checkpoint_dir"`
MaxRetries int `json:"max_retries"`
HeartbeatInterval time.Duration `json:"heartbeat_interval"`
AutoResume bool `json:"auto_resume"`
}
执行器Config 配置长期执行器。
Click to show internal directories.
Click to hide internal directories.