event

package
v2.8.1 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

View Source
const (
	// EventTypeContainerStart and the constants below enumerate Arcane event types.
	EventTypeContainerStart   EventType = "container.start"
	EventTypeContainerStop    EventType = "container.stop"
	EventTypeContainerRestart EventType = "container.restart"
	EventTypeContainerDelete  EventType = "container.delete"
	EventTypeContainerCreate  EventType = "container.create"
	EventTypeContainerScan    EventType = "container.scan"
	EventTypeContainerUpdate  EventType = "container.update"
	EventTypeContainerDeploy  EventType = "container.deploy"
	EventTypeContainerKill    EventType = "container.kill"
	EventTypeContainerPause   EventType = "container.pause"
	EventTypeContainerUnpause EventType = "container.unpause"
	EventTypeContainerError   EventType = "container.error"

	EventTypeImagePull              EventType = "image.pull"
	EventTypeImageLoad              EventType = "image.load"
	EventTypeImageTag               EventType = "image.tag"
	EventTypeImageCommit            EventType = "image.commit"
	EventTypeImageDelete            EventType = "image.delete"
	EventTypeImageScan              EventType = "image.scan"
	EventTypeImageError             EventType = "image.error"
	EventTypeImageVulnerabilityScan EventType = "image.vulnerability_scan"

	EventTypeProjectDeploy EventType = "project.deploy"
	EventTypeProjectDelete EventType = "project.delete"
	EventTypeProjectStart  EventType = "project.start"
	EventTypeProjectStop   EventType = "project.stop"
	EventTypeProjectCreate EventType = "project.create"
	EventTypeProjectUpdate EventType = "project.update"
	EventTypeProjectError  EventType = "project.error"

	EventTypeGitRepositoryCreate EventType = "git.repository.create"
	EventTypeGitRepositoryUpdate EventType = "git.repository.update"
	EventTypeGitRepositoryDelete EventType = "git.repository.delete"
	EventTypeGitRepositoryTest   EventType = "git.repository.test"
	EventTypeGitRepositoryError  EventType = "git.repository.error"

	EventTypeGitSyncCreate EventType = "git.sync.create"
	EventTypeGitSyncUpdate EventType = "git.sync.update"
	EventTypeGitSyncDelete EventType = "git.sync.delete"
	EventTypeGitSyncRun    EventType = "git.sync.run"
	EventTypeGitSyncError  EventType = "git.sync.error"

	EventTypeVolumeCreate EventType = "volume.create"
	EventTypeVolumeDelete EventType = "volume.delete"
	EventTypeVolumeError  EventType = "volume.error"

	EventTypeVolumeFileCreate      EventType = "volume.file.create"
	EventTypeVolumeFileDelete      EventType = "volume.file.delete"
	EventTypeVolumeFileUpload      EventType = "volume.file.upload"
	EventTypeVolumeFileUpdate      EventType = "volume.file.update"
	EventTypeVolumeWorkspaceUpdate EventType = "volume.workspace.update"

	EventTypeVolumeBackupCreate       EventType = "volume.backup.create"
	EventTypeVolumeBackupDelete       EventType = "volume.backup.delete"
	EventTypeVolumeBackupRestore      EventType = "volume.backup.restore"
	EventTypeVolumeBackupRestoreFiles EventType = "volume.backup.restore_files"
	EventTypeVolumeBackupDownload     EventType = "volume.backup.download"

	EventTypeNetworkCreate EventType = "network.create"
	EventTypeNetworkDelete EventType = "network.delete"
	EventTypeNetworkError  EventType = "network.error"

	EventTypeSystemPrune       EventType = "system.prune"
	EventTypeUserLogin         EventType = "user.login"
	EventTypeUserLogout        EventType = "user.logout"
	EventTypeFederatedExchange EventType = "federated.exchange"
	EventTypeSystemAutoUpdate  EventType = "system.auto_update"
	EventTypeSystemUpgrade     EventType = "system.upgrade"

	EventTypeEnvironmentCreate            EventType = "environment.create"
	EventTypeEnvironmentConnect           EventType = "environment.connect"
	EventTypeEnvironmentDisconnect        EventType = "environment.disconnect"
	EventTypeEnvironmentUpdate            EventType = "environment.update"
	EventTypeEnvironmentDelete            EventType = "environment.delete"
	EventTypeEnvironmentApiKeyRegenerated EventType = "environment.api_key.regenerated"
	EventTypeEnvironmentMTLSCAGenerated   EventType = "environment.mtls.ca_generated"
	EventTypeEnvironmentMTLSCertIssued    EventType = "environment.mtls.cert_issued"
	EventTypeEnvironmentMTLSEnroll        EventType = "environment.mtls.enroll"
	EventTypeEnvironmentMTLSDownload      EventType = "environment.mtls.download"

	EventTypeWebhookCreate  EventType = "webhook.create"
	EventTypeWebhookUpdate  EventType = "webhook.update"
	EventTypeWebhookDelete  EventType = "webhook.delete"
	EventTypeWebhookTrigger EventType = "webhook.trigger"

	// EventTypeNotificationSend is emitted for every notification delivery
	// attempt; severity is success or error depending on the send result.
	EventTypeNotificationSend EventType = "notification.send"

	// EventTypeLifecycleExecute is emitted by LifecycleService each time a
	// pre-deploy script runs. Severity is success on a clean exit and warning
	// on non-zero exit or timeout.
	EventTypeLifecycleExecute EventType = "lifecycle.execute"

	// EventSeverityInfo and the constants below enumerate event severities.
	EventSeverityInfo    EventSeverity = "info"
	EventSeverityWarning EventSeverity = "warning"
	EventSeverityError   EventSeverity = "error"
	EventSeveritySuccess EventSeverity = "success"
)

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          EventType     `json:"type"`
	Severity      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      database.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 Event added in v2.8.1

type Event struct {
	database.BaseModel

	Type          EventType     `json:"type" sortable:"true"`
	Severity      EventSeverity `json:"severity" sortable:"true"`
	Title         string        `json:"title" sortable:"true"`
	Description   string        `json:"description"`
	ResourceType  *string       `json:"resourceType,omitempty" sortable:"true"`
	ResourceID    *string       `json:"resourceId,omitempty" sortable:"true"`
	ResourceName  *string       `json:"resourceName,omitempty" sortable:"true"`
	UserID        *string       `json:"userId,omitempty" sortable:"true"`
	Username      *string       `json:"username,omitempty" sortable:"true"`
	EnvironmentID *string       `json:"environmentId,omitempty"`
	Metadata      database.JSON `json:"metadata,omitempty" gorm:"type:text"`
	Timestamp     time.Time     `json:"timestamp" sortable:"true"`
}

func (Event) TableName added in v2.8.1

func (Event) TableName() string

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) (*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 EventType, containerID, containerName, userID, username, environmentID string, metadata database.JSON) error

func (*EventService) LogErrorEvent

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

func (*EventService) LogImageEvent

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

func (*EventService) LogNetworkEvent

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

func (*EventService) LogProjectEvent

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

func (*EventService) LogUserEvent

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

func (*EventService) LogVolumeEvent

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

type EventSeverity added in v2.8.1

type EventSeverity string

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 EventType added in v2.8.1

type EventType string

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