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

hook

package
v0.55.0 Latest Latest
Warning

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

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

Documentation

Overview

Package hook provides the `@hook:name` directive, which attaches every named hook from the kernel registry to the compiled pipeline, and the hook.probe action that reads HookProbeKey from the context to prove a hook fired.

The bundle registers the reserved "hook.verify" hook, which sets HookProbeKey in the request context. Fixtures use it to confirm that @hook actually attached something.

Typical use:

@hook:hook.verify
{ test: "data" } -> hook.probe

Index

Constants

View Source
const ID = "hook"

Variables

View Source
var Directive = compiler.Directive{
	Name:    "hook",
	Example: "@hook:hook.verify",
	Handler: handleDirective,
}

Directive parses `@hook:name1,name2` and appends every name to meta["hooks"]. WrapPipeline consumes the list.

View Source
var HookProbeKey = xctx.NewKey[bool]("flow.hook.probe")

HookProbeKey is the context key set by the hook.verify hook. The probe action reads it; fixtures assert on the result.

Functions

func Bundle

func Bundle(_ map[string]string) compiler.Bundle

func ProbeAction

func ProbeAction() action.AnyAction

ProbeAction reads HookProbeKey from the context and returns it as part of the typed result. Used by fixtures to prove a hook ran.

Types

type ProbeRes

type ProbeRes struct {
	Payload      any  `json:"payload,omitempty"`
	HookVerified bool `json:"hook_verified"`
}

ProbeRes is the typed response. Keeping a concrete struct avoids per-call map allocations on the hot path.

Jump to

Keyboard shortcuts

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