ws

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a WebSocket client connection

func NewClient

func NewClient(hub *Hub, conn *websocket.Conn) *Client

NewClient creates a new Client

func (*Client) ReadPump

func (c *Client) ReadPump(ctx context.Context)

ReadPump reads messages from the WebSocket connection (mainly to detect disconnects)

func (*Client) Send

func (c *Client) Send(data []byte) bool

Send queues a message to be sent to this client

func (*Client) WritePump

func (c *Client) WritePump(ctx context.Context)

WritePump pumps messages from the hub to the WebSocket connection

type Hub

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

Hub maintains the set of active clients and broadcasts messages to them

func NewHub

func NewHub() *Hub

NewHub creates a new Hub

func (*Hub) Broadcast

func (h *Hub) Broadcast(msg Message)

Broadcast sends a message to all connected clients

func (*Hub) ClientCount

func (h *Hub) ClientCount() int

ClientCount returns the number of connected clients

func (*Hub) Register

func (h *Hub) Register(c *Client)

Register adds a client to the hub

func (*Hub) Run

func (h *Hub) Run()

Run starts the hub's main loop

func (*Hub) Unregister

func (h *Hub) Unregister(c *Client)

Unregister removes a client from the hub

type KeyEventData

type KeyEventData struct {
	Op  string `json:"op"` // "set", "del", "expire", "expired", "rename_from", "rename_to"
	Key string `json:"key"`
}

KeyEventData represents a key operation event

type Message

type Message struct {
	Type string      `json:"type"` // "key_event", "stats", "status"
	Data interface{} `json:"data"`
}

Message is the wrapper for all WebSocket messages

type StatsData

type StatsData struct {
	DBSize          int64  `json:"dbSize"`
	UsedMemory      int64  `json:"usedMemory"`      // bytes
	UsedMemoryHuman string `json:"usedMemoryHuman"` // formatted (e.g., "1.18M")
	NotificationsOn bool   `json:"notificationsOn"`
}

StatsData represents periodic stats updates

type StatusData

type StatusData struct {
	Live bool   `json:"live"`          // true if keyspace notifications are enabled
	Msg  string `json:"msg,omitempty"` // optional message
}

StatusData represents connection status information

Jump to

Keyboard shortcuts

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