You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -156,6 +156,30 @@ ok github.com/noneback/go-taskflow/benchmark 5.606s
156
156
157
157
Conditional nodes in go-taskflow behave similarly to those in [taskflow-cpp](https://github.com/taskflow/taskflow). They participate in both conditional control and looping. To avoid common pitfalls, refer to the [Conditional Tasking documentation](https://taskflow.github.io/taskflow/ConditionalTasking.html).
158
158
159
+
## Executor Options
160
+
161
+
`NewExecutor` accepts functional options to configure behavior:
gtf.WithPanicHandler(func(task string, r interface{}) {
171
+
log.Printf("task %s panicked: %v", task, r)
172
+
}),
173
+
)
174
+
```
175
+
176
+
| Option | Description |
177
+
|:---|:---|
178
+
|`WithConcurrency(n uint)`| Set max goroutine concurrency (overrides positional arg). Enables `NewExecutor(0, WithConcurrency(n))` style. |
179
+
|`WithProfiler()`| Enable flamegraph profiling. Required before calling `executor.Profile()`. |
180
+
|`WithTracer()`| Enable Chrome Trace recording. Required before calling `executor.Trace()`. |
181
+
|`WithPanicHandler(fn)`| Custom panic handler invoked on task panic. Replaces default log output. Graph is still canceled. |
182
+
159
183
## Error Handling in go-taskflow
160
184
161
185
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.
The output is in [Chrome Trace Event format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU). Open it in `chrome://tracing` or [Perfetto UI](https://ui.perfetto.dev/) for visualization.
253
+
204
254
## Stargazer
205
255
206
256
[](https://star-history.com/#noneback/go-taskflow&Date)
Copy file name to clipboardExpand all lines: executor.go
+61-27Lines changed: 61 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ import (
17
17
typeExecutorinterface {
18
18
Wait() // Wait block until all tasks finished
19
19
Profile(w io.Writer) error// Profile write flame graph raw text into w
20
+
Trace(w io.Writer) error// Trace write Chrome Trace Event data into w
20
21
Run(tf*TaskFlow) Executor// Run start to schedule and execute taskflow
21
22
}
22
23
@@ -26,23 +27,27 @@ type innerExecutorImpl struct {
26
27
wq*utils.Queue[*innerNode]
27
28
wg*sync.WaitGroup
28
29
profiler*profiler
30
+
tracer*tracer
29
31
mu*sync.Mutex
30
32
}
31
33
32
-
// NewExecutor return a Executor with a specified max goroutine concurrency(recommend a value bigger than Runtime.NumCPU, **MUST** bigger than num(subflows). )
33
-
funcNewExecutor(concurrencyuint) Executor {
34
+
// NewExecutor returns an Executor with the specified concurrency and options.
35
+
// concurrency must be > 0. Recommend concurrency > runtime.NumCPU and MUST > num(subflows).
0 commit comments