dag

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 9 Imported by: 2

README

DAG

pipeline status coverage report

Create DAGs (Directed Acyclic Graph) and run jobs

Examples

See folder examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dag

type Dag struct {
	ID         string
	Name       string
	Jobs       map[string]*Job
	JobsOrder  []string
	Status     string
	CreatedTs  time.Time
	StartedTs  time.Time
	FinishedTs time.Time
}

Dag represents directed acyclic graph

func New

func New(name string, lggr *logrus.Entry, hooksLocal Hooks) *Dag

New creates new DAG

func (*Dag) CreateJob

func (dag *Dag) CreateJob(name string, task func() (map[string]string, error)) (*Job, error)

CreateJob adds a job to DAG

func (*Dag) GetJob

func (dag *Dag) GetJob(name string) Job

GetJob returns a job

func (*Dag) GetJobEdges

func (dag *Dag) GetJobEdges() []Edge

GetJobEdges returns a list of job names

func (*Dag) GetJobs

func (dag *Dag) GetJobs() []JobBasics

GetJobs returns a list of job names in order as they were added

func (*Dag) JobExists

func (dag *Dag) JobExists(name string) bool

JobExists tests if job exists

func (*Dag) Run

func (dag *Dag) Run()

Run starts the DAG main loop which controls the jobs

func (*Dag) ShowJobStatuses

func (dag *Dag) ShowJobStatuses()

type Edge

type Edge struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type Hooks

type Hooks struct {
	DagCreated         func(dag *Dag)
	DagStarted         func(dag *Dag)
	DagFinishedSuccess func(dag *Dag)
	DagFinishedFailed  func(dag *Dag)
	JobCreated         func(job *Job)
	JobStarted         func(job *Job)
	JobFinishedSuccess func(job *Job)
	JobFinishedFailed  func(job *Job)
}

Hooks define what happens on certain events like DAG start or JOB finished with error

type Job

type Job struct {
	ID   string
	Name string

	DagID      string
	ParentJobs []*Job
	ChildJobs  []*Job
	Status     string
	CreatedTs  time.Time
	StartedTs  time.Time
	FinishedTs time.Time
	Data       map[string]string
	Responses  map[string]string
	// contains filtered or unexported fields
}

func (*Job) AddData

func (job *Job) AddData(key string, value string)

AddData adds additional data to job

func (*Job) After

func (job *Job) After(parent *Job)

func (*Job) Then

func (parent *Job) Then(job *Job)

type JobBasics

type JobBasics struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	ParentJobsCount int    `json:"parentJobsCount"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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