events¶
Package events provides the event system for Mooncake execution lifecycle. Events are emitted during execution and consumed by subscribers for logging, artifacts, and observability.
Index¶
- type ArchiveExtractedData
- type AssertionData
- type ChannelPublisher
- func (p *ChannelPublisher) Close()
- func (p *ChannelPublisher) Flush()
- func (p *ChannelPublisher) Publish(event Event)
- func (p *ChannelPublisher) Subscribe(subscriber Subscriber) int
- func (p *ChannelPublisher) Unsubscribe(id int)
- type Event
- type EventType
- type FileCopiedData
- type FileDownloadedData
- type FileOperationData
- type FileRemovedData
- type LinkCreatedData
- type PermissionsChangedData
- type PlanLoadedData
- type PresetData
- type PrintData
- type Publisher
- func NewPublisher() Publisher
- func NewSyncPublisher() Publisher
- type RunCompletedData
- type RunStartedData
- type ServiceManagementData
- type StepCompletedData
- type StepFailedData
- type StepOutputData
- type StepSkippedData
- type StepStartedData
- type Subscriber
- type SyncPublisher
- func (p *SyncPublisher) Close()
- func (p *SyncPublisher) Flush()
- func (p *SyncPublisher) Publish(event Event)
- func (p *SyncPublisher) Subscribe(subscriber Subscriber) int
- func (p *SyncPublisher) Unsubscribe(id int)
- type TemplateRenderData
- type VarsLoadedData
- type VarsSetData
type ArchiveExtractedData¶
ArchiveExtractedData contains data for archive.extracted events
type ArchiveExtractedData struct {
Src string `json:"src"`
Dest string `json:"dest"`
Format string `json:"format"`
FilesExtracted int `json:"files_extracted"`
DirsCreated int `json:"dirs_created"`
BytesExtracted int64 `json:"bytes_extracted"`
StripComponents int `json:"strip_components,omitempty"`
DurationMs int64 `json:"duration_ms"`
DryRun bool `json:"dry_run"`
}
type AssertionData¶
AssertionData contains data for assert.passed and assert.failed events
type AssertionData struct {
Type string `json:"type"` // Assertion type: "command", "file", or "http"
Expected string `json:"expected"` // What was expected
Actual string `json:"actual"` // What was found
Failed bool `json:"failed"` // Whether the assertion failed
StepID string `json:"step_id,omitempty"` // Step ID (added by event bus)
}
type ChannelPublisher¶
ChannelPublisher implements Publisher using buffered channels
func (*ChannelPublisher) Close¶
Close closes the publisher and all subscriber channels
func (*ChannelPublisher) Flush¶
Flush waits for all pending events to be processed by subscribers
func (*ChannelPublisher) Publish¶
Publish sends an event to all subscribers This is non-blocking - if a subscriber's channel is full, the event is dropped
func (*ChannelPublisher) Subscribe¶
Subscribe adds a new subscriber and returns its ID
func (*ChannelPublisher) Unsubscribe¶
Unsubscribe removes a subscriber
type Event¶
Event represents a single event in the execution lifecycle
type Event struct {
Type EventType `json:"type"`
Timestamp time.Time `json:"timestamp"`
Data interface{} `json:"data"`
}
type EventType¶
EventType identifies the type of event
const (
EventRunStarted EventType = "run.started"
EventPlanLoaded EventType = "plan.loaded"
EventRunCompleted EventType = "run.completed"
)
Event types for step lifecycle
const (
EventStepStarted EventType = "step.started"
EventStepCompleted EventType = "step.completed"
EventStepSkipped EventType = "step.skipped"
EventStepFailed EventType = "step.failed"
)
Event types for output streaming
const (
EventStepStdout EventType = "step.stdout"
EventStepStderr EventType = "step.stderr"
EventStepDebug EventType = "step.debug"
)
Event types for file operations
const (
EventFileCreated EventType = "file.created"
EventFileUpdated EventType = "file.updated"
EventFileRemoved EventType = "file.removed"
EventFileCopied EventType = "file.copied"
EventFileDownloaded EventType = "file.downloaded"
EventDirCreated EventType = "directory.created"
EventDirRemoved EventType = "directory.removed"
EventLinkCreated EventType = "link.created"
EventPermissionsChanged EventType = "permissions.changed"
EventTemplateRender EventType = "template.rendered"
EventArchiveExtracted EventType = "archive.extracted"
)
const (
EventAssertPassed EventType = "assert.passed"
EventAssertFailed EventType = "assert.failed"
)
const (
EventPresetExpanded EventType = "preset.expanded"
EventPresetCompleted EventType = "preset.completed"
)
Event types for package management
Event types for service management
type FileCopiedData¶
FileCopiedData contains data for file.copied events
type FileCopiedData struct {
Src string `json:"src"`
Dest string `json:"dest"`
SizeBytes int64 `json:"size_bytes"`
Mode string `json:"mode"`
Checksum string `json:"checksum,omitempty"`
DryRun bool `json:"dry_run"`
}
type FileDownloadedData¶
FileDownloadedData contains data for file.downloaded events
type FileDownloadedData struct {
URL string `json:"url"`
Dest string `json:"dest"`
SizeBytes int64 `json:"size_bytes"`
Mode string `json:"mode"`
Checksum string `json:"checksum,omitempty"`
DryRun bool `json:"dry_run"`
}
type FileOperationData¶
FileOperationData contains data for file operation events
type FileOperationData struct {
Path string `json:"path"`
Mode string `json:"mode,omitempty"`
SizeBytes int64 `json:"size_bytes,omitempty"`
Changed bool `json:"changed"`
DryRun bool `json:"dry_run"`
}
type FileRemovedData¶
FileRemovedData contains data for file/directory removal events
type FileRemovedData struct {
Path string `json:"path"`
WasDir bool `json:"was_dir"`
SizeBytes int64 `json:"size_bytes,omitempty"`
DryRun bool `json:"dry_run"`
}
type LinkCreatedData¶
LinkCreatedData contains data for link creation events
type LinkCreatedData struct {
Src string `json:"src"`
Dest string `json:"dest"`
Type string `json:"type"` // "symlink" or "hardlink"
DryRun bool `json:"dry_run"`
}
type PermissionsChangedData¶
PermissionsChangedData contains data for permissions.changed events
type PermissionsChangedData struct {
Path string `json:"path"`
Mode string `json:"mode,omitempty"`
Owner string `json:"owner,omitempty"`
Group string `json:"group,omitempty"`
Recursive bool `json:"recursive"`
DryRun bool `json:"dry_run"`
}
type PlanLoadedData¶
PlanLoadedData contains data for plan.loaded events
type PlanLoadedData struct {
RootFile string `json:"root_file"`
TotalSteps int `json:"total_steps"`
Tags []string `json:"tags,omitempty"`
}
type PresetData¶
PresetData contains data for preset events
type PresetData struct {
Name string `json:"name"` // Preset name
Parameters map[string]interface{} `json:"parameters,omitempty"` // Parameters passed to preset
StepsCount int `json:"steps_count"` // Number of steps in preset
Changed bool `json:"changed,omitempty"` // Whether any step changed (only in completed event)
}
type PrintData¶
PrintData contains data for print.message events
type Publisher¶
Publisher publishes events to subscribers
type Publisher interface {
Publish(event Event)
Subscribe(subscriber Subscriber) int
Unsubscribe(id int)
Flush()
Close()
}
func NewPublisher¶
NewPublisher creates a new channel-based event publisher
func NewSyncPublisher¶
NewSyncPublisher creates a new synchronous event publisher for testing.
type RunCompletedData¶
RunCompletedData contains data for run.completed events
type RunCompletedData struct {
TotalSteps int `json:"total_steps"`
SuccessSteps int `json:"success_steps"`
FailedSteps int `json:"failed_steps"`
SkippedSteps int `json:"skipped_steps"`
ChangedSteps int `json:"changed_steps"`
DurationMs int64 `json:"duration_ms"`
Success bool `json:"success"`
ErrorMessage string `json:"error_message,omitempty"`
}
type RunStartedData¶
RunStartedData contains data for run.started events
type RunStartedData struct {
RootFile string `json:"root_file"`
Tags []string `json:"tags,omitempty"`
DryRun bool `json:"dry_run"`
TotalSteps int `json:"total_steps"`
}
type ServiceManagementData¶
ServiceManagementData contains data for service.managed events
type ServiceManagementData struct {
Service string `json:"service"` // Service name
State string `json:"state,omitempty"` // Desired state (started/stopped/restarted/reloaded)
Enabled *bool `json:"enabled,omitempty"` // Enabled status
Changed bool `json:"changed"` // Whether changes were made
Operations []string `json:"operations,omitempty"` // List of operations performed
DryRun bool `json:"dry_run"`
}
type StepCompletedData¶
StepCompletedData contains data for step.completed events
type StepCompletedData struct {
StepID string `json:"step_id"`
Name string `json:"name"`
Level int `json:"level"`
DurationMs int64 `json:"duration_ms"`
Changed bool `json:"changed"`
Result map[string]interface{} `json:"result,omitempty"`
Depth int `json:"depth,omitempty"` // Directory depth for filetree items
DryRun bool `json:"dry_run"`
}
type StepFailedData¶
StepFailedData contains data for step.failed events
type StepFailedData struct {
StepID string `json:"step_id"`
Name string `json:"name"`
Level int `json:"level"`
ErrorMessage string `json:"error_message"`
DurationMs int64 `json:"duration_ms"`
Depth int `json:"depth,omitempty"` // Directory depth for filetree items
DryRun bool `json:"dry_run"`
}
type StepOutputData¶
StepOutputData contains data for step.stdout/stderr events
type StepOutputData struct {
StepID string `json:"step_id"`
Stream string `json:"stream"` // "stdout" or "stderr"
Line string `json:"line"`
LineNumber int `json:"line_number"`
}
type StepSkippedData¶
StepSkippedData contains data for step.skipped events
type StepSkippedData struct {
StepID string `json:"step_id"`
Name string `json:"name"`
Level int `json:"level"`
Reason string `json:"reason"`
Depth int `json:"depth,omitempty"` // Directory depth for filetree items
}
type StepStartedData¶
StepStartedData contains data for step.started events
type StepStartedData struct {
StepID string `json:"step_id"`
Name string `json:"name"`
Level int `json:"level"`
GlobalStep int `json:"global_step"`
Action string `json:"action"`
Tags []string `json:"tags,omitempty"`
When string `json:"when,omitempty"`
Vars map[string]string `json:"vars,omitempty"`
Depth int `json:"depth,omitempty"` // Directory depth for filetree items
DryRun bool `json:"dry_run"`
}
type Subscriber¶
Subscriber receives events from a publisher
type SyncPublisher¶
SyncPublisher implements Publisher with synchronous event delivery. Events are delivered immediately via direct OnEvent() calls. This is useful for tests to avoid race conditions with async delivery.
func (*SyncPublisher) Close¶
Close closes the publisher.
func (*SyncPublisher) Flush¶
Flush is a no-op for SyncPublisher (already synchronous).
func (*SyncPublisher) Publish¶
Publish sends an event to all subscribers synchronously.
func (*SyncPublisher) Subscribe¶
Subscribe adds a new subscriber and returns its ID.
func (*SyncPublisher) Unsubscribe¶
Unsubscribe removes a subscriber.
type TemplateRenderData¶
TemplateRenderData contains data for template.rendered events
type TemplateRenderData struct {
TemplatePath string `json:"template_path"`
DestPath string `json:"dest_path"`
SizeBytes int64 `json:"size_bytes"`
Changed bool `json:"changed"`
DryRun bool `json:"dry_run"`
}
type VarsLoadedData¶
VarsLoadedData contains data for variables.loaded events
type VarsLoadedData struct {
FilePath string `json:"file_path"`
Count int `json:"count"`
Keys []string `json:"keys"`
DryRun bool `json:"dry_run"`
}
type VarsSetData¶
VarsSetData contains data for variables.set events
type VarsSetData struct {
Count int `json:"count"`
Keys []string `json:"keys"`
DryRun bool `json:"dry_run"`
}
Generated by gomarkdoc