daemon

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPortRequired is returned when GOZNP_PORT is not set.
	ErrPortRequired = ConfigError("GOZNP_PORT environment variable is required")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Adapter configuration
	Port     string // GOZNP_PORT (required)
	BaudRate int    // GOZNP_BAUD_RATE (default: 115200)

	// HTTP server configuration
	HTTPAddr string // GOZNP_HTTP_ADDR (default: :8080)

	// Logging configuration
	LogLevel string // GOZNP_LOG_LEVEL (default: info)

	// Device polling configuration
	PollInterval time.Duration // GOZNP_POLL_INTERVAL (default: 5m)

	// Message listener configuration
	ListenTimeout time.Duration // GOZNP_LISTEN_TIMEOUT (default: 100ms)

	// Network configuration
	PermitJoinDuration uint8 // GOZNP_PERMIT_JOIN_DURATION (default: 255 = always)
}

Config holds configuration for goznpd. All values are loaded from environment variables with reasonable defaults.

func Load

func Load() (*Config, error)

Load loads configuration from environment variables. Returns an error if required variables are missing.

func (*Config) ToSerialConfig

func (c *Config) ToSerialConfig() serial.Config

ToSerialConfig converts Config to serial.Config.

type ConfigError

type ConfigError string

ConfigError represents a configuration error.

func (ConfigError) Error

func (e ConfigError) Error() string

type Server

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

Server manages the HTTP server and associated components.

func NewServer

func NewServer(cfg *Config, adapter *adapter.Adapter, manager *state.Manager, eventBus *event.Bus, listener *message.Listener, logger *slog.Logger) *Server

NewServer creates a new daemon server.

func (*Server) GetAddr

func (s *Server) GetAddr() string

GetAddr returns the server's listen address.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the HTTP server.

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server. This blocks until the server is stopped.

Jump to

Keyboard shortcuts

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