1
0
forked from extern/smegmesh
- Adding retry policy for mobility
This commit is contained in:
Tim Beatham 2023-12-29 00:58:43 +00:00
parent bf53108384
commit d2c8a52ec6
2 changed files with 19 additions and 2 deletions

View File

@ -42,8 +42,25 @@ func NewWgCtrlConnection(clientConfig *tls.Config, server string) (PeerConnectio
// ConnectWithToken: Connects to a new gRPC peer given the address of the other server.
func (c *WgCtrlConnection) CreateGrpcConnection() error {
retryPolicy := `{
"methodConfig": [{
"name": [
{"service": "syncservice.SyncService"},
{"service": "ctrlserver.MeshCtrlServer"}
],
"waitForReady": true,
"retryPolicy": {
"MaxAttempts": 2,
"InitialBackoff": ".01s",
"MaxBackoff": ".01s",
"BackoffMultiplier": 1.0,
"RetryableStatusCodes": [ "UNAVAILABLE" ]
}
}]}`
conn, err := grpc.Dial(c.endpoint,
grpc.WithTransportCredentials(credentials.NewTLS(c.clientConfig)))
grpc.WithTransportCredentials(credentials.NewTLS(c.clientConfig)),
grpc.WithDefaultServiceConfig(retryPolicy))
if err != nil {
logging.Log.WriteErrorf("Could not connect: %s\n", err.Error())

View File

@ -19,7 +19,7 @@ type ConnectionManager interface {
// If the endpoint does not exist then add the connection. Returns an error
// if something went wrong
GetConnection(endPoint string) (PeerConnection, error)
// HasConnections returns true if a client has already registered at the givne
// HasConnections returns true if a peer has already registered at the given
// endpoint or false otherwise.
HasConnection(endPoint string) bool
// Goes through all the connections and closes eachone