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

Method sendStatusEvent

nats.go:6557–6574  ·  view source on GitHub ↗

sendStatusEvent sends connection status event to all channels. If channel is closed, or there is no listener, sendStatusEvent will not block. Lock should be held entering.

(s Status)

Source from the content-addressed store, hash-verified

6555// If channel is closed, or there is no listener, sendStatusEvent
6556// will not block. Lock should be held entering.
6557func (nc *Conn) sendStatusEvent(s Status) {
6558Loop:
6559 for ch := range nc.statListeners[s] {
6560 // make sure channel is not closed
6561 select {
6562 case <-ch:
6563 // if chan is closed, remove it
6564 delete(nc.statListeners[s], ch)
6565 continue Loop
6566 default:
6567 }
6568 // only send event if someone's listening
6569 select {
6570 case ch <- s:
6571 default:
6572 }
6573 }
6574}
6575
6576// changeConnStatus changes connections status and sends events
6577// to all listeners. Lock should be held entering.

Callers 1

changeConnStatusMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected