A lightweight DAG (Directed Acyclic Graph) execution framework for Go, ported from C++ CGraph-lite library.
- 🚀 Lightweight DAG execution framework
- 🔄 Thread-safe parameter sharing between nodes
- ⚡ Concurrent execution with worker pool
- 🏗️ Easy-to-use builder pattern for pipeline construction
- 🔧 Compatible with original C++ CGraph-lite interface
package main
import "fmt"
// Define your custom node
type MyNode struct {
BaseGElement
}
func (n *MyNode) Run() *CStatus {
fmt.Printf("%s: Hello World!\n", n.GetName())
return NewCStatus()
}
func main() {
// Create pipeline
pipeline := Factory.Create()
// Register nodes
node := &MyNode{}
pipeline.RegisterGElement(node, []GElement{}, "MyNode")
// Execute
pipeline.Process(1)
// Cleanup
Factory.Remove(pipeline)
}
See T02_Param.go
for a complete example of sharing parameters between nodes.
T01_Simple.go
- Basic node execution exampleT02_Param.go
- Parameter sharing between nodes example
go get github.com/AsunaU2/GoCGraph
go build .
# Run simple example
go run T01_Simple.go go_cgraph_lite.go
# Run parameter example
go run T02_Param.go go_cgraph_lite.go
Basic execution unit in the DAG. Implement the Run()
method to define your logic.
Manages the entire DAG execution flow, handles dependencies and concurrent execution.
Thread-safe parameter sharing mechanism between nodes.
This project is inspired by and ported from the excellent CGraph-lite C++ library by ChunelFeng. We extend our heartfelt gratitude to the original author for creating such an elegant and efficient DAG execution framework.
MIT License
Pull requests are welcome! For major changes, please open an issue first.