Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sword-jin/how-dagger-work
explain how dagger work in code
https://github.com/sword-jin/how-dagger-work
cue cuelang dagger go
Last synced: about 1 month ago
JSON representation
explain how dagger work in code
- Host: GitHub
- URL: https://github.com/sword-jin/how-dagger-work
- Owner: sword-jin
- Created: 2022-04-08T14:29:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-22T06:18:23.000Z (over 2 years ago)
- Last Synced: 2024-08-17T08:05:17.416Z (5 months ago)
- Topics: cue, cuelang, dagger, go
- Language: Go
- Homepage:
- Size: 268 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# how-dagger-work
## core idea
### 1. how cue-flow generate a dag
- basic-1.cue, no nest, no dependency
- basic-2.cue, has nest, no dependency
- pipeline.cue, has nest, has dependency```bash
cd cue-flow-dag
go run main.go basic-1.cue isTask
````flow` can generate some dependency trees like this:
```
#0 Pipeline.client."./".read.contents
#0 Pipeline.client."./_build".write.contents
#1 Pipeline.jobs.build
#2 Pipeline.jobs.test
#3 Pipeline.jobs.lint
```**core code**
-
### 2. how cue-flow execute a dag
```bash
cd cue-flow-execute
go run main.go deploy-site.cue
````flow` can execute a dag according to dependency trees, **Tasks belonging to the same level of height can be processed in parallel**
**core code**-
can describe a simple pseudo-code:
```go
// ...
for {
for _, t := range flow.tasks {
switch task.status {
case Waiting:
waiting = true
case Ready:
t.status = Running
// handle task
// if no err
t.status = Successfor _, t2 := range flow.tasks {
if t2.status == Waiting && t.IsReady() {
t2.status = Ready
}
}
}
}
}
// ...// Check task is ready for execute
func (t *Task) IsReady() bool {
for _, dep := range t.deps {
if dep.status != Success {
return false
}
}
return true
}```
### 3. real-world example
```bash
make test -B
make build -B
```