d1ad538345
* Adds client-side retry for no leader errors. This paves over the case where the client was connected to the leader when it loses leadership. * Adds a configurable server RPC drain time and a fail-fast path for RPCs. When a server leaves it gets removed from the Raft configuration, so it will never know who the new leader server ends up being. Without this we'd be doomed to wait out the RPC hold timeout and then fail. This makes things fail a little quicker while a sever is draining, and since we added a client retry AND since the server doing this has already shut down and left the Serf LAN, clients should retry against some other server. * Makes the RPC hold timeout configurable. * Reorders struct members. * Sets the RPC hold timeout default for test servers. * Bumps the leave drain time up to 5 seconds. * Robustifies retries with a simpler client-side RPC hold. * Reverts untended delete.
28 lines
531 B
Go
28 lines
531 B
Go
package lib
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
|
|
"github.com/hashicorp/yamux"
|
|
)
|
|
|
|
var yamuxStreamClosed = yamux.ErrStreamClosed.Error()
|
|
var yamuxSessionShutdown = yamux.ErrSessionShutdown.Error()
|
|
|
|
// IsErrEOF returns true if we get an EOF error from the socket itself, or
|
|
// an EOF equivalent error from yamux.
|
|
func IsErrEOF(err error) bool {
|
|
if err == io.EOF {
|
|
return true
|
|
}
|
|
|
|
errStr := err.Error()
|
|
if strings.Contains(errStr, yamuxStreamClosed) ||
|
|
strings.Contains(errStr, yamuxSessionShutdown) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|