subscriber

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 3 Imported by: 0

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) *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.

Jump to

Keyboard shortcuts

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