Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andy2046/rund
a DAG task dependency scheduler
https://github.com/andy2046/rund
dag directed-acyclic-graph task-runner task-scheduler
Last synced: about 1 month ago
JSON representation
a DAG task dependency scheduler
- Host: GitHub
- URL: https://github.com/andy2046/rund
- Owner: andy2046
- License: bsd-3-clause
- Created: 2019-05-11T06:04:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-17T08:27:42.000Z (over 5 years ago)
- Last Synced: 2024-06-21T21:02:45.539Z (6 months ago)
- Topics: dag, directed-acyclic-graph, task-runner, task-scheduler
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rund
[![GoDoc](https://godoc.org/github.com/andy2046/rund?status.svg)](https://godoc.org/github.com/andy2046/rund)
rund is a task dependency scheduler to run all tasks in parallel topological order, using the semantic of Directed Acyclic Graph.
## Install
```
go get github.com/andy2046/rund
```## Example
```go
r := rund.New()op1 := rund.NewFuncOperator(func() error {
fmt.Println("1 will run before 2 and 3")
return nil
})
op2 := rund.NewFuncOperator(func() error {
fmt.Println("2 and 3 will run in parallel before 4")
return nil
})
op3 := rund.NewFuncOperator(func() error {
fmt.Println("2 and 3 will run in parallel before 4")
return nil
})
op4 := rund.NewFuncOperator(func() error {
fmt.Println("4 will run after 2 and 3")
return errors.New("4 is broken")
})
op5 := rund.NewFuncOperator(func() error {
fmt.Println("5 will never run")
return nil
})r.AddNode("1", op1)
r.AddNode("2", op2)
r.AddNode("3", op3)
r.AddNode("4", op4)
r.AddNode("5", op5)r.AddEdge("1", "2")
r.AddEdge("1", "3")
r.AddEdge("2", "4")
r.AddEdge("3", "4")
r.AddEdge("4", "5")// 2
// / \
// 1 4 - 5
// \ /
// 3fmt.Printf("the result: %v\n", r.Run())
// Output:
// 1 will run before 2 and 3
// 2 and 3 will run in parallel before 4
// 2 and 3 will run in parallel before 4
// 4 will run after 2 and 3
// the result: 4 is broken```