event

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Overview

Package event owns persisted system events, manager ingestion, and event HTTP routes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAgentEventIngestion

func RegisterAgentEventIngestion(g *echo.Group, eventService *EventService, cfg *config.Config)

RegisterAgentEventIngestion registers the manager ingestion endpoint used by direct agents when no edge tunnel is active. This route is not part of the Huma/OpenAPI surface and authenticates only with the configured agent token.

func RegisterEvents

func RegisterEvents(api huma.API, eventService *EventService)

RegisterEvents registers all event management endpoints.

Types

type CreateEventRequest

type CreateEventRequest struct {
	Type          models.EventType     `json:"type"`
	Severity      models.EventSeverity `json:"severity,omitempty"`
	Title         string               `json:"title"`
	Description   string               `json:"description,omitempty"`
	ResourceType  *string              `json:"resourceType,omitempty"`
	ResourceID    *string              `json:"resourceId,omitempty"`
	ResourceName  *string              `json:"resourceName,omitempty"`
	UserID        *string              `json:"userId,omitempty"`
	Username      *string              `json:"username,omitempty"`
	EnvironmentID *string              `json:"environmentId,omitempty"`
	Metadata      models.JSON          `json:"metadata,omitempty"`
}

type DeleteEventInput

type DeleteEventInput struct {
	EventID string `path:"eventId" doc:"Event ID"`
}

type DeleteEventOutput

type DeleteEventOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

type Dependencies

type Dependencies struct {
	DB         *database.DB
	Config     *config.Config
	HTTPClient *http.Client
}

Dependencies are the collaborators the event domain needs.

type EventHandler

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

EventHandler handles event management endpoints.

func (*EventHandler) DeleteEvent

func (h *EventHandler) DeleteEvent(ctx context.Context, input *DeleteEventInput) (*DeleteEventOutput, error)

DeleteEvent deletes an event.

func (*EventHandler) GetEventStats

GetEventStats returns global event counts grouped by severity.

func (*EventHandler) GetEventsByEnvironment

GetEventsByEnvironment returns events for a specific environment.

func (*EventHandler) ListEvents

func (h *EventHandler) ListEvents(ctx context.Context, input *ListEventsInput) (*ListEventsOutput, error)

ListEvents returns a paginated list of events.

type EventService

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

func NewEventService

func NewEventService(db *database.DB, cfg *config.Config, httpClient *http.Client) *EventService

func (*EventService) CreateEvent

func (s *EventService) CreateEvent(ctx context.Context, req CreateEventRequest) (*models.Event, error)

func (*EventService) DeleteEvent

func (s *EventService) DeleteEvent(ctx context.Context, eventID string) error

func (*EventService) DeleteOldEvents

func (s *EventService) DeleteOldEvents(ctx context.Context, olderThan time.Duration) error

func (*EventService) GetEventSeverityCounts

func (s *EventService) GetEventSeverityCounts(ctx context.Context) (EventSeverityCounts, error)

func (*EventService) GetEventsByEnvironmentPaginated

func (s *EventService) GetEventsByEnvironmentPaginated(ctx context.Context, environmentID string, params pagination.QueryParams) ([]eventtypes.Event, pagination.Response, error)

func (*EventService) ListEventsPaginated

func (s *EventService) ListEventsPaginated(ctx context.Context, params pagination.QueryParams) ([]eventtypes.Event, pagination.Response, error)

func (*EventService) LogContainerEvent

func (s *EventService) LogContainerEvent(ctx context.Context, eventType models.EventType, containerID, containerName, userID, username, environmentID string, metadata models.JSON) error

func (*EventService) LogErrorEvent

func (s *EventService) LogErrorEvent(ctx context.Context, eventType models.EventType, resourceType, resourceID, resourceName, userID, username, environmentID string, err error, metadata models.JSON)

func (*EventService) LogImageEvent

func (s *EventService) LogImageEvent(ctx context.Context, eventType models.EventType, imageID, imageName, userID, username, environmentID string, metadata models.JSON) error

func (*EventService) LogNetworkEvent

func (s *EventService) LogNetworkEvent(ctx context.Context, eventType models.EventType, networkID, networkName, userID, username, environmentID string, metadata models.JSON) error

func (*EventService) LogProjectEvent

func (s *EventService) LogProjectEvent(ctx context.Context, eventType models.EventType, projectID, projectName, userID, username, environmentID string, metadata models.JSON) error

func (*EventService) LogUserEvent

func (s *EventService) LogUserEvent(ctx context.Context, eventType models.EventType, userID, username string, metadata models.JSON) error

func (*EventService) LogVolumeEvent

func (s *EventService) LogVolumeEvent(ctx context.Context, eventType models.EventType, volumeID, volumeName, userID, username, environmentID string, metadata models.JSON) error

type EventSeverityCounts

type EventSeverityCounts struct {
	Total   int64 `json:"total"`
	Info    int64 `json:"info"`
	Success int64 `json:"success"`
	Warning int64 `json:"warning"`
	Error   int64 `json:"error"`
}

EventSeverityCounts holds global event counts per severity.

type GetEventStatsInput

type GetEventStatsInput struct{}

type GetEventStatsOutput

type GetEventStatsOutput struct {
	Body base.ApiResponse[EventSeverityCounts]
}

type GetEventsByEnvironmentInput

type GetEventsByEnvironmentInput struct {
	EnvironmentID string `path:"environmentId" doc:"Environment ID"`
	Search        string `query:"search" doc:"Search query"`
	Sort          string `query:"sort" doc:"Column to sort by"`
	Order         string `query:"order" default:"asc" doc:"Sort direction"`
	Start         int    `query:"start" default:"0" doc:"Start index"`
	Limit         int    `query:"limit" default:"20" doc:"Limit"`
	Severity      string `query:"severity" doc:"Filter by severity"`
	Type          string `query:"type" doc:"Filter by event type (exact type or category prefix, comma-separated)"`
}

type GetEventsByEnvironmentOutput

type GetEventsByEnvironmentOutput struct {
	Body base.Paginated[eventtypes.Event]
}

type ListEventsInput

type ListEventsInput struct {
	Search   string `query:"search" doc:"Search query"`
	Sort     string `query:"sort" doc:"Column to sort by"`
	Order    string `query:"order" default:"asc" doc:"Sort direction"`
	Start    int    `query:"start" default:"0" doc:"Start index"`
	Limit    int    `query:"limit" default:"20" doc:"Limit"`
	Severity string `query:"severity" doc:"Filter by severity"`
	Type     string `query:"type" doc:"Filter by event type (exact type or category prefix, comma-separated)"`
}

type ListEventsOutput

type ListEventsOutput struct {
	Body base.Paginated[eventtypes.Event]
}

type Module

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

Module owns event persistence and both of the domain's HTTP surfaces.

func New

func New(deps Dependencies) *Module

New builds the event domain from its dependencies.

func (*Module) RegisterAgentRoutes

func (m *Module) RegisterAgentRoutes(group *echo.Group)

RegisterAgentRoutes mounts the token-authenticated direct-agent ingestion endpoint.

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API)

RegisterRoutes mounts the typed event endpoints for runtime and schema discovery.

func (*Module) Service

func (m *Module) Service() *EventService

Service exposes event operations to collaborating domains.

Jump to

Keyboard shortcuts

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