Documentation
¶
Index ¶
- type Descriptor
- type ExtraInfo
- type Module
- type ModuleError
- type Registry
- func (r *Registry) All() map[string]Module
- func (r *Registry) Get(name string) (Module, bool)
- func (r *Registry) GetDescriptor(name string) (Descriptor, bool)
- func (r *Registry) InitAll(bus *eventbus.Bus) error
- func (r *Registry) Names() []string
- func (r *Registry) Register(m Module, d Descriptor)
- func (r *Registry) StartAll(ctx context.Context) error
- func (r *Registry) StatusAll() map[string]Status
- func (r *Registry) StopAll() error
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Descriptor ¶
type Descriptor struct {
Name string `json:"name"` // Unique module identifier
Version string `json:"version"` // Module version
Description string `json:"description"` // Human-readable description
Dependencies []string `json:"dependencies"` // Other modules this depends on
Optional bool `json:"optional"` // Whether module can be disabled
ConfigFile string `json:"config_file"` // Path to module's config file
}
Descriptor contains static metadata about a module
type Module ¶
type Module interface {
// Name returns the unique module identifier
// Examples: "login-monitor", "suricata-watcher", "feeds-sync"
Name() string
// Init initializes the module with the event bus
// Called once before Start
// Should set up internal state but NOT start background work
Init(bus *eventbus.Bus) error
// Start begins the module's background work
// Called after Init
// Should spawn goroutines for continuous work
// The context is cancelled when the daemon shuts down
Start(ctx context.Context) error
// Stop gracefully shuts down the module
// Called when daemon is stopping
// Should clean up resources and wait for goroutines to finish
Stop() error
// Status returns the current module status
// Called on demand for health checks and API responses
Status() Status
}
Module is the interface all nftban modules must implement
type ModuleError ¶
ModuleError wraps errors with module context
func (*ModuleError) Error ¶
func (e *ModuleError) Error() string
func (*ModuleError) Unwrap ¶
func (e *ModuleError) Unwrap() error
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all registered modules
func (*Registry) GetDescriptor ¶
func (r *Registry) GetDescriptor(name string) (Descriptor, bool)
GetDescriptor retrieves a module descriptor by name
func (*Registry) Register ¶
func (r *Registry) Register(m Module, d Descriptor)
Register adds a module to the registry
type Status ¶
type Status struct {
Name string `json:"name"` // Module name
Enabled bool `json:"enabled"` // Whether module is enabled in config
Running bool `json:"running"` // Whether module is currently running
Healthy bool `json:"healthy"` // Whether module is functioning correctly
LastRun time.Time `json:"last_run"` // Last time module performed its main task
LastError string `json:"last_error"` // Last error message (empty if none)
ErrorCount int `json:"error_count"` // Total errors since start
EventCount int64 `json:"event_count"` // Total events processed
StartTime time.Time `json:"start_time"` // When module was started
Uptime string `json:"uptime"` // Human-readable uptime
Extra ExtraInfo `json:"extra"` // Module-specific status info
}
Status contains runtime status information for a module
func (*Status) MarkRunning ¶
func (s *Status) MarkRunning()
MarkRunning updates status to indicate module is running
func (*Status) MarkStopped ¶
func (s *Status) MarkStopped()
MarkStopped updates status to indicate module is stopped
func (*Status) RecordEvent ¶
func (s *Status) RecordEvent()
RecordEvent increments the event counter
func (*Status) UpdateUptime ¶
func (s *Status) UpdateUptime()
UpdateUptime calculates and updates the uptime string
Click to show internal directories.
Click to hide internal directories.