Documentation
¶
Overview ¶
Package kern provides the Krewire Kernel — the imperative control plane that boots, supervises, and executes workloads. It is stdlib plus libs/core only; framework and krewire provide Module implementations.
Index ¶
- type Executor
- type Kernel
- func (k *Kernel) Boot(ctx context.Context) error
- func (k *Kernel) Execute(ctx context.Context, workload core.Workload) core.ExitCode
- func (k *Kernel) RegisterHandler(kind core.Kind, fn func(context.Context, core.Workload) core.ExitCode)
- func (k *Kernel) Shutdown(ctx context.Context) error
- func (k *Kernel) Use(modules ...Module) *Kernel
- type Module
- type Registry
- type Startable
- type Supervisor
- func (s *Supervisor) Add(m Startable)
- func (s *Supervisor) Health() map[string]error
- func (s *Supervisor) OnReload(fn func())
- func (s *Supervisor) Reload()
- func (s *Supervisor) Start(ctx context.Context) error
- func (s *Supervisor) Stop(ctx context.Context) error
- func (s *Supervisor) WithShutdownTimeout(d time.Duration) *Supervisor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kernel ¶
type Kernel struct {
Project core.Project
Registry *Registry
Supervisor *Supervisor
Executor Executor
// contains filtered or unexported fields
}
Kernel is the central executor for the Krewire ecosystem.
func (*Kernel) RegisterHandler ¶
func (k *Kernel) RegisterHandler(kind core.Kind, fn func(context.Context, core.Workload) core.ExitCode)
RegisterHandler registers a workload handler for the given kind.
type Module ¶
Module is a kernel module. Modules are registered by name and initialized against the kernel. Optionally, a module may implement DependsOn() []string to declare ordering.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds modules by name.
func (*Registry) Ordered ¶
Ordered returns modules topologically sorted by DependsOn() if implemented, otherwise in registration order (sorted by name for determinism).
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor manages long-running modules.
func NewSupervisor ¶
func NewSupervisor() *Supervisor
NewSupervisor creates a Supervisor with a 10s shutdown timeout.
func (*Supervisor) Add ¶
func (s *Supervisor) Add(m Startable)
Add registers a startable module for supervision.
func (*Supervisor) Health ¶
func (s *Supervisor) Health() map[string]error
Health returns a snapshot of module health.
func (*Supervisor) OnReload ¶
func (s *Supervisor) OnReload(fn func())
OnReload sets the hot-reload hook.
func (*Supervisor) Reload ¶
func (s *Supervisor) Reload()
Reload triggers the hot-reload hook if set.
func (*Supervisor) Start ¶
func (s *Supervisor) Start(ctx context.Context) error
Start starts all registered modules.
func (*Supervisor) Stop ¶
func (s *Supervisor) Stop(ctx context.Context) error
Stop stops all modules with the configured timeout.
func (*Supervisor) WithShutdownTimeout ¶
func (s *Supervisor) WithShutdownTimeout(d time.Duration) *Supervisor
WithShutdownTimeout sets the timeout used by Stop.