Help us shape the future of Go! Take the 2026 Go Developer Survey

callbacks

package
v0.9.22 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalHandlers []Handler

Functions

func AppendHandlers added in v0.3.4

func AppendHandlers(ctx context.Context, info *RunInfo, handlers ...Handler) context.Context

func EnsureRunInfo added in v0.3.27

func EnsureRunInfo(ctx context.Context, typ string, comp components.Component) context.Context

func InitCallbacks

func InitCallbacks(ctx context.Context, info *RunInfo, handlers ...Handler) context.Context

func On

func On[T any](ctx context.Context, inOut T, handle Handle[T], timing CallbackTiming, start bool) (context.Context, T)

func OnEndHandle

func OnEndHandle[T any](ctx context.Context, output T,
	runInfo *RunInfo, handlers []Handler) (context.Context, T)

func OnEndWithStreamOutputHandle

func OnEndWithStreamOutputHandle[T any](ctx context.Context, output *schema.StreamReader[T],
	runInfo *RunInfo, handlers []Handler) (context.Context, *schema.StreamReader[T])

func OnErrorHandle

func OnErrorHandle(ctx context.Context, err error,
	runInfo *RunInfo, handlers []Handler) (context.Context, error)

func OnStartHandle

func OnStartHandle[T any](ctx context.Context, input T,
	runInfo *RunInfo, handlers []Handler) (context.Context, T)

func OnStartWithStreamInputHandle

func OnStartWithStreamInputHandle[T any](ctx context.Context, input *schema.StreamReader[T],
	runInfo *RunInfo, handlers []Handler) (context.Context, *schema.StreamReader[T])

func OnWithStreamHandle added in v0.3.4

func OnWithStreamHandle[S any](
	ctx context.Context,
	inOut S,
	handlers []Handler,
	cpy func(int) []S,
	handle func(context.Context, Handler, S) context.Context) (context.Context, S)

func ReuseHandlers added in v0.3.4

func ReuseHandlers(ctx context.Context, info *RunInfo) context.Context

Types

type CallbackInput

type CallbackInput any

type CallbackOutput

type CallbackOutput any

type CallbackTiming

type CallbackTiming uint8

type CtxManagerKey

type CtxManagerKey struct{}

type CtxRunInfoKey added in v0.3.28

type CtxRunInfoKey struct{}

type Handle

type Handle[T any] func(context.Context, T, *RunInfo, []Handler) (context.Context, T)

func BuildOnEndHandleWithCopy added in v0.8.0

func BuildOnEndHandleWithCopy[T any](copyFn func(T, int) []T) Handle[T]

type Handler

type Handler interface {
	OnStart(ctx context.Context, info *RunInfo, input CallbackInput) context.Context
	OnEnd(ctx context.Context, info *RunInfo, output CallbackOutput) context.Context

	OnError(ctx context.Context, info *RunInfo, err error) context.Context

	OnStartWithStreamInput(ctx context.Context, info *RunInfo,
		input *schema.StreamReader[CallbackInput]) context.Context
	OnEndWithStreamOutput(ctx context.Context, info *RunInfo,
		output *schema.StreamReader[CallbackOutput]) context.Context
}

type RunInfo

type RunInfo struct {
	// Name is the graph node name for display purposes, not unique.
	// Passed from compose.WithNodeName().
	Name      string
	Type      string
	Component components.Component
}

type TimingChecker

type TimingChecker interface {
	Needed(ctx context.Context, info *RunInfo, timing CallbackTiming) bool
}

Jump to

Keyboard shortcuts

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