fix: grpc reconnect backoff

This commit is contained in:
徐聪
2022-07-15 14:49:47 +08:00
parent 89871e6c68
commit d75cffbd30
2 changed files with 10 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import (
"golang.org/x/oauth2"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/oauth"
"google.golang.org/grpc/metadata"
@@ -169,6 +170,14 @@ func (c *grpcClient) start() (err error) {
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(32 * 10e9)),
grpc.WithUnaryInterceptor(unaryInterceptor),
grpc.WithStreamInterceptor(streamInterceptor),
grpc.WithConnectParams(grpc.ConnectParams{
Backoff: backoff.Config{
BaseDelay: 1 * time.Second,
Multiplier: 1.2,
MaxDelay: 3 * time.Second,
},
MinConnectTimeout: 3 * time.Second,
}),
}
c.config.conn, err = grpc.Dial(addr, opts...)
if err != nil {

View File

@@ -1320,7 +1320,7 @@ func (r *masterRunner) reportStats() {
table := tablewriter.NewWriter(os.Stdout)
table.SetColMinWidth(0, 20)
table.SetColMinWidth(1, 10)
table.SetHeader([]string{"Worker ID", "IP", "State", "Current Users", "CPU (%)", "Memory (%)"})
table.SetHeader([]string{"Worker ID", "IP", "State", "Current Users", "CPU Usage (%)", "Memory Usage (%)"})
for _, worker := range r.server.getAllWorkers() {
row := make([]string, 6)