Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config holds the connection parameters for NATS. Decoupled from protobuf config so this package can be imported externally.
type ReloadableConnection ¶
ReloadableConnection wraps a NATS connection and provides reconnection notifications via a pub/sub fan-out to subscribers.
func New ¶
func New(cfg *Config, logger log.Logger) (*ReloadableConnection, func(), error)
New creates a ReloadableConnection with automatic reconnection handling. Returns (nil, cleanup, nil) when cfg is nil or URI is empty (NATS is optional). The cleanup function drains the NATS connection on shutdown.
func (*ReloadableConnection) Broadcast ¶
func (rc *ReloadableConnection) Broadcast()
Broadcast notifies all subscribers of a reconnection event. Non-blocking: if a subscriber's channel is full, the signal is dropped. Nil-receiver safe.
func (*ReloadableConnection) Subscribe ¶
func (rc *ReloadableConnection) Subscribe(ctx context.Context) <-chan struct{}
Subscribe registers for reconnection notifications. The returned channel receives a signal each time the NATS connection is re-established. The subscription is automatically removed when ctx is cancelled. Nil-receiver safe: returns a closed channel.