sse

package
v0.0.0-...-d236baf Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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 BroadcastPayload struct {
	ID      string `json:"id"`
	Message []byte `json:"message"`
}

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

func (*Hub) Run

func (h *Hub) Run()

func (*Hub) ServeSSE

func (h *Hub) ServeSSE(w http.ResponseWriter, r *http.Request)

Handles client connections to SSE service

type QueueUpdate

type QueueUpdate struct {
	MessageType string                  `json:"message_type"`
	QueueItems  []*responses.QueuedItem `json:"queue_items"`
}

Broadcast a message to all clients

Jump to

Keyboard shortcuts

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