Documentation
¶
Index ¶
- func WriteConfig(path string, cfg *Config) error
- type Config
- type Connector
- func (c *Connector) Close() error
- func (c *Connector) ConnectInterface(name string) (*rpc.NetworkClient, error)
- func (c *Connector) ControlClient() *outboard_v1alpha.OutboardControlClient
- func (c *Connector) Detach() error
- func (c *Connector) IsRunning() bool
- func (c *Connector) PID() (int, error)
- func (c *Connector) RPCState() *rpc.State
- func (c *Connector) Reconnect(ctx context.Context) error
- func (c *Connector) Start(ctx context.Context) error
- func (c *Connector) StartOrReconnect(ctx context.Context) error
- func (c *Connector) Stop(ctx context.Context) error
- type ConnectorConfig
- type RestartPolicy
- type Server
- func (s *Server) CheckVersion(ctx context.Context, state *outboard_v1alpha.OutboardControlCheckVersion) error
- func (s *Server) Close() error
- func (s *Server) Health(ctx context.Context, state *outboard_v1alpha.OutboardControlHealth) error
- func (s *Server) Logger() *slog.Logger
- func (s *Server) RPCState() *rpc.State
- func (s *Server) UpdateConfig(fn func(*Config)) error
- type ServerOption
- type TokenAuthenticator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteConfig ¶
WriteConfig writes an outboard config to the given path atomically. It uses a temp file and rename to ensure readers never see partial data.
Types ¶
type Config ¶
type Config struct {
Token string `json:"token"`
FIFOStdout string `json:"fifo_stdout"`
FIFOStderr string `json:"fifo_stderr"`
PID int `json:"pid,omitempty"`
RPCAddr string `json:"rpc_addr,omitempty"`
Ready bool `json:"ready,omitempty"`
}
Config is the shared configuration file format between the connector (parent) and the outboard process (child). The connector writes it before starting the process; the process reads it on startup and writes back its RPC address, PID, and ready flag.
func ReadConfig ¶
ReadConfig reads an outboard config from the given path.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector manages the lifecycle of an outboard process from the parent side. It handles starting, monitoring, restarting, and RPC connection to the child.
func NewConnector ¶
func NewConnector(log *slog.Logger, cfg ConnectorConfig) *Connector
NewConnector creates a new Connector for managing an outboard process.
func (*Connector) ConnectInterface ¶
func (c *Connector) ConnectInterface(name string) (*rpc.NetworkClient, error)
ConnectInterface connects to an additional RPC interface exposed by the outboard process.
func (*Connector) ControlClient ¶
func (c *Connector) ControlClient() *outboard_v1alpha.OutboardControlClient
ControlClient returns the OutboardControl RPC client.
func (*Connector) Detach ¶
Detach disconnects from the outboard process without stopping it. Call this during restart - the process keeps running and can be reconnected later.
func (*Connector) RPCState ¶
RPCState returns the parent-side RPC state for connecting to additional interfaces exposed by the outboard process.
func (*Connector) Reconnect ¶
Reconnect attempts to connect to an existing outboard process. Returns error if no process is running or reconnection fails.
func (*Connector) StartOrReconnect ¶
StartOrReconnect tries to reconnect to an existing outboard process first, falling back to starting a fresh process if reconnection fails.
type ConnectorConfig ¶
type ConnectorConfig struct {
Name string
BinaryPath string
Args []string
Env []string
DataPath string
RestartPolicy RestartPolicy
ReadyTimeout time.Duration // default 60s
}
ConnectorConfig configures how the connector manages the outboard process.
type RestartPolicy ¶
type RestartPolicy struct {
MaxRestarts int // 0 = unlimited
BackoffBase time.Duration // Base delay for exponential backoff
BackoffMax time.Duration // Maximum backoff delay
ResetWindow time.Duration // Time after which restart count resets
}
RestartPolicy configures automatic restart behavior.
func DefaultRestartPolicy ¶
func DefaultRestartPolicy() RestartPolicy
DefaultRestartPolicy returns a restart policy with unlimited restarts.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the outboard process side of the outboard framework. It reads the config written by the connector, sets up token-authenticated RPC, exposes the OutboardControl interface, and signals readiness.
func NewServer ¶
NewServer creates a new outboard Server by reading the config file at configPath. It creates a JSON slog handler writing to stdout (which the connector reads via FIFO), starts an RPC server with token authentication, and exposes the OutboardControl interface.
func (*Server) CheckVersion ¶
func (s *Server) CheckVersion(ctx context.Context, state *outboard_v1alpha.OutboardControlCheckVersion) error
CheckVersion implements OutboardControl.CheckVersion
func (*Server) Health ¶
func (s *Server) Health(ctx context.Context, state *outboard_v1alpha.OutboardControlHealth) error
Health implements OutboardControl.Health
func (*Server) RPCState ¶
RPCState returns the RPC state for registering additional domain-specific interfaces.
func (*Server) UpdateConfig ¶
UpdateConfig re-reads the config and updates the ready state. This is used internally after the process has finished initializing.
type ServerOption ¶
type ServerOption func(*Server)
ServerOption configures the outboard Server.
func WithShutdownFunc ¶
func WithShutdownFunc(fn func()) ServerOption
WithShutdownFunc sets a function to call when a version mismatch triggers shutdown.
func WithVersion ¶
func WithVersion(v uint64) ServerOption
WithVersion sets the version number reported by this outboard process.
type TokenAuthenticator ¶
type TokenAuthenticator struct {
// contains filtered or unexported fields
}
TokenAuthenticator implements rpc.Authenticator using a shared bearer token. It validates the Authorization header using constant-time comparison.
func NewTokenAuthenticator ¶
func NewTokenAuthenticator(token string) *TokenAuthenticator
NewTokenAuthenticator creates a new TokenAuthenticator with the given token.