node

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package node provides reusable built-in node implementations for the graph engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delay

func Delay[S any](cfg DelayConfig) graph.NodeFunc[S]

Delay pauses execution for cfg.Duration, then returns state unchanged. Respects context cancellation.

func HTTP

func HTTP[S any](cfg HTTPConfig[S]) graph.NodeFunc[S]

HTTP builds a NodeFunc that makes an outbound HTTP call.

func Noop

func Noop[S any](_ context.Context, state S) (S, error)

Noop returns the state unchanged. Useful as a placeholder or synchronisation point.

func NoopFunc

func NoopFunc[S any]() graph.NodeFunc[S]

NoopFunc returns a named NodeFunc that does nothing. Identical to Noop but satisfies graph.NodeFunc[S] without a type assertion.

func Transform

func Transform[S any](fn TransformFunc[S]) graph.NodeFunc[S]

Transform wraps a pure TransformFunc as a NodeFunc (ctx is ignored).

Types

type DelayConfig

type DelayConfig struct {
	Duration time.Duration
}

DelayConfig configures a Delay node.

type HTTPConfig

type HTTPConfig[S any] struct {
	Method  string         // GET, POST, …
	URL     string         // static URL; use URLFunc for dynamic
	URLFunc func(S) string // overrides URL if set
	Timeout time.Duration

	// BuildRequest lets callers customise headers and body from state.
	// If nil, a JSON-encoded state is used as the body for non-GET methods.
	BuildRequest func(ctx context.Context, state S, req *http.Request) error

	// ParseResponse merges the HTTP response into state.
	// If nil, the response body is discarded.
	ParseResponse func(ctx context.Context, state S, resp *http.Response) (S, error)
}

HTTPConfig configures an HTTP node.

type TransformFunc

type TransformFunc[S any] func(state S) (S, error)

TransformFunc is a pure function that maps one state to another.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL