Documentation
¶
Index ¶
- type Manager
- func (m *Manager) PruneCache(keepVersions int) error
- func (m *Manager) RegisterModuleService(srv *grpc.Server)
- func (m *Manager) Resolve(repoURL, version string) (*ModuleBinary, error)
- func (m *Manager) Spawn(ctx context.Context, bin *ModuleBinary) error
- func (m *Manager) StopAll(ctx context.Context) error
- func (m *Manager) TrackProxy(moduleID string, proxy *SidecarProxy)
- func (m *Manager) VerifyChecksum(bin *ModuleBinary, expected string) error
- type ModuleBinary
- type RestartPolicy
- type SidecarProxy
- func (p *SidecarProxy) Health(_ context.Context) error
- func (p *SidecarProxy) Info() contracts.ModuleInfo
- func (p *SidecarProxy) Init(_ context.Context) error
- func (p *SidecarProxy) Start(_ context.Context) error
- func (p *SidecarProxy) Stop(_ context.Context) error
- func (p *SidecarProxy) TrackProcess(cmd *exec.Cmd)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager spawns and tracks sidecar module processes.
func NewManager ¶
NewManager creates a module manager. meshAddr is the gRPC address modules should connect to. reg is the module registry for discovery. modMgr is the lifecycle manager for events/audit.
func (*Manager) PruneCache ¶
PruneCache removes old cached module binaries, keeping only the most recent keepVersions versions per module ID. Versions are sorted lexicographically (semver tags produced by `git describe` sort correctly this way). A keepVersions of 0 removes all cached versions. Call on startup to prevent unbounded cache growth.
func (*Manager) RegisterModuleService ¶
RegisterModuleService sets up the gRPC registration service.
func (*Manager) Resolve ¶
func (m *Manager) Resolve(repoURL, version string) (*ModuleBinary, error)
Resolve locates a module binary for the given repo and version. Resolution order: cache → build from source.
func (*Manager) Spawn ¶
func (m *Manager) Spawn(ctx context.Context, bin *ModuleBinary) error
Spawn starts a module binary as a child process.
func (*Manager) TrackProxy ¶
func (m *Manager) TrackProxy(moduleID string, proxy *SidecarProxy)
TrackProxy registers a SidecarProxy for health tracking. Called during gRPC registration so Spawn can attach the process.
func (*Manager) VerifyChecksum ¶
func (m *Manager) VerifyChecksum(bin *ModuleBinary, expected string) error
VerifyChecksum reads the binary at bin.Path, computes its SHA256 digest, and compares it against the expected hex string. Returns nil if they match or if expected is empty (backward compatible). Returns an error on mismatch or if the file cannot be read.
type ModuleBinary ¶
type ModuleBinary struct {
ID string
Version string
Path string
Repo string
RestartPolicy RestartPolicy
}
ModuleBinary is a resolved module binary ready to run.
type RestartPolicy ¶
type RestartPolicy string
RestartPolicy controls how the manager handles unexpected module exits.
const ( // RestartNever does not restart the module on exit. Default. RestartNever RestartPolicy = "never" // RestartOnFailure restarts the module only on non-zero exit codes. RestartOnFailure RestartPolicy = "on-failure" // RestartAlways restarts the module on any exit (including clean exit 0). RestartAlways RestartPolicy = "always" )
type SidecarProxy ¶
type SidecarProxy struct {
// contains filtered or unexported fields
}
SidecarProxy wraps a sidecar module's ModuleInfo so it satisfies contracts.Module for registry registration. The real module runs in a separate process — lifecycle methods here are no-ops because the sidecar process manages its own lifecycle.
Health is tracked via the sidecar process's exit status: after Spawn(), TrackProcess attaches the exec.Cmd so Health() can report the actual process state (running, exited, or crashed).
func NewSidecarProxy ¶
func NewSidecarProxy(info contracts.ModuleInfo) *SidecarProxy
NewSidecarProxy creates a registry-compatible proxy for a sidecar module.
func (*SidecarProxy) Health ¶
func (p *SidecarProxy) Health(_ context.Context) error
Health returns nil when the sidecar process is running, or an error describing the exit status (crashed, exited with non-zero code, etc.). Returns nil for proxies that haven't been attached to a process yet (registration order: proxy created before spawn).
func (*SidecarProxy) Info ¶
func (p *SidecarProxy) Info() contracts.ModuleInfo
func (*SidecarProxy) TrackProcess ¶
func (p *SidecarProxy) TrackProcess(cmd *exec.Cmd)
TrackProcess attaches the running process for health monitoring. startErr is the error from cmd.Start() — nil means the process started.