fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

grpc: zoekt-sourcegraph-indexserver: support retries when frontend isn't available (#645)

+15 -2
+13
cmd/zoekt-sourcegraph-indexserver/main.go
··· 32 32 "time" 33 33 34 34 grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/openmetrics/v2" 35 + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/retry" 35 36 "github.com/keegancsmith/tmpfriend" 36 37 "github.com/peterbourgon/ff/v3/ffcli" 37 38 "github.com/prometheus/client_golang/prometheus" ··· 44 45 "golang.org/x/net/trace" 45 46 "golang.org/x/sys/unix" 46 47 "google.golang.org/grpc" 48 + "google.golang.org/grpc/codes" 47 49 "google.golang.org/grpc/credentials/insecure" 48 50 "google.golang.org/grpc/metadata" 49 51 ··· 1463 1465 func dialGRPCClient(addr string, logger sglog.Logger, additionalOpts ...grpc.DialOption) (proto.ZoektConfigurationServiceClient, error) { 1464 1466 metrics := mustGetClientMetrics() 1465 1467 1468 + // If the service seems to be unavailable, this 1469 + // will retry after [1s, 2s, 4s, 8s, 16s] with a jitterFraction of .1 1470 + // Ex: (on the first retry attempt, we will wait between [.9s and 1.1s]) 1471 + retryOpts := []retry.CallOption{ 1472 + retry.WithMax(5), 1473 + retry.WithBackoff(retry.BackoffExponentialWithJitter(1*time.Second, .1)), 1474 + retry.WithCodes(codes.Unavailable), 1475 + } 1476 + 1466 1477 opts := []grpc.DialOption{ 1467 1478 grpc.WithTransportCredentials(insecure.NewCredentials()), 1468 1479 grpc.WithChainStreamInterceptor( ··· 1470 1481 internalActorStreamInterceptor(), 1471 1482 internalerrs.LoggingStreamClientInterceptor(logger), 1472 1483 internalerrs.PrometheusStreamClientInterceptor, 1484 + retry.StreamClientInterceptor(retryOpts...), 1473 1485 ), 1474 1486 grpc.WithChainUnaryInterceptor( 1475 1487 grpc_prometheus.UnaryClientInterceptor(metrics), 1476 1488 internalActorUnaryInterceptor(), 1477 1489 internalerrs.LoggingUnaryClientInterceptor(logger), 1478 1490 internalerrs.PrometheusUnaryClientInterceptor, 1491 + retry.UnaryClientInterceptor(retryOpts...), 1479 1492 ), 1480 1493 grpc.WithDefaultServiceConfig(defaultGRPCServiceConfigurationJSON), 1481 1494 grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(defaultGRPCMessageReceiveSizeBytes)),
+2 -2
go.mod
··· 2 2 3 3 require ( 4 4 cloud.google.com/go/profiler v0.3.1 5 + github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 5 6 github.com/RoaringBitmap/roaring v1.3.0 6 7 github.com/andygrunwald/go-gerrit v0.0.0-20230628115649-c44fe2fbf2ca 7 8 github.com/bmatcuk/doublestar v1.3.4 ··· 18 19 github.com/google/slothfs v0.0.0-20190717100203-59c1163fd173 19 20 github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db 20 21 github.com/grpc-ecosystem/go-grpc-middleware/providers/openmetrics/v2 v2.0.0-rc.3 22 + github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2.0.20210128111500-3ff779b52992 21 23 github.com/hashicorp/go-retryablehttp v0.7.4 22 24 github.com/keegancsmith/rpc v1.3.0 23 25 github.com/keegancsmith/tmpfriend v0.0.0-20180423180255-86e88902a513 ··· 63 65 cloud.google.com/go v0.110.3 // indirect 64 66 cloud.google.com/go/compute v1.20.1 // indirect 65 67 cloud.google.com/go/compute/metadata v0.2.3 // indirect 66 - github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect 67 68 github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect 68 69 github.com/Microsoft/go-winio v0.6.1 // indirect 69 70 github.com/ProtonMail/go-crypto v0.0.0-20230626094100-7e9e0395ebec // indirect ··· 96 97 github.com/google/uuid v1.3.0 // indirect 97 98 github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect 98 99 github.com/googleapis/gax-go/v2 v2.11.0 // indirect 99 - github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2.0.20210128111500-3ff779b52992 // indirect 100 100 github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect 101 101 github.com/hashicorp/go-cleanhttp v0.5.2 // indirect 102 102 github.com/hashicorp/go-hclog v0.16.2 // indirect