Skip to content

Commit

Permalink
Adds client retry. Fixes #959 (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Feb 13, 2019
1 parent cb9eb0a commit 4283b8a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion reposerver/clientset.go
Expand Up @@ -2,6 +2,9 @@ package reposerver

import (
"crypto/tls"
"time"

"github.com/grpc-ecosystem/go-grpc-middleware/retry"

"github.com/argoproj/argo-cd/reposerver/repository"
"github.com/argoproj/argo-cd/util"
Expand All @@ -20,7 +23,14 @@ type clientSet struct {
}

func (c *clientSet) NewRepositoryClient() (util.Closer, repository.RepositoryServiceClient, error) {
conn, err := grpc.Dial(c.address, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{InsecureSkipVerify: true})))
retryOpts := []grpc_retry.CallOption{
grpc_retry.WithMax(3),
grpc_retry.WithBackoff(grpc_retry.BackoffLinear(1000 * time.Millisecond)),
}
conn, err := grpc.Dial(c.address,
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{InsecureSkipVerify: true})),
grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(retryOpts...)),
grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(retryOpts...)))
if err != nil {
log.Errorf("Unable to connect to repository service with address %s", c.address)
return nil, nil, err
Expand Down

0 comments on commit 4283b8a

Please sign in to comment.