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)
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
23
24
typeinnerExecutorImplstruct {
24
-
concurrencyuint
25
-
pool*utils.Copool
26
-
wq*utils.Queue[*innerNode]
27
-
wg*sync.WaitGroup
28
-
profiler*profiler
29
-
mu*sync.Mutex
25
+
concurrencyuint
26
+
pool*utils.Copool
27
+
wq*utils.Queue[*innerNode]
28
+
wg*sync.WaitGroup
29
+
profiler*profiler
30
+
tracer*tracer
31
+
panicHandlerfunc(taskstring, rinterface{})
32
+
mu*sync.Mutex
30
33
}
31
34
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
-
ifconcurrency==0 {
35
-
panic("executor concurrency cannot be zero")
35
+
// Option configures executor behavior.
36
+
typeOptionfunc(*innerExecutorImpl)
37
+
38
+
// WithProfiler enables flame graph profiling for task execution analysis.
0 commit comments