百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

go-taskflow

> 编程语言
开源

一个纯粹的 Go 通用任务并行编程框架

636 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个纯粹的 Go 通用任务并行编程框架

go-taskflow

DeepWiki

go-taskflow is a general-purpose task-parallel programming framework for Go, inspired by taskflow-cpp. It leverages Go's native capabilities and simplicity, making it ideal for managing complex dependencies in concurrent tasks.

Features

  • High Extensibility: Easily extend the framework to adapt to various specific use cases.

  • Native Go Concurrency Model: Leverages Go's goroutines for efficient concurrent task execution.

  • User-Friendly Programming Interface: Simplifies complex task dependency management in Go.

  • Static, Subflow, Conditional, and Cyclic Tasking: Define static tasks, condition nodes, nested subflows, and cyclic flows to enhance modularity and programmability.

    Static Subflow Condition Cyclic
  • Priority Task Scheduling: Assign task priorities to ensure higher-priority tasks are executed first.

  • Built-in Visualization, Profiling and Tracing: Generate visual representations of tasks, profile task execution with flamegraph, and capture Chrome Trace events for timeline analysis.

Use Cases

  • Data Pipelines: Orchestrate data processing stages with complex dependencies.
  • AI Agent Workflow Automation: Define and execute AI agent workflows with clear sequences and dependency structures.
  • Parallel Graph Tasking: Execute graph-based tasks concurrently to maximize CPU utilization.

Installation

Import the latest version of go-taskflow using:

bash
go get -u github.com/noneback/go-taskflow

Documentation

DeepWiki Page

Quick Start

A MapReduce word-count pipeline with parallel mappers, hash-partitioned shuffle, and reducers:

…

For more examples, visit the examples directory.

Benchmark

The following benchmarks provide a rough estimate of pure scheduling overhead using empty task functions. Note that most realistic workloads are I/O-bound, and their performance cannot be accurately reflected by these results. For CPU-intensive tasks, consider using taskflow-cpp.

Benchmark naming: N{task_count}-C{concurrency} where concurrency is goroutine pool size.

…

Understanding Conditional Tasks

Conditional nodes in go-taskflow behave similarly to those in taskflow-cpp. They participate in both conditional control and looping. To avoid common pitfalls, refer to the Conditional Tasking documentation.

Executor Options

NewExecutor accepts functional options to configure behavior:

go
executor := gtf.NewExecutor(1000,
    gtf.WithProfiler(), // enable flamegraph profiling
    gtf.WithTracer(),   // enable Chrome Trace recording
)
Option Description
WithProfiler() Enable flamegraph profiling. Required before calling executor.Profile().
WithTracer() Enable Chrome Trace recording. Required before calling executor.Trace().

Error Handling in go-taskflow

In Go, errors are values, and it is the user's responsibility to handle them appropriately. Only unrecovered panic events are managed by the framework. If a panic occurs, the entire parent graph is canceled, leaving the remaining tasks incomplete. This behavior may evolve in the future. If you have suggestions, feel free to share them.

To prevent interruptions caused by panic, you can handle them manually when registering tasks:

go
tf.NewTask("not interrupt", func() {
    defer func() {
        if r := recover(); r != nil {
            // Handle the panic.
        }
    }()
    // User-defined logic.
})

Visualizing Taskflows

To generate a visual representation of a taskflow, use the Dump method:

go
if err := tf.Dump(os.Stdout); err != nil {
    log.Fatal(err)
}

The Dump method generates raw strings in DOT format. Use the dot tool to create a graph SVG.

Profiling Taskflows

To profile a taskflow, first enable the profiler with WithProfiler(), then call Profile:

go
executor := gtf.NewExecutor(1000, gtf.WithProfiler())
executor.Run(tf).Wait()

if err := executor.Profile(os.Stdout); err != nil {
    log.Fatal(err)
}

The Profile method generates raw strings in flamegraph format. Use the flamegraph tool to create a flamegraph SVG.

Tracing Taskflows

To trace a taskflow, first enable the tracer with WithTracer(), then call Trace:

go
executor := gtf.NewExecutor(1000, gtf.WithTracer())
executor.Run(tf).Wait()

if err := executor.Trace(os.Stdout); err != nil {
    log.Fatal(err)
}

The Trace method outputs JSON in Chrome Trace Event format. Open it in chrome://tracing or Perfetto UI for visualization.

Stargazer

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言