MCPcopy Create free account
hub / github.com/DoNewsCode/core / ExampleDAG_run

Function ExampleDAG_run

dag/example_dag_run_test.go:12–30  ·  view source on GitHub ↗

This example shows how to pass results to the next vertex or the dag caller.

()

Source from the content-addressed store, hash-verified

10
11// This example shows how to pass results to the next vertex or the dag caller.
12func ExampleDAG_run() {
13 d := dag.New()
14 v1 := d.AddVertex(func(ctx context.Context) error {
15 ctxmeta.GetBaggage(ctx).Set("v1Result", "foo")
16 return nil
17 })
18 v2 := d.AddVertex(func(ctx context.Context) error {
19 v1Result, _ := ctxmeta.GetBaggage(ctx).Get("v1Result")
20 fmt.Println(v1Result)
21 return nil
22 })
23 d.AddEdge(v1, v2)
24
25 _, ctx := ctxmeta.Inject(context.Background())
26 d.Run(ctx)
27
28 // Output:
29 // foo
30}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
GetBaggageFunction · 0.92
InjectFunction · 0.92
AddVertexMethod · 0.80
AddEdgeMethod · 0.80
GetMethod · 0.65
SetMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected