Documentation
¶
Overview ¶
Package daemon provides the core daemon bootstrapping and lifecycle management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingLogger is returned when logger is not provided ErrMissingLogger = errors.New("logger is required") // ErrMissingAPIHandler is returned when API handler is not provided ErrMissingAPIHandler = errors.New("API handler is required") // ErrManagerNotStarted is returned when trying to shutdown a manager that hasn't started ErrManagerNotStarted = errors.New("manager not started") // ErrServerStartFailed is returned when a server fails to start ErrServerStartFailed = errors.New("server failed to start") )
Functions ¶
func WaitForShutdown ¶
WaitForShutdown waits for interrupt/termination signals.
Types ¶
type Config ¶
type Config struct {
// Version is the build version
Version string
// ConfigPath is the path to the YAML config file
ConfigPath string
// ListenAddr is the HTTP server listen address
ListenAddr string
// Server timeouts
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxHeaderBytes int
// ShutdownTimeout is the graceful shutdown timeout
ShutdownTimeout time.Duration
}
Config holds daemon configuration.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon represents the xg2g daemon instance.
type Deps ¶ added in v1.6.0
type Deps struct {
// Logger is the structured logger for the daemon
Logger zerolog.Logger
// Config is the jobs configuration (OpenWebIF, EPG, etc.)
Config jobs.Config
// APIHandler is the HTTP handler for the API server
APIHandler http.Handler
// ProxyConfig contains proxy server configuration (if enabled)
ProxyConfig *ProxyConfig
// MetricsHandler is the HTTP handler for Prometheus metrics (if enabled)
MetricsHandler http.Handler
}
Deps contains dependencies required by the daemon Manager. This allows for clean dependency injection and easier testing.
type Manager ¶ added in v1.6.0
type Manager interface {
// Start starts all configured servers and blocks until shutdown
Start(ctx context.Context) error
// Shutdown gracefully shuts down all servers
Shutdown(ctx context.Context) error
// RegisterShutdownHook registers a function to be called during shutdown
RegisterShutdownHook(name string, hook ShutdownHook)
}
Manager manages the daemon lifecycle: starting servers, handling shutdown.
func NewManager ¶ added in v1.6.0
func NewManager(serverCfg config.ServerConfig, deps Deps) (Manager, error)
NewManager creates a new daemon manager with the given configuration and dependencies.
type ProxyConfig ¶ added in v1.6.0
type ProxyConfig struct {
// ListenAddr is the proxy listen address (e.g., ":18000")
ListenAddr string
// TargetURL is the upstream target URL (optional if StreamDetector is provided)
TargetURL string
// ReceiverHost is the receiver hostname/IP for Smart Detection fallback
ReceiverHost string
// StreamDetector enables smart port detection (8001 vs 17999)
StreamDetector *openwebif.StreamDetector
// Logger is the logger for the proxy
Logger zerolog.Logger
}
ProxyConfig holds proxy server configuration.
type ShutdownHook ¶ added in v1.7.0
ShutdownHook is a function that performs cleanup during graceful shutdown. Hooks are executed in reverse registration order (LIFO).