Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber manages topic subscriptions for a single WebSocket connection by delegating to a shared Hub. The Hub ensures that each unique NATS topic has at most one NATS subscription per server instance, fanning messages out to all local connections in-memory.
func New ¶
func New(h *hub.Hub, conn hub.Conn, telemetry *observability.WSTelemetry, ctx func() context.Context) *Subscriber
New creates a subscriber backed by the shared hub for the given connection.
func (*Subscriber) Close ¶
func (s *Subscriber) Close() error
Close removes this connection from all topics.
func (*Subscriber) Subscribe ¶
func (s *Subscriber) Subscribe(key, topic string) error
Subscribe registers this connection for the given NATS topic under a logical key. If a previous subscription existed for the same key, it is replaced.
func (*Subscriber) Unsubscribe ¶
func (s *Subscriber) Unsubscribe(key string) error
Unsubscribe removes the subscription for the given key.
Click to show internal directories.
Click to hide internal directories.