Documentation
¶
Overview ¶
Package daemon provides the core daemon runner for WarpDL. It manages the lifecycle of the download service including start, stop, and graceful shutdown capabilities.
Index ¶
Constants ¶
View Source
const ( // DefaultServiceName is the default Windows service name. DefaultServiceName = "WarpDL" // DefaultDisplayName is the default Windows service display name. DefaultDisplayName = "WarpDL Download Manager" // DefaultDescription is the default Windows service description. DefaultDescription = "High-performance parallel download manager" )
Service name constants for Windows service registration.
Variables ¶
View Source
var ( // ErrAlreadyRunning is returned when Start() is called on a running daemon. ErrAlreadyRunning = errors.New("daemon is already running") // ErrNotRunning is returned when Shutdown() is called on a stopped daemon. ErrNotRunning = errors.New("daemon is not running") // ErrShutdownTimeout is returned when shutdown exceeds the configured timeout. ErrShutdownTimeout = errors.New("shutdown timed out") )
Sentinel errors for the daemon runner.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ServiceName is the Windows service name.
ServiceName string
// DisplayName is the Windows service display name.
DisplayName string
// Port is the TCP port for fallback connections.
// Use 0 for an ephemeral port.
Port int
// ConfigDir is the directory for configuration files.
ConfigDir string
// ShutdownTimeout is the maximum time to wait for graceful shutdown.
// A zero value means no timeout.
ShutdownTimeout time.Duration
}
Config holds the configuration for the daemon runner.
type Dependencies ¶
type Dependencies struct {
// ListenerFactory creates network listeners.
// If nil, net.Listen is used.
ListenerFactory func(network, address string) (net.Listener, error)
// ShutdownFunc is called during shutdown to clean up resources.
// If nil, no cleanup function is called.
ShutdownFunc func() error
}
Dependencies holds the external dependencies for the daemon runner. This enables dependency injection for testing.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner manages the daemon lifecycle.
func New ¶
func New(config *Config, deps *Dependencies) *Runner
New creates a new daemon runner with the given configuration and dependencies. If config is nil, default values are used. If deps is nil, default dependencies (using net.Listen) are used.
Click to show internal directories.
Click to hide internal directories.