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

Method processOpErr

nats.go:3431–3461  ·  view source on GitHub ↗

processOpErr handles errors from reading or parsing the protocol. The lock should not be held entering this function. If forceReconnect is true, the first reconnect attempt will bypass the configured ReconnectWait; subsequent attempts still obey the normal backoff.

(err error, forceReconnect bool)

Source from the content-addressed store, hash-verified

3429// is true, the first reconnect attempt will bypass the configured
3430// ReconnectWait; subsequent attempts still obey the normal backoff.
3431func (nc *Conn) processOpErr(err error, forceReconnect bool) bool {
3432 nc.mu.Lock()
3433 defer nc.mu.Unlock()
3434 if nc.isConnecting() || nc.isClosed() || nc.isReconnecting() {
3435 return false
3436 }
3437
3438 if nc.Opts.AllowReconnect && nc.status == CONNECTED {
3439 // Set our new status
3440 nc.changeConnStatus(RECONNECTING)
3441 // Stop ping timer if set
3442 nc.stopPingTimer()
3443 if nc.conn != nil {
3444 nc.conn.Close()
3445 nc.conn = nil
3446 }
3447
3448 // Create pending buffer before reconnecting.
3449 nc.bw.switchToPending()
3450
3451 // Clear any queued pongs, e.g. pending flush calls.
3452 nc.clearPendingFlushCalls()
3453
3454 go nc.doReconnect(err, forceReconnect)
3455 return false
3456 }
3457
3458 nc.changeConnStatus(DISCONNECTED)
3459 nc.err = err
3460 return true
3461}
3462
3463// dispatch is responsible for calling any async callbacks
3464func (ac *asyncCallbacksHandler) asyncCBDispatcher() {

Callers 4

readLoopMethod · 0.95
flusherMethod · 0.95
processErrMethod · 0.95
processPingTimerMethod · 0.95

Calls 9

isConnectingMethod · 0.95
isClosedMethod · 0.95
isReconnectingMethod · 0.95
changeConnStatusMethod · 0.95
stopPingTimerMethod · 0.95
doReconnectMethod · 0.95
switchToPendingMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected