Documentation
¶
Overview ¶
Package module defines the extension contracts used to customize engine bootstrap and lifecycle behavior.
Modules register host-scoped services, such as runtime library entries and encoding codecs, and can attach hooks that run during engine, plan, and session stages.
Index ¶
- type AfterCompileHook
- type AfterRunHook
- type BeforeCompileHook
- type BeforeRunHook
- type Bootstrap
- type EngineCloseHook
- type EngineHookRegistrar
- type EngineInitHook
- type HookRegistrar
- type HostContext
- type Module
- type PlanCloseHook
- type PlanHookRegistrar
- type SessionCloseHook
- type SessionHookRegistrar
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterCompileHook ¶
AfterCompileHook runs after each compilation attempt. Hooks run in LIFO order and receive the compilation error (if any).
type AfterRunHook ¶
AfterRunHook runs after each session run attempt. Hooks run in LIFO order, receive the run error (if any), and aggregate hook errors.
type BeforeCompileHook ¶
BeforeCompileHook runs before compilation starts. Hooks run in FIFO order and stop on the first error.
type BeforeRunHook ¶
BeforeRunHook runs before each session run. It can return a derived context for subsequent hooks and VM execution.
type Bootstrap ¶
type Bootstrap interface {
// Host returns the host-scoped registries and services that a module can
// populate during engine construction.
Host() HostContext
// Hooks returns the lifecycle hook registrars for the engine, plan, and
// session stages created from this engine.
Hooks() HookRegistrar
}
Bootstrap exposes the mutable engine bootstrap state passed to Module.Register.
type EngineCloseHook ¶
type EngineCloseHook func() error
EngineCloseHook runs during engine shutdown. Close hooks are executed in LIFO order and their errors are aggregated.
type EngineHookRegistrar ¶
type EngineHookRegistrar interface {
// OnInit registers a hook executed in FIFO order during engine
// initialization.
// A nil hook is ignored.
OnInit(hook EngineInitHook)
// OnClose registers a hook executed in LIFO order when engine
// construction fails or the engine is closed.
// A nil hook is ignored.
OnClose(hook EngineCloseHook)
}
EngineHookRegistrar registers hooks for engine initialization and shutdown.
type EngineInitHook ¶
type EngineInitHook func() error
EngineInitHook runs during engine initialization. Returning an error stops initialization immediately.
type HookRegistrar ¶
type HookRegistrar interface {
// Engine returns the registrar for engine initialization and shutdown
// hooks.
Engine() EngineHookRegistrar
// Plan returns the registrar for plan compilation and shutdown hooks.
Plan() PlanHookRegistrar
// Session returns the registrar for session run and shutdown hooks.
Session() SessionHookRegistrar
}
HookRegistrar provides access to lifecycle hook registrars for the engine, plan, and session stages created from a bootstrapped engine.
type HostContext ¶
type HostContext interface {
// Library returns the runtime library registry being assembled for the
// engine.
Library() runtime.Library
// Params returns the default parameter set inherited by sessions created
// from the engine.
Params() runtime.Params
// Encoding returns the codec registrar used to configure output encoding for
// the engine.
Encoding() encoding.CodecRegistrar
// Logger returns the engine logger used by the engine and inherited by
// sessions created from it.
Logger() logging.Logger
// FileSystem returns the file system used by the engine and derived
// executions.
FileSystem() fs.FileSystem
}
HostContext exposes the host-scoped registries and services that modules can configure during engine bootstrap.
type Module ¶
type Module interface {
// Name returns the stable identifier for this module.
Name() string
// Register mutates the engine bootstrap state for this module instance.
// Returning an error aborts engine construction.
Register(Bootstrap) error
}
Module defines an engine extension that participates in bootstrap.
Modules are passed to the engine during construction and can register host services, codecs, and lifecycle hooks before the engine is initialized.
type PlanCloseHook ¶
type PlanCloseHook func() error
PlanCloseHook runs when a plan is closed. Close hooks are executed in LIFO order and their errors are aggregated.
type PlanHookRegistrar ¶
type PlanHookRegistrar interface {
// BeforeCompile registers a hook executed in FIFO order before plan
// compilation starts.
// A nil hook is ignored.
BeforeCompile(hook BeforeCompileHook)
// AfterCompile registers a hook executed in LIFO order after each
// compilation attempt.
// It receives the compilation error (if any), and a nil hook is ignored.
AfterCompile(hook AfterCompileHook)
// OnClose registers a hook executed in LIFO order when a compiled plan is
// closed.
// A nil hook is ignored.
OnClose(hook PlanCloseHook)
}
PlanHookRegistrar registers hooks for plan compilation and shutdown.
type SessionCloseHook ¶
type SessionCloseHook func() error
SessionCloseHook runs when a session is closed. Close hooks are executed in LIFO order and their errors are aggregated.
type SessionHookRegistrar ¶
type SessionHookRegistrar interface {
// BeforeRun registers a hook executed in FIFO order before each session
// run.
// Hooks can replace the context passed to subsequent hooks and VM execution.
// A nil hook is ignored.
BeforeRun(hook BeforeRunHook)
// AfterRun registers a hook executed in LIFO order after each session run
// attempt.
// It receives the run error (if any), and a nil hook is ignored.
AfterRun(hook AfterRunHook)
// OnClose registers a hook executed in LIFO order when a session is
// closed.
// A nil hook is ignored.
OnClose(hook SessionCloseHook)
}
SessionHookRegistrar registers hooks for session execution and shutdown.