websocket

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: AGPL-3.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilConfig = errors.New("websocket async notifier config is nil")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	HeartbeatInterval time.Duration `env:"HEARTBEAT_INTERVAL" json:"heartbeatInterval"`
	ReadBufferSize    int           `env:"READ_BUFFER_SIZE"   json:"readBufferSize"`
	WriteBufferSize   int           `env:"WRITE_BUFFER_SIZE"  json:"writeBufferSize"`
}

Config holds WebSocket async notifier configuration.

func (*Config) ValidateWithContext

func (cfg *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates a Config struct.

type Notifier

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

Notifier is a WebSocket-backed AsyncNotifier that manages direct client connections.

func NewNotifier

func NewNotifier(cfg *Config, logger logging.Logger, tracerProvider tracing.TracerProvider) (*Notifier, error)

NewNotifier creates a new WebSocket-backed AsyncNotifier.

func (*Notifier) AcceptConnection

func (n *Notifier) AcceptConnection(w http.ResponseWriter, r *http.Request, channel, memberID string) error

AcceptConnection upgrades the HTTP connection to a WebSocket and registers it under the given channel and memberID.

func (*Notifier) Close

func (n *Notifier) Close() error

Close releases resources held by the notifier.

func (*Notifier) Publish

func (n *Notifier) Publish(ctx context.Context, channel string, event *asyncnotifications.Event) error

Publish sends an event to all connected clients on the given channel.

Jump to

Keyboard shortcuts

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