executor

package
v0.0.0-...-3961abf Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResumeExecution

func ResumeExecution(types *ActionConfig, cp Checkpointer, maxCpuIntensiveTasks int, checkpointInterval time.Duration) error

Types

type Action

type Action struct {
	Type       ActionType
	JsonAction JsonAction
}

type ActionConfig

type ActionConfig struct {
	ActionTypes map[ActionTypeName]ActionType
}

func NewActionConfig

func NewActionConfig(types ...ActionType) (*ActionConfig, error)

type ActionKey

type ActionKey any

type ActionType

type ActionType interface {
	TypeName() ActionTypeName
	EmptyJsonAction() JsonAction
	IsCpuIntensive() bool
}

type ActionTypeName

type ActionTypeName string

type Checkpoint

type Checkpoint struct {
	Actions []*CheckpointedAction
}

type CheckpointedAction

type CheckpointedAction struct {
	ActionType ActionTypeName
	JsonAction string
	Completed  bool
}

type Checkpointer

type Checkpointer interface {
	// GetCheckpoint returns the current checkpoint, or nil if untracked.
	GetCheckpoint() ([]byte, error)
	// SetCheckpoint updates the current checkpoint, or deletes it if nil/an empty array is provided.
	SetCheckpoint(checkpoint []byte) error
}

type Dependency

type Dependency struct {
	ActionTypeName ActionTypeName
	ActionKey      ActionKey
}

type Execution

type Execution struct {
	// contains filtered or unexported fields
}

func NewExecution

func NewExecution(types *ActionConfig, cp Checkpointer, maxCpuIntensiveTasks int, checkpointInterval time.Duration) (*Execution, error)

func (*Execution) AddAction

func (e *Execution) AddAction(typeName ActionTypeName, jsonAction JsonAction) error

func (*Execution) Run

func (e *Execution) Run() error

type JsonAction

type JsonAction interface {
	Dependencies() []Dependency
	ActionKey() ActionKey
	Execute() error
}

Jump to

Keyboard shortcuts

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