Documentation
¶
Index ¶
- type Event
- type EventBus
- func (eb *EventBus) Close()
- func (eb *EventBus) GetBuffer() []Event
- func (eb *EventBus) GetMetrics() *EventMetrics
- func (eb *EventBus) Publish(event Event) error
- func (eb *EventBus) RegisterHandler(eventType EventType, handler EventHandler)
- func (eb *EventBus) Subscribe(ctx context.Context, filter EventFilter, bufferSize int) *Subscription
- func (eb *EventBus) Unsubscribe(sub *Subscription)
- type EventBusInterface
- type EventFilter
- type EventHandler
- type EventMetrics
- type EventType
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
ID string `json:"id"`
Type EventType `json:"type"`
Timestamp time.Time `json:"timestamp"`
Source string `json:"source"`
Data map[string]interface{} `json:"data"`
Metadata map[string]string `json:"metadata,omitempty"`
Error error `json:"error,omitempty"`
UserID string `json:"user_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
Event represents a system event
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus manages event publishing and subscriptions
func (*EventBus) Close ¶
func (eb *EventBus) Close()
Close closes the event bus and all subscriptions
func (*EventBus) GetMetrics ¶
func (eb *EventBus) GetMetrics() *EventMetrics
GetMetrics returns current event bus metrics
func (*EventBus) RegisterHandler ¶
func (eb *EventBus) RegisterHandler(eventType EventType, handler EventHandler)
RegisterHandler registers a handler for specific event types
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(ctx context.Context, filter EventFilter, bufferSize int) *Subscription
Subscribe creates a new subscription with a filter
func (*EventBus) Unsubscribe ¶
func (eb *EventBus) Unsubscribe(sub *Subscription)
Unsubscribe removes a subscription
type EventBusInterface ¶ added in v1.1.0
type EventBusInterface interface {
Publish(event Event) error
Subscribe(ctx context.Context, filter EventFilter, bufferSize int) *Subscription
Unsubscribe(sub *Subscription)
RegisterHandler(eventType EventType, handler EventHandler)
GetMetrics() *EventMetrics
Close()
}
EventBusInterface defines the contract for event bus implementations
type EventFilter ¶
type EventFilter struct {
Types []EventType
Sources []string
MinTime *time.Time
MaxTime *time.Time
Metadata map[string]string
}
EventFilter defines criteria for event filtering
type EventHandler ¶
type EventHandler func(event Event)
EventHandler is a function that handles events
type EventMetrics ¶
type EventMetrics struct {
EventsPublished map[EventType]int64
EventsDelivered map[EventType]int64
SubscriptionCount int
ActiveHandlers int
// contains filtered or unexported fields
}
EventMetrics tracks event bus metrics
type EventType ¶
type EventType string
EventType represents the type of event
const ( // Discovery events EventDiscoveryStarted EventType = "discovery.started" EventDiscoveryProgress EventType = "discovery.progress" EventDiscoveryCompleted EventType = "discovery.completed" EventDiscoveryFailed EventType = "discovery.failed" EventResourceDiscovered EventType = "discovery.resource" // Drift detection events EventDriftDetectionStarted EventType = "drift.started" EventDriftDetectionProgress EventType = "drift.progress" EventDriftDetectionCompleted EventType = "drift.completed" EventDriftDetected EventType = "drift.detected" EventDriftResolved EventType = "drift.resolved" // Remediation events EventRemediationStarted EventType = "remediation.started" EventRemediationProgress EventType = "remediation.progress" EventRemediationCompleted EventType = "remediation.completed" EventRemediationFailed EventType = "remediation.failed" EventResourceDeleted EventType = "remediation.deleted" EventResourceImported EventType = "remediation.imported" // State management events EventStateBackupCreated EventType = "state.backup.created" EventStatePulled EventType = "state.pulled" EventStatePushed EventType = "state.pushed" EventStateValidated EventType = "state.validated" EventStateModified EventType = "state.modified" // System events EventCacheCleared EventType = "cache.cleared" EventCacheRefreshed EventType = "cache.refreshed" EventHealthCheck EventType = "health.check" EventConfigChanged EventType = "config.changed" EventAuditLog EventType = "audit.log" // Job events EventJobQueued EventType = "job.queued" EventJobStarted EventType = "job.started" EventJobCompleted EventType = "job.completed" EventJobFailed EventType = "job.failed" EventJobRetrying EventType = "job.retrying" // WebSocket events EventWSClientConnected EventType = "ws.connected" EventWSClientDisconnected EventType = "ws.disconnected" EventWSMessage EventType = "ws.message" )
type Subscription ¶
type Subscription struct {
ID string
Filter EventFilter
Channel chan Event
// contains filtered or unexported fields
}
Subscription represents a subscription to events
Click to show internal directories.
Click to hide internal directories.