Documentation
¶
Index ¶
- Constants
- func Send(path string, clientID int64, data interface{})
- func SendAlert(path string, clientID int64, title, message string, level EventLevel)
- func SendProgress(path string, clientID int64, percent, currentStep, totalSteps int, ...)
- func SendToPath(path string, data interface{})
- func SendToPathWithMetadata(path string, status string, data interface{}, metadata *EventMetadata)
- func SendToPathWithStatus(path string, status string, data interface{})
- func SendWithMetadata(path string, clientID int64, status string, data interface{}, ...)
- func SendWithStatus(path string, clientID int64, status string, data interface{})
- type AlertEvent
- type Event
- type EventHub
- func (hub *EventHub) Broadcast(path string, clientID int64, event interface{})
- func (hub *EventHub) BroadcastAll(event interface{})
- func (hub *EventHub) BroadcastPath(path string, event interface{})
- func (hub *EventHub) Subscribe(path string, clientID int64) chan interface{}
- func (hub *EventHub) Unsubscribe(path string, clientID int64)
- type EventLevel
- type EventMetadata
- type ProgressEvent
Constants ¶
const ( // Connection states StatusConnected = "connected" StatusDisconnected = "disconnected" StatusReconnecting = "reconnecting" // Information states StatusInfo = "info" StatusWarning = "warning" StatusError = "error" StatusSuccess = "success" StatusDebug = "debug" // Process states StatusStarted = "started" StatusProcessing = "processing" StatusCompleted = "completed" StatusCancelled = "cancelled" StatusPaused = "paused" StatusResumed = "resumed" // Data states StatusCreated = "created" StatusUpdated = "updated" StatusDeleted = "deleted" StatusArchived = "archived" // System states StatusHealthy = "healthy" StatusDegraded = "degraded" StatusMaintenance = "maintenance" )
Status constants for common event states
Variables ¶
This section is empty.
Functions ¶
func SendAlert ¶
func SendAlert(path string, clientID int64, title, message string, level EventLevel)
SendAlert sends an alert event to a specific client on a specific path
func SendProgress ¶
func SendProgress(path string, clientID int64, percent, currentStep, totalSteps int, description string)
SendProgress sends a progress update event to a specific client on a specific path
func SendToPath ¶
func SendToPath(path string, data interface{})
SendToPath sends an event to all clients subscribed to a specific path
func SendToPathWithMetadata ¶
func SendToPathWithMetadata(path string, status string, data interface{}, metadata *EventMetadata)
SendToPathWithMetadata sends an event with metadata to all clients on a specific path
func SendToPathWithStatus ¶
SendToPathWithStatus sends an event with a status to all clients on a specific path
func SendWithMetadata ¶
func SendWithMetadata(path string, clientID int64, status string, data interface{}, metadata *EventMetadata)
SendWithMetadata sends an event with full metadata to a specific client on a specific path
func SendWithStatus ¶
SendWithStatus sends an event with additional status metadata to a specific client on a specific path
Types ¶
type AlertEvent ¶
type AlertEvent struct {
Title string `json:"title"`
Message string `json:"message"`
Level string `json:"level"`
ActionURL string `json:"actionUrl,omitempty"`
Expiration time.Time `json:"expiration,omitempty"`
Time time.Time `json:"time"`
}
AlertEvent represents an alert or notification
type Event ¶
type Event struct {
ID string `json:"id"`
Status string `json:"status"`
Time time.Time `json:"time"`
Data interface{} `json:"data,omitempty"`
Metadata *EventMetadata `json:"metadata,omitempty"`
}
Event represents a server-sent event with metadata
type EventHub ¶
type EventHub struct {
// contains filtered or unexported fields
}
EventHub manages per-path and per-client event delivery
var EventHubInstance *EventHub
EventHubInstance is the central hub for managing connections and events. Ensure that this is initialized and injected by the application.
func (*EventHub) BroadcastAll ¶
func (hub *EventHub) BroadcastAll(event interface{})
BroadcastAll sends an event to all clients across all paths
func (*EventHub) BroadcastPath ¶
BroadcastPath sends an event to all clients subscribed to a specific path
func (*EventHub) Unsubscribe ¶
Unsubscribe removes a subscriber for a specific path and client
type EventLevel ¶
type EventLevel int
EventLevel represents the severity/importance of an event
const ( LevelDebug EventLevel = iota LevelInfo LevelWarning LevelError LevelCritical )
type EventMetadata ¶
type EventMetadata struct {
Level EventLevel `json:"level,omitempty"`
Source string `json:"source,omitempty"`
Category string `json:"category,omitempty"`
RetryCount int `json:"retryCount,omitempty"`
Version string `json:"version,omitempty"`
Environment string `json:"environment,omitempty"`
}
EventMetadata contains additional information about the event