Documentation
¶
Overview ¶
Package nodes_dispatch provides the `dispatch.run` action, which tries explicitly listed actions in order and returns the first successful result.
Typical use:
dispatch.run @{ members: [runtime.fail, runtime.const], payload: { value: "x" } }
Index ¶
Constants ¶
View Source
const ID = "nodes_dispatch"
Variables ¶
View Source
var Dispatch = action.New("dispatch.run", func(ctx context.Context, req DispatchReq) (any, error) { resolver := contracts.ActionResolverFromContext(ctx) if resolver == nil { return nil, xerr.Internal("dispatch: no action resolver in context") } var lastErr error for _, name := range req.Members { target, ok := resolver.Action(name) if !ok { lastErr = xerr.NotFound("dispatch: member not registered: " + name) continue } output, err := action.InvokeAny(ctx, target, req.Payload) if err == nil { return output, nil } lastErr = err } if lastErr == nil { lastErr = xerr.NotFound("dispatch: no member succeeded") } return nil, lastErr }).Description("Tries each explicitly listed action in order until one succeeds"). Tag("dispatch", "routing"). Build()
Functions ¶
Types ¶
type DispatchReq ¶
Click to show internal directories.
Click to hide internal directories.