dag

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EXTENSIONS = []string{".yaml", ".yml"}

Functions

func EvalCondition

func EvalCondition(c *Condition) error

EvalCondition evaluates a single condition and checks the result.

func EvalConditions

func EvalConditions(cond []*Condition) error

EvalConditions evaluates a list of conditions and checks the results.

func NewContext

func NewContext(ctx context.Context, dag *DAG) context.Context

NewContext sets the current DAG to the context.

func ReadFile

func ReadFile(file string) (string, error)

Types

type BuildDAGOptions

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

type Condition

type Condition struct {
	Condition string
	Expected  string
}

Condition represents a condition to be evaluated by the agent.

func (*Condition) CheckResult

func (c *Condition) CheckResult(actualValue string) error

CheckResult checks if the actual value of the condition matches the expected value.

func (*Condition) Evaluate

func (c *Condition) Evaluate() (string, error)

Evaluate returns the actual value of the condition.

type ContinueOn

type ContinueOn struct {
	Failure bool
	Skipped bool
}

ContinueOn represents the conditions under which the step continues.

type DAG

type DAG struct {
	Location          string
	Group             string
	Name              string
	Schedule          []*Schedule
	StopSchedule      []*Schedule
	RestartSchedule   []*Schedule
	Description       string
	Env               []string
	LogDir            string
	HandlerOn         HandlerOn
	Steps             []*Step
	MailOn            *MailOn
	ErrorMail         *MailConfig
	InfoMail          *MailConfig
	Smtp              *SmtpConfig
	Delay             time.Duration
	RestartWait       time.Duration
	HistRetentionDays int
	Preconditions     []*Condition
	MaxActiveRuns     int
	Params            []string
	DefaultParams     string
	MaxCleanUpTime    time.Duration
	Tags              []string
}

DAG represents a DAG configuration.

func GetDAGFromContext

func GetDAGFromContext(ctx context.Context) *DAG

GetDAGFromContext returns the DAG from the current context.

func (*DAG) Clone

func (d *DAG) Clone() *DAG

func (*DAG) HasTag

func (d *DAG) HasTag(tag string) bool

func (*DAG) SockAddr

func (d *DAG) SockAddr() string

func (*DAG) String

func (d *DAG) String() string

type DAGBuilder

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

type DAGContextKey

type DAGContextKey struct{}

DAGContextKey is used as the key for storing the DAG in the context.

type ExecutorConfig

type ExecutorConfig struct {
	Type   string
	Config map[string]interface{}
}

ExecutorConfig represents the configuration for the executor of a step.

type HandlerOn

type HandlerOn struct {
	Failure *Step
	Success *Step
	Cancel  *Step
	Exit    *Step
}

type Loader

type Loader struct {
	BaseConfig string
}

Loader is a config loader.

func (*Loader) Load

func (cl *Loader) Load(f, params string) (*DAG, error)

Load loads config from file.

func (*Loader) LoadData

func (cl *Loader) LoadData(data []byte) (*DAG, error)

LoadData loads config from given data.

func (*Loader) LoadMetadata

func (cl *Loader) LoadMetadata(f string) (*DAG, error)

LoadMetadata loads config from file and returns only the headline data.

func (*Loader) LoadWithoutEval

func (cl *Loader) LoadWithoutEval(f string) (*DAG, error)

LoadWithoutEval loads config from file without evaluating env variables.

type MailConfig

type MailConfig struct {
	From       string
	To         string
	Prefix     string
	AttachLogs bool
}

type MailOn

type MailOn struct {
	Failure bool
	Success bool
}

type RepeatPolicy

type RepeatPolicy struct {
	Repeat   bool
	Interval time.Duration
}

RepeatPolicy represents the repeat policy for a step.

type RetryPolicy

type RetryPolicy struct {
	Limit    int
	Interval time.Duration
}

RetryPolicy represents the retry policy for a step.

type Schedule

type Schedule struct {
	Expression string
	Parsed     cron.Schedule
}

type SmtpConfig

type SmtpConfig struct {
	Host     string
	Port     string
	Username string
	Password string
}

type Step

type Step struct {
	Name            string
	Description     string
	Variables       []string
	OutputVariables *utils.SyncMap
	Dir             string
	ExecutorConfig  ExecutorConfig
	CmdWithArgs     string
	Command         string
	Script          string
	Stdout          string
	Stderr          string
	Output          string
	Args            []string
	Depends         []string
	ContinueOn      ContinueOn
	RetryPolicy     *RetryPolicy
	RepeatPolicy    RepeatPolicy
	MailOnError     bool
	Preconditions   []*Condition
	SignalOnStop    string
}

Step represents a step in a DAG.

func (*Step) String

func (s *Step) String() string

String returns a string representation of the step's properties.

Jump to

Keyboard shortcuts

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