internal

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MonitorInterval = 30 * time.Second

Variables

This section is empty.

Functions

func DefaultLogFn added in v1.2.3

func DefaultLogFn(prefix string) func(currentAlloc, peakAlloc uint64)

DefaultLogFn returns a log function with the given prefix.

func ErrorResponse added in v0.0.43

func ErrorResponse(w http.ResponseWriter, statusMessage *StatusMessage) error

func FormatBytes added in v1.2.3

func FormatBytes(b uint64) string

func NilChecker

func NilChecker(data any) error

func ReadPump

func ReadPump(c *Client, h *Hub)

func WritePump

func WritePump(c *Client, h *Hub)

Types

type Client

type Client struct {
	ID             string
	Conn           *websocket.Conn
	Send           chan []byte
	SubscribedPath string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conn *websocket.Conn, subscribedPath string) *Client

type Hub

type Hub struct {
	Clients    map[*Client]bool
	Broadcast  chan []byte
	Register   chan *Client
	Unregister chan *Client
	// contains filtered or unexported fields
}

func NewHub

func NewHub(path string, maxClients int) *Hub

func (*Hub) Run

func (h *Hub) Run(ctx context.Context)

Run starts the hub event loop. It exits when ctx is cancelled.

type MemoryMonitor added in v1.2.3

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

func NewMemoryMonitor added in v1.2.3

func NewMemoryMonitor() *MemoryMonitor

func (*MemoryMonitor) Run added in v1.2.3

func (m *MemoryMonitor) Run(ctx context.Context, logFn func(currentAlloc, peakAlloc uint64))

Run starts a periodic monitor loop that calls logFn with each snapshot. It blocks until ctx is cancelled.

func (*MemoryMonitor) Snapshot added in v1.2.3

func (m *MemoryMonitor) Snapshot() (currentAlloc, peakAlloc uint64)

Snapshot reads current heap allocation, updates the peak, and returns both.

type StatusMessage added in v0.0.43

type StatusMessage struct {
	StatusCode *int
	Message    *string `json:"msg"`
}

type StatusMessageBuilder added in v0.0.43

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

func NewStatusMessage added in v0.0.43

func NewStatusMessage() *StatusMessageBuilder

func (*StatusMessageBuilder) Build added in v0.0.43

func (sm *StatusMessageBuilder) Build() *StatusMessage

func (*StatusMessageBuilder) Message added in v0.0.43

func (sm *StatusMessageBuilder) Message(message string) *StatusMessageBuilder

func (*StatusMessageBuilder) StatusCode added in v0.0.43

func (sm *StatusMessageBuilder) StatusCode(statusCode int) *StatusMessageBuilder

Jump to

Keyboard shortcuts

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