Help us shape the future of Go! Take the 2026 Go Developer Survey

event

package
v2.17.2 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

View Source
const (
	EventTypeContainerDie       EventType = "container.die"
	EventTypeContainerOOM       EventType = "container.oom"
	EventTypeContainerRename    EventType = "container.rename"
	EventTypeContainerUnhealthy EventType = "container.unhealthy"
	EventTypeImageUntag         EventType = "image.untag"
	EventTypeImageImport        EventType = "image.import"
	EventTypeImagePrune         EventType = "image.prune"
	EventTypeVolumePrune        EventType = "volume.prune"
	EventTypeNetworkPrune       EventType = "network.prune"

	// 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"
	EventTypeVolumeRename EventType = "volume.rename"
	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"
	EventTypeNetworkConnect    EventType = "network.connect"
	EventTypeNetworkDisconnect EventType = "network.disconnect"
	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"
)
View Source
const (
	DaemonEventBatchSize = 64
)

Variables

This section is empty.

Functions

func RegisterAgentEventIngestion

func RegisterAgentEventIngestion(g *echo.Group, eventService *EventService, resolveEnvironment func(context.Context, string) (string, error))

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 with the originating environment 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"`
	// contains filtered or unexported fields
}

type DeleteEventInput

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

type Event added in v2.8.1

type Event struct {
	database.BaseModel

	DeduplicationKey *string       `json:"-" gorm:"uniqueIndex:idx_events_deduplication_key"`
	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

DeleteEvent deletes an event.

func (*EventHandler) GetEventStats

GetEventStats returns global event counts grouped by severity.

func (*EventHandler) GetEventsByEnvironment

func (h *EventHandler) GetEventsByEnvironment(ctx context.Context, input *GetEventsByEnvironmentInput) (*handlerutil.Page[event.Event], error)

GetEventsByEnvironment returns events for a specific environment.

func (*EventHandler) ListEvents

func (h *EventHandler) ListEvents(ctx context.Context, input *ListEventsInput) (*handlerutil.Page[event.Event], 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) BeginComposeSuppressionWindow added in v2.11.0

func (s *EventService) BeginComposeSuppressionWindow(composeProject string) func()

BeginComposeSuppressionWindow covers daemon events labeled with the Compose project.

func (*EventService) BeginDockerResourceSuppressionWindow added in v2.11.0

func (s *EventService) BeginDockerResourceSuppressionWindow(resourceType, resourceID, resourceName string) func()

BeginDockerResourceSuppressionWindow covers a mutation for its full duration and cleanup grace.

func (*EventService) BeginDockerTypeSuppressionWindow added in v2.15.0

func (s *EventService) BeginDockerTypeSuppressionWindow(resourceType string) func()

BeginDockerTypeSuppressionWindow covers bulk daemon operations whose per-item IDs are unknown until they finish.

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) (event.SeverityCounts, error)

func (*EventService) GetEventsByEnvironmentPaginated

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

func (*EventService) IngestAgentEvent added in v2.11.0

func (s *EventService) IngestAgentEvent(ctx context.Context, environmentID string, req CreateEventRequest) (*Event, error)

IngestAgentEvent assigns the authenticated environment instead of trusting the agent's local ID.

func (*EventService) ListEventsPaginated

func (s *EventService) ListEventsPaginated(ctx context.Context, params pagination.QueryParams) ([]event.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

func (*EventService) MarkDockerExpectation added in v2.11.0

func (s *EventService) MarkDockerExpectation(resourceType, resourceID, resourceName string)

MarkDockerExpectation correlates subsequent daemon observations with a local Arcane action.

func (*EventService) RecordDockerEvent added in v2.11.0

func (s *EventService) RecordDockerEvent(ctx context.Context, msg events.Message)

RecordDockerEvent persists a daemon occurrence once across normal and overflow delivery.

func (*EventService) RunStreamProducer added in v2.11.0

func (s *EventService) RunStreamProducer(ctx context.Context, streamEvents chan<- event.StreamEvent)

RunStreamProducer signals committed event changes so clients can refresh their current query.

func (*EventService) SetDockerUpdatingContainers added in v2.11.0

func (s *EventService) SetDockerUpdatingContainers(source func() []string)

SetDockerUpdatingContainers supplies the updater's live identities without coupling domains.

func (*EventService) ShouldSuppressDaemonEvent added in v2.11.0

func (s *EventService) ShouldSuppressDaemonEvent(resourceType, actorID, actorName, composeProject string) bool

ShouldSuppressDaemonEvent reports whether a daemon observation matches a recent local action.

func (*EventService) Stop added in v2.17.0

func (s *EventService) Stop(ctx context.Context) error

Stop flushes queued daemon events; later observations are persisted directly.

func (*EventService) SubscribeDockerEvents added in v2.11.0

func (s *EventService) SubscribeDockerEvents(eventBus *bus.DockerEventBus) (run func(context.Context) error, cleanup func())

SubscribeDockerEvents prepares subscriptions before the watcher starts. The caller runs the returned worker and calls cleanup after joining it, including on failed startup.

type EventSeverity added in v2.8.1

type EventSeverity string

type EventType added in v2.8.1

type EventType string

type GetEventStatsInput

type GetEventStatsInput struct{}

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 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 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(service *EventService) *Module

New assembles the event routes around its service.

func (*Module) RegisterAgentRoutes

func (m *Module) RegisterAgentRoutes(group *echo.Group, resolveEnvironment func(context.Context, string) (string, error))

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.

Directories

Path Synopsis
children

Jump to

Keyboard shortcuts

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