Documentation
¶
Index ¶
- func AppendTemplateOIDs(templateID string, oids []TemplateOID)
- func TenantIDFromContext(ctx context.Context) string
- type Engine
- func (e *Engine) AddHeartbeatHook(hook HeartbeatHook)
- func (e *Engine) AgentAuthService() ports.AgentAuthService
- func (e *Engine) AgentMessenger() ports.AgentMessenger
- func (e *Engine) AgentRepo() ports.AgentRepository
- func (e *Engine) AuditService() ports.AuditService
- func (e *Engine) AuthMiddleware() echo.MiddlewareFunc
- func (e *Engine) CertDetailsRepo() ports.CertDetailsRepository
- func (e *Engine) Echo() *echo.Echo
- func (e *Engine) HeartbeatRepo() ports.HeartbeatRepository
- func (e *Engine) IncidentRepo() ports.IncidentRepository
- func (e *Engine) IncidentService() ports.IncidentService
- func (e *Engine) Init(ctx context.Context) error
- func (e *Engine) InvestigationService() ports.InvestigationService
- func (e *Engine) Logger() *slog.Logger
- func (e *Engine) MonitorRepo() ports.MonitorRepository
- func (e *Engine) MonitorService() ports.MonitorService
- func (e *Engine) NewMaintenanceWindowRepo() ports.MaintenanceWindowRepository
- func (e *Engine) OnMaintenanceExpired(hook MaintenanceExpiredHook)
- func (e *Engine) Pool() *pgxpool.Pool
- func (e *Engine) Registry() *registry.Registry
- func (e *Engine) Run(ctx context.Context) error
- func (e *Engine) SetIncidents(open, acknowledged int)
- func (e *Engine) SetMaintenanceTenantProvider(p MaintenanceTenantProvider)
- func (e *Engine) SetPostRegisterHook(hook handlers.PostRegisterHook)
- func (e *Engine) SetRateLimitOnReject(fn func(ip string))
- func (e *Engine) SetTenantValidator(v handlers.TenantValidator)
- func (e *Engine) Shutdown(ctx context.Context) error
- func (e *Engine) StatusPageRepo() ports.StatusPageRepository
- func (e *Engine) TenantMiddleware() echo.MiddlewareFunc
- type HeartbeatHook
- type MaintenanceExpiredHook
- type MaintenanceTenantProvider
- type TemplateOID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendTemplateOIDs ¶
func AppendTemplateOIDs(templateID string, oids []TemplateOID)
AppendTemplateOIDs adds OIDs to an existing device template by ID.
func TenantIDFromContext ¶
TenantIDFromContext extracts the tenant ID from a request context. Returns "default" if no tenant ID is set.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine wraps all application components and manages the lifecycle. Usage: New() -> (optional Registry().Register overrides) -> Init() -> Run()
func New ¶
New creates a new Engine, loading config, connecting to the database, creating all repositories, services, notifiers, and registering default modules. It does NOT call InitAll or start the server, allowing callers to register module overrides before initialization.
func (*Engine) AddHeartbeatHook ¶
func (e *Engine) AddHeartbeatHook(hook HeartbeatHook)
AddHeartbeatHook registers a hook to be called after each heartbeat is processed. Extensions can use this for post-processing heartbeat data.
func (*Engine) AgentAuthService ¶
func (e *Engine) AgentAuthService() ports.AgentAuthService
AgentAuthService returns the agent auth service for extensions.
func (*Engine) AgentMessenger ¶
func (e *Engine) AgentMessenger() ports.AgentMessenger
AgentMessenger returns the WebSocket hub as an AgentMessenger for extensions.
func (*Engine) AgentRepo ¶
func (e *Engine) AgentRepo() ports.AgentRepository
AgentRepo returns the agent repository for extensions.
func (*Engine) AuditService ¶
func (e *Engine) AuditService() ports.AuditService
AuditService returns the audit service for extensions.
func (*Engine) AuthMiddleware ¶
func (e *Engine) AuthMiddleware() echo.MiddlewareFunc
AuthMiddleware returns an Echo middleware that authenticates requests via session cookie and sets "user_id" in the Echo context. This is exposed so that external route groups (which cannot import internal packages) can reuse the same session-based auth that CE uses. Returns JSON 401 on failure.
func (*Engine) CertDetailsRepo ¶
func (e *Engine) CertDetailsRepo() ports.CertDetailsRepository
CertDetailsRepo returns the certificate details repository for extensions.
func (*Engine) HeartbeatRepo ¶
func (e *Engine) HeartbeatRepo() ports.HeartbeatRepository
HeartbeatRepo returns the heartbeat repository for extensions.
func (*Engine) IncidentRepo ¶
func (e *Engine) IncidentRepo() ports.IncidentRepository
IncidentRepo returns the incident repository for extensions.
func (*Engine) IncidentService ¶
func (e *Engine) IncidentService() ports.IncidentService
IncidentService returns the incident service for extensions.
func (*Engine) Init ¶
Init initializes all registered modules and registers HTTP routes. Call this after registering any module overrides.
func (*Engine) InvestigationService ¶
func (e *Engine) InvestigationService() ports.InvestigationService
InvestigationService returns the investigation service for extensions.
func (*Engine) MonitorRepo ¶
func (e *Engine) MonitorRepo() ports.MonitorRepository
MonitorRepo returns the monitor repository for extensions.
func (*Engine) MonitorService ¶
func (e *Engine) MonitorService() ports.MonitorService
MonitorService returns the monitor service for extensions.
func (*Engine) NewMaintenanceWindowRepo ¶
func (e *Engine) NewMaintenanceWindowRepo() ports.MaintenanceWindowRepository
NewMaintenanceWindowRepo returns the maintenance window repository. The repo is already wired into MonitorService during New(). Kept for compatibility.
func (*Engine) OnMaintenanceExpired ¶
func (e *Engine) OnMaintenanceExpired(hook MaintenanceExpiredHook)
OnMaintenanceExpired registers a hook called when a maintenance window expires with an offline agent. EE uses this for audit logging.
func (*Engine) SetIncidents ¶
SetIncidents updates the Prometheus incidents_active gauge.
func (*Engine) SetMaintenanceTenantProvider ¶
func (e *Engine) SetMaintenanceTenantProvider(p MaintenanceTenantProvider)
SetMaintenanceTenantProvider sets the provider for listing tenant IDs. When set, the background maintenance ticker iterates over all tenants instead of only the "default" tenant. EE sets this from the tenants table.
func (*Engine) SetPostRegisterHook ¶
func (e *Engine) SetPostRegisterHook(hook handlers.PostRegisterHook)
SetPostRegisterHook sets the hook for post-registration actions.
func (*Engine) SetRateLimitOnReject ¶
SetRateLimitOnReject sets the callback that the general rate limiter will invoke whenever a request is denied for exceeding the burst limit. The callback receives the client IP string. Pass nil to clear.
Must be called before Init() — the router constructs the limiter during Init and the callback value is captured at that point.
Use case: extension modules wire this to persistent block-list trackers (e.g. write to a blocked_ips table) without modifying the rate-limiter or middleware code paths.
func (*Engine) SetTenantValidator ¶
func (e *Engine) SetTenantValidator(v handlers.TenantValidator)
SetTenantValidator sets the hook for tenant-scoped registration. When set, registration requires a valid tenant_slug and creates users in the specified tenant rather than the default.
func (*Engine) StatusPageRepo ¶
func (e *Engine) StatusPageRepo() ports.StatusPageRepository
StatusPageRepo returns the status page repository for extensions.
func (*Engine) TenantMiddleware ¶
func (e *Engine) TenantMiddleware() echo.MiddlewareFunc
TenantMiddleware returns the tenant-scoping middleware that injects tenant_id into the request context. External route groups need this to ensure repository queries are correctly scoped by tenant.
type HeartbeatHook ¶
type HeartbeatHook func(ctx context.Context, agentID, monitorID uuid.UUID, payload *protocol.HeartbeatPayload)
HeartbeatHook is called after each heartbeat is processed. Extensions can use this to add custom post-processing.
type MaintenanceExpiredHook ¶
type MaintenanceExpiredHook func(ctx context.Context, mw *domain.MaintenanceWindow)
MaintenanceExpiredHook is called when a maintenance window expires with an offline agent. Extensions (e.g. EE) can use this for audit logging.
type MaintenanceTenantProvider ¶
MaintenanceTenantProvider returns all tenant IDs that have maintenance windows. Used by the background ticker to iterate over tenants for RLS-safe queries. If nil, only the "default" tenant is processed.