lightbringer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LightbringerTOML

type LightbringerTOML struct {
	GossipEntrypoint string
	Storage          string
	RpcAddr          string
	GrpcAddr         string

	// Optional sections
	InfluxdbHost     string
	InfluxdbDatabase string
	InfluxdbToken    string

	BlockConfirmRpcHTTP string
	BlockConfirmRpcWS   string

	// Quiet emits [log] quiet = true so Lightbringer logs at Warn level only.
	Quiet bool
}

LightbringerTOML represents the Lightbringer.toml structure that Lightbringer expects. This mirrors the Rust ConfigRaw struct in the Lightbringer source.

func (*LightbringerTOML) GenerateTOML

func (c *LightbringerTOML) GenerateTOML() string

GenerateTOML produces a valid Lightbringer.toml string from the config.

func (*LightbringerTOML) Validate

func (c *LightbringerTOML) Validate() error

Validate checks that required fields are present and well-formed.

func (*LightbringerTOML) WriteConfigFile

func (c *LightbringerTOML) WriteConfigFile(dir string) (string, error)

WriteConfigFile writes Lightbringer.toml to the given directory using an atomic write pattern (write to temp file, then rename) to prevent partial writes.

type Manager

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

Manager handles the lifecycle of a Lightbringer child process: config generation, spawning, log capture, health checking, and shutdown.

func NewManager

func NewManager(cfg ManagerConfig) *Manager

NewManager creates a new Lightbringer process manager.

func (*Manager) Done

func (m *Manager) Done() <-chan struct{}

Done returns a channel that is closed when the Lightbringer process exits. Returns nil if Start has not been called.

func (*Manager) IsRunning

func (m *Manager) IsRunning() bool

IsRunning returns true if the Lightbringer process is currently running.

func (*Manager) MonitorAndRestart

func (m *Manager) MonitorAndRestart(stopCh <-chan struct{}, maxRetries int)

MonitorAndRestart watches for unexpected Lightbringer exits and restarts with exponential backoff. Stops monitoring when stopCh is closed. maxRetries=0 means unlimited retries. Returns when stopped or max retries exceeded.

func (*Manager) Pid

func (m *Manager) Pid() int

Pid returns the PID of the running Lightbringer process, or 0 if not running.

func (*Manager) Start

func (m *Manager) Start() error

Start spawns the Lightbringer process and begins capturing its output. On Linux, Pdeathsig ensures the kernel sends SIGTERM to Lightbringer if Mithril exits for any reason (including os.Exit, SIGKILL, panic).

func (*Manager) Stop

func (m *Manager) Stop(timeout time.Duration) error

Stop sends SIGTERM to the Lightbringer process and waits for it to exit. If the process doesn't exit within the timeout, it sends SIGKILL.

func (*Manager) WaitReady

func (m *Manager) WaitReady(timeout time.Duration) error

WaitReady polls the gRPC endpoint until it accepts a TCP connection, or the timeout expires.

func (*Manager) WriteConfig

func (m *Manager) WriteConfig() (string, error)

WriteConfig generates Lightbringer.toml in the configured directory. Returns an error if required fields are missing.

type ManagerConfig

type ManagerConfig struct {
	BinaryPath string
	ConfigDir  string
	GrpcAddr   string
	TOML       LightbringerTOML
	LogWriter  io.Writer // where captured stdout/stderr is written
}

ManagerConfig holds the parameters needed to create a Manager.

Jump to

Keyboard shortcuts

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