hooks

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterProcessHook

type AfterProcessHook func(ctx *ProcessContext) error

AfterProcessHook executes after a node finishes processing a packet.

type AfterRouteHook

type AfterRouteHook func(ctx *RouteContext) error

type AfterSendHook

type AfterSendHook func(ctx *MessageContext) error

AfterSendHook executes after a packet has been dispatched by a node.

type BeforeProcessHook

type BeforeProcessHook func(ctx *ProcessContext) error

BeforeProcessHook executes before a node starts processing a packet.

type BeforeRouteHook

type BeforeRouteHook func(ctx *RouteContext) error

type BeforeSendHook

type BeforeSendHook func(ctx *MessageContext) error

BeforeSendHook executes prior to sending a packet from a node.

type GlobalPluginFactory

type GlobalPluginFactory func(broker *PluginBroker) error

GlobalPluginFactory installs global hooks into the broker.

type HookBundle

type HookBundle struct {
	TxCreated     []TxCreatedHook
	BeforeRoute   []BeforeRouteHook
	AfterRoute    []AfterRouteHook
	BeforeSend    []BeforeSendHook
	AfterSend     []AfterSendHook
	BeforeProcess []BeforeProcessHook
	AfterProcess  []AfterProcessHook
}

HookBundle groups multiple hook handlers that belong to one plugin.

type MessageContext

type MessageContext struct {
	Packet   *core.Packet
	NodeID   int
	TargetID int
	Cycle    int
}

MessageContext provides data for send/receive hook handlers.

type NodePluginFactory

type NodePluginFactory func(nodeID int, broker *PluginBroker) error

NodePluginFactory installs hooks scoped to a specific node ID.

type PluginBroker

type PluginBroker struct {
	// contains filtered or unexported fields
}

PluginBroker coordinates hook registration and triggering.

func NewPluginBroker

func NewPluginBroker() *PluginBroker

NewPluginBroker creates an empty broker instance.

func (*PluginBroker) EmitAfterProcess

func (p *PluginBroker) EmitAfterProcess(ctx *ProcessContext) error

EmitAfterProcess triggers OnAfterProcess hooks.

func (*PluginBroker) EmitAfterRoute

func (p *PluginBroker) EmitAfterRoute(ctx *RouteContext) error

func (*PluginBroker) EmitAfterSend

func (p *PluginBroker) EmitAfterSend(ctx *MessageContext) error

EmitAfterSend triggers OnAfterSend hooks.

func (*PluginBroker) EmitBeforeProcess

func (p *PluginBroker) EmitBeforeProcess(ctx *ProcessContext) error

EmitBeforeProcess triggers OnBeforeProcess hooks.

func (*PluginBroker) EmitBeforeRoute

func (p *PluginBroker) EmitBeforeRoute(ctx *RouteContext) error

func (*PluginBroker) EmitBeforeSend

func (p *PluginBroker) EmitBeforeSend(ctx *MessageContext) error

EmitBeforeSend triggers OnBeforeSend hooks.

func (*PluginBroker) EmitTxCreated

func (p *PluginBroker) EmitTxCreated(ctx *TxCreatedContext) error

EmitTxCreated triggers all registered transaction creation hooks.

func (*PluginBroker) ListAllPlugins

func (p *PluginBroker) ListAllPlugins() []PluginDescriptor

ListAllPlugins returns descriptors of every registered plugin.

func (*PluginBroker) ListPlugins

func (p *PluginBroker) ListPlugins(category PluginCategory) []PluginDescriptor

ListPlugins returns descriptors for plugins in the requested category.

func (*PluginBroker) RegisterAfterProcess

func (p *PluginBroker) RegisterAfterProcess(h AfterProcessHook)

RegisterAfterProcess registers a hook for the OnAfterProcess stage.

func (*PluginBroker) RegisterAfterRoute

func (p *PluginBroker) RegisterAfterRoute(h AfterRouteHook)

func (*PluginBroker) RegisterAfterSend

func (p *PluginBroker) RegisterAfterSend(h AfterSendHook)

RegisterAfterSend registers a hook for the OnAfterSend stage.

func (*PluginBroker) RegisterBeforeProcess

func (p *PluginBroker) RegisterBeforeProcess(h BeforeProcessHook)

RegisterBeforeProcess registers a hook for the OnBeforeProcess stage.

func (*PluginBroker) RegisterBeforeRoute

func (p *PluginBroker) RegisterBeforeRoute(h BeforeRouteHook)

func (*PluginBroker) RegisterBeforeSend

func (p *PluginBroker) RegisterBeforeSend(h BeforeSendHook)

RegisterBeforeSend registers a hook for the OnBeforeSend stage.

func (*PluginBroker) RegisterBundle

func (p *PluginBroker) RegisterBundle(desc PluginDescriptor, bundle HookBundle)

RegisterBundle registers a plugin descriptor together with all hook handlers.

func (*PluginBroker) RegisterPluginMetadata

func (p *PluginBroker) RegisterPluginMetadata(desc PluginDescriptor)

RegisterPluginMetadata stores plugin metadata without registering hooks.

func (*PluginBroker) RegisterTxCreated

func (p *PluginBroker) RegisterTxCreated(h TxCreatedHook)

RegisterTxCreated adds a new hook executed when a transaction is created.

type PluginCategory

type PluginCategory string

PluginCategory represents the high-level role of a plugin.

const (
	// PluginCategoryCapability covers node or link behavioural extensions.
	PluginCategoryCapability PluginCategory = "capability"
	// PluginCategoryVisualization covers UI, timeline, or monitoring plugins.
	PluginCategoryVisualization PluginCategory = "visualization"
	// PluginCategoryPolicy covers routing, flow control, or consistency policies.
	PluginCategoryPolicy PluginCategory = "policy"
	// PluginCategoryInstrumentation covers metrics, tracing, and diagnostics.
	PluginCategoryInstrumentation PluginCategory = "instrumentation"
)

type PluginDescriptor

type PluginDescriptor struct {
	Name        string
	Category    PluginCategory
	Description string
}

PluginDescriptor describes a plugin registered with the broker.

type ProcessContext

type ProcessContext struct {
	Packet      *core.Packet
	Transaction *core.Transaction
	Node        interface{}
	NodeID      int
	Cycle       int
}

ProcessContext provides data for process stage hooks.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry keeps plugin factories that can be activated via configuration.

func NewRegistry

func NewRegistry(broker *PluginBroker) *Registry

NewRegistry creates an empty plugin registry bound to a broker.

func (*Registry) Broker

func (r *Registry) Broker() *PluginBroker

Broker returns the underlying broker associated with the registry.

func (*Registry) Descriptor

func (r *Registry) Descriptor(name string) (PluginDescriptor, bool)

Descriptor returns metadata registered under the provided name.

func (*Registry) LoadForNode

func (r *Registry) LoadForNode(nodeID int, names []string) error

LoadForNode activates the requested node-scoped plugins.

func (*Registry) LoadGlobal

func (r *Registry) LoadGlobal(names []string) error

LoadGlobal activates the requested global plugins.

func (*Registry) RegisterGlobal

func (r *Registry) RegisterGlobal(name string, desc PluginDescriptor, factory GlobalPluginFactory) error

RegisterGlobal registers a global plugin factory.

func (*Registry) RegisterNode

func (r *Registry) RegisterNode(name string, desc PluginDescriptor, factory NodePluginFactory) error

RegisterNode registers a node-scoped plugin factory.

type RouteContext

type RouteContext struct {
	Packet        *core.Packet
	SourceNodeID  int
	DefaultTarget int
	TargetID      int
}

type TxCreatedContext

type TxCreatedContext struct {
	Packet      *core.Packet
	Transaction *core.Transaction
}

TxCreatedContext carries information for transaction creation hooks.

type TxCreatedHook

type TxCreatedHook func(ctx *TxCreatedContext) error

TxCreatedHook defines the signature for OnTxCreated plugins.

Jump to

Keyboard shortcuts

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