longrunning

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package longrunning 提供长时代理任务执行与恢复能力。

Index

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

func (e *Executor) CreateExecution(name string, steps []StepFunc) *Execution

CreateExecution 创建了新的长期执行.

func (*Executor) GetExecution

func (e *Executor) GetExecution(execID string) (*Execution, bool)

GetExecution 以 ID 检索执行 。

func (*Executor) ListExecutions

func (e *Executor) ListExecutions() []*Execution

ListExecutions 返回全部处决 。

func (*Executor) LoadExecution

func (e *Executor) LoadExecution(execID string) (*Execution, error)

LoadExecution从检查站装入一个执行器.

func (*Executor) Pause

func (e *Executor) Pause(execID string) error

暂停执行 。

func (*Executor) Resume

func (e *Executor) Resume(execID string) error

恢复暂停执行 。

func (*Executor) Start

func (e *Executor) Start(ctx context.Context, execID string, initialState any) error

开始长期执行

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 配置长期执行器。

func DefaultExecutorConfig

func DefaultExecutorConfig() ExecutorConfig

默认执行config 返回默认配置 。

type StepFunc

type StepFunc func(ctx context.Context, state any) (any, error)

StepFunc代表了长跑行刑的单步.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL