dag

package module
Version: v0.0.0-...-dd0c42b Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 8 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
	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

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

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL