MCPcopy
hub / github.com/nats-io/nats.go / StatusChanged

Method StatusChanged

nats.go:6506–6517  ·  view source on GitHub ↗

StatusChanged returns a channel on which given list of connection status changes will be reported. If no statuses are provided, defaults will be used: CONNECTED, RECONNECTING, DISCONNECTED, CLOSED.

(statuses ...Status)

Source from the content-addressed store, hash-verified

6504// StatusChanged returns a channel on which given list of connection status changes will be reported.
6505// If no statuses are provided, defaults will be used: CONNECTED, RECONNECTING, DISCONNECTED, CLOSED.
6506func (nc *Conn) StatusChanged(statuses ...Status) chan Status {
6507 if len(statuses) == 0 {
6508 statuses = []Status{CONNECTED, RECONNECTING, DISCONNECTED, CLOSED}
6509 }
6510 ch := make(chan Status, 10)
6511 nc.mu.Lock()
6512 defer nc.mu.Unlock()
6513 for _, s := range statuses {
6514 nc.registerStatusChangeListener(s, ch)
6515 }
6516 return ch
6517}
6518
6519// RemoveStatusListener removes a status change listener.
6520// If the channel is not closed, it will be closed.

Callers 15

newAsyncReplyMethod · 0.45
FetchMethod · 0.45
FetchBatchMethod · 0.45
TestRemoveStatusListenerFunction · 0.45
TestAuthExpiredReconnectFunction · 0.45
TestForceReconnectFunction · 0.45
TestUserInfoHandlerFunction · 0.45
TestSubscriptionEventsFunction · 0.45

Calls 1

Tested by 9

TestRemoveStatusListenerFunction · 0.36
TestAuthExpiredReconnectFunction · 0.36
TestForceReconnectFunction · 0.36
TestUserInfoHandlerFunction · 0.36
TestSubscriptionEventsFunction · 0.36