Documentation
¶
Index ¶
- Constants
- type AppVersionMessage
- type BroadcastPayload
- type Client
- type Hub
- func (h *Hub) BraodcastKeepalive()
- func (h *Hub) BroadcastLivePageMessage(req shared.LivePageMessage)
- func (h *Hub) BroadcastQueueUpdate(msg []*responses.QueuedItem)
- func (h *Hub) BroadcastStatusUpdate(msg repository.TaskStatusUpdateResponse)
- func (h *Hub) Run()
- func (h *Hub) ServeSSE(w http.ResponseWriter, r *http.Request)
- type QueueUpdate
Constants ¶
View Source
const ALL_CLIENTS_ID = "all"
View Source
const LIVE_STREAM_ID = "live"
Special stream ID for live page
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppVersionMessage ¶
type AppVersionMessage struct {
Version string `json:"version"`
}
type BroadcastPayload ¶
type Client ¶
type Client struct { // Buffered channel of outbound messages. Send chan []byte // identifier for connected client Uid string }
Every server connection is a client instance
type Hub ¶
type Hub struct { // Events are pushed to this channel by the main events-gathering routine Broadcast chan BroadcastPayload // We need to send keepalives to clients so connections stay alive KeepAlive chan bool // Clients connecting Register chan *Client // Clients disconnecting Unregister chan *Client // Database access Repo *repository.Repository Redis *database.RedisWrapper // contains filtered or unexported fields }
func NewHub ¶
func NewHub(redis *database.RedisWrapper, repo *repository.Repository) *Hub
func (*Hub) BraodcastKeepalive ¶
func (h *Hub) BraodcastKeepalive()
func (*Hub) BroadcastLivePageMessage ¶
func (h *Hub) BroadcastLivePageMessage(req shared.LivePageMessage)
Broadcast a message for the live page
func (*Hub) BroadcastQueueUpdate ¶
func (h *Hub) BroadcastQueueUpdate(msg []*responses.QueuedItem)
func (*Hub) BroadcastStatusUpdate ¶
func (h *Hub) BroadcastStatusUpdate(msg repository.TaskStatusUpdateResponse)
Broadcasts message from sc-worker to client(s) SSE stream(s) It's published by our repository, after we do database-y stuff with out cog message
type QueueUpdate ¶
type QueueUpdate struct { MessageType string `json:"message_type"` QueueItems []*responses.QueuedItem `json:"queue_items"` }
Broadcast a message to all clients
Click to show internal directories.
Click to hide internal directories.