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)
| 3429 | // is true, the first reconnect attempt will bypass the configured |
| 3430 | // ReconnectWait; subsequent attempts still obey the normal backoff. |
| 3431 | func (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 |
| 3464 | func (ac *asyncCallbacksHandler) asyncCBDispatcher() { |
no test coverage detected