scheduler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogDir        string
	MaxActiveRuns int
	Delay         time.Duration
	Dry           bool
	OnExit        *pb.Step
	OnSuccess     *pb.Step
	OnFailure     *pb.Step
	OnCancel      *pb.Step
	RequestId     string
}

type ExecutionGraph

type ExecutionGraph struct {
	StartedAt  time.Time
	FinishedAt time.Time
	// contains filtered or unexported fields
}

ExecutionGraph represents a graph of steps.

func NewExecutionGraph

func NewExecutionGraph(steps ...*dag.Step) (*ExecutionGraph, error)

NewExecutionGraph creates a new execution graph with the given steps.

func NewExecutionGraphForRetry

func NewExecutionGraphForRetry(nodes ...*Node) (*ExecutionGraph, error)

NewExecutionGraphForRetry creates a new execution graph for retry with given nodes.

func (*ExecutionGraph) Duration

func (g *ExecutionGraph) Duration() time.Duration

Duration returns the duration of the execution.

func (*ExecutionGraph) Nodes

func (g *ExecutionGraph) Nodes() []*Node

Nodes returns the nodes of the execution graph.

type Node

type Node struct {
	*dag.Step
	NodeState
	// contains filtered or unexported fields
}

Node is a node in a DAG. It executes a command.

func (*Node) Execute

func (n *Node) Execute(ctx context.Context) error

Execute runs the command synchronously and returns error if any.

func (*Node) IsDone

func (n *Node) IsDone() bool

func (*Node) ReadDoneCount

func (n *Node) ReadDoneCount() int

func (*Node) ReadRetriedAt

func (n *Node) ReadRetriedAt() time.Time

func (*Node) ReadRetryCount

func (n *Node) ReadRetryCount() int

func (*Node) ReadStatus

func (n *Node) ReadStatus() NodeStatus

ReadStatus reads the status of a node.

func (*Node) SetRetriedAt

func (n *Node) SetRetriedAt(retriedAt time.Time)

type NodeState

type NodeState struct {
	Status     NodeStatus
	Log        string
	StartedAt  time.Time
	FinishedAt time.Time
	RetryCount int
	RetriedAt  time.Time
	DoneCount  int
	Error      error
}

NodeState is the state of a node.

type NodeStatus

type NodeStatus int
const (
	NodeStatus_None NodeStatus = iota
	NodeStatus_Running
	NodeStatus_Error
	NodeStatus_Cancel
	NodeStatus_Success
	NodeStatus_Skipped
)

func (NodeStatus) String

func (s NodeStatus) String() string

type Scheduler

type Scheduler struct {
	*Config
	// contains filtered or unexported fields
}

Scheduler is a scheduler that runs a graph of steps.

func (*Scheduler) Cancel

func (sc *Scheduler) Cancel(g *ExecutionGraph)

Cancel sends -1 signal to all nodes.

func (*Scheduler) HandlerNode

func (sc *Scheduler) HandlerNode(name string) *Node

HandlerNode returns the handler node with the given name.

func (*Scheduler) IsCanceled

func (sc *Scheduler) IsCanceled() bool

IsCanceled returns true if the scheduler is canceled.

func (*Scheduler) Schedule

func (sc *Scheduler) Schedule(ctx context.Context, g *ExecutionGraph, done chan *Node) error

Schedule runs the graph of steps.

func (*Scheduler) Signal

func (sc *Scheduler) Signal(g *ExecutionGraph, sig os.Signal, done chan bool, allowOverride bool)

Signal sends a signal to the scheduler. for a node with repeat policy, it does not stop the node and wait to finish current run.

func (*Scheduler) Status

func (sc *Scheduler) Status(g *ExecutionGraph) SchedulerStatus

Status returns the status of the scheduler.

type SchedulerStatus

type SchedulerStatus int
const (
	SchedulerStatus_None SchedulerStatus = iota
	SchedulerStatus_Running
	SchedulerStatus_Error
	SchedulerStatus_Cancel
	SchedulerStatus_Success
	SchedulerStatus_Skipped_Unused
)

func (SchedulerStatus) String

func (s SchedulerStatus) String() string

Jump to

Keyboard shortcuts

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