Help us shape the future of Go! Take the 2026 Go Developer Survey

realtime

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func NewHub

func NewHub(cfg *config.Config) *Hub

func (*Hub) HandleSSE

func (h *Hub) HandleSSE(w http.ResponseWriter, r *http.Request, userID string) error

func (*Hub) HandleWebSocket

func (h *Hub) HandleWebSocket(w http.ResponseWriter, r *http.Request, userID string) error

func (*Hub) MaxConnectionsPerUser

func (h *Hub) MaxConnectionsPerUser() int

func (*Hub) PushMessage

func (h *Hub) PushMessage(userID string, data any) error

func (*Hub) PushMessageWaitAck

func (h *Hub) PushMessageWaitAck(userID string, data any, timeout time.Duration) PushAckResult

func (*Hub) Stats

func (h *Hub) Stats() Stats

func (*Hub) SubscribeInbound

func (h *Hub) SubscribeInbound(handler func(InboundMessage)) func()

func (*Hub) Transport

func (h *Hub) Transport() Transport

type InboundMessage

type InboundMessage struct {
	UserID     string          `json:"user_id"`
	ClientID   string          `json:"client_id"`
	Transport  Transport       `json:"transport"`
	Payload    map[string]any  `json:"payload"`
	Raw        json.RawMessage `json:"raw"`
	ReceivedAt time.Time       `json:"received_at"`
}

type PushAckResult

type PushAckResult struct {
	OK        bool   `json:"ok"`
	UserID    string `json:"user_id"`
	Acked     int    `json:"acked"`
	Total     int    `json:"total"`
	Delivered int    `json:"delivered"`
	Detail    string `json:"detail,omitempty"`
	Error     string `json:"error,omitempty"`
}

type Stats

type Stats struct {
	Transport             string         `json:"transport"`
	MaxConnectionsPerUser int            `json:"max_connections_per_user"`
	Users                 int            `json:"users"`
	TotalConnections      int            `json:"total_connections"`
	ConnectionsByUser     map[string]int `json:"connections_by_user"`
}

type Transport

type Transport string
const (
	TransportWS  Transport = "ws"
	TransportSSE Transport = "sse"
)

Jump to

Keyboard shortcuts

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