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

Method Close

nats.go:6042–6052  ·  nats.go::Conn.Close

Close will close the connection to the server. This call will release all blocking calls, such as Flush() and NextMsg()

()

Source from the content-addressed store, hash-verified

6040// Close will close the connection to the server. This call will release
6041// all blocking calls, such as Flush() and NextMsg()
6042func (nc *Conn) Close() {
6043 if nc != nil {
6044 // This will be a no-op if the connection was not websocket.
6045 // We do this here as opposed to inside close() because we want
6046 // to do this only for the final user-driven close of the client.
6047 // Otherwise, we would need to change close() to pass a boolean
6048 // indicating that this is the case.
6049 nc.wsClose()
6050 nc.close(CLOSED, !nc.Opts.NoCallbacksAfterClientClose, nil)
6051 }
6052}
6053
6054// IsClosed tests if a Conn has been closed.
6055func (nc *Conn) IsClosed() bool {

Callers 15

drainConnectionMethod · 0.95
DrainMethod · 0.95
TestErrOnMaxPayloadLimitFunction · 0.95
TestConnectedAddrFunction · 0.95
TestLocalAddrFunction · 0.95
TestWSNoMixingSchemeFunction · 0.45
TestWSProxyPathFunction · 0.45
startHeaderCatcherFunction · 0.45
CloseTCPConnMethod · 0.45
wsInitHandshakeMethod · 0.45

Calls 2

wsCloseMethod · 0.95
closeMethod · 0.95

Tested by 15

TestErrOnMaxPayloadLimitFunction · 0.76
TestConnectedAddrFunction · 0.76
TestLocalAddrFunction · 0.76
TestWSNoMixingSchemeFunction · 0.36
TestWSProxyPathFunction · 0.36
startHeaderCatcherFunction · 0.36
ExampleConnectFunction · 0.36
ExampleCustomDialerFunction · 0.36
ExampleConn_SubscribeFunction · 0.36