Skip to content

Commit

Permalink
fix lint?vet?
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed May 22, 2018
1 parent b970c5c commit 091eb4a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions grpclb_remote_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ func (lb *lbBalancer) sendLoadReport(s *balanceLoadClientStream, interval time.D
}
}

func (lb *lbBalancer) callRemoteBalancer() (_ error, backoff bool) {
func (lb *lbBalancer) callRemoteBalancer() (backoff bool, _ error) {
lbClient := &loadBalancerClient{cc: lb.ccRemoteLB}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
stream, err := lbClient.BalanceLoad(ctx, FailFast(false))
if err != nil {
return fmt.Errorf("grpclb: failed to perform RPC to the remote balancer %v", err), true
return true, fmt.Errorf("grpclb: failed to perform RPC to the remote balancer %v", err)
}

// grpclb handshake on the stream.
Expand All @@ -194,18 +194,18 @@ func (lb *lbBalancer) callRemoteBalancer() (_ error, backoff bool) {
},
}
if err := stream.Send(initReq); err != nil {
return fmt.Errorf("grpclb: failed to send init request: %v", err), true
return true, fmt.Errorf("grpclb: failed to send init request: %v", err)
}
reply, err := stream.Recv()
if err != nil {
return fmt.Errorf("grpclb: failed to recv init response: %v", err), true
return true, fmt.Errorf("grpclb: failed to recv init response: %v", err)
}
initResp := reply.GetInitialResponse()
if initResp == nil {
return fmt.Errorf("grpclb: reply from remote balancer did not include initial response"), true
return true, fmt.Errorf("grpclb: reply from remote balancer did not include initial response")
}
if initResp.LoadBalancerDelegate != "" {
return fmt.Errorf("grpclb: Delegation is not supported"), true
return true, fmt.Errorf("grpclb: Delegation is not supported")
}

go func() {
Expand All @@ -214,13 +214,13 @@ func (lb *lbBalancer) callRemoteBalancer() (_ error, backoff bool) {
}
}()
// No backoff if init req/resp handshake was successful.
return lb.readServerList(stream), false
return false, lb.readServerList(stream)
}

func (lb *lbBalancer) watchRemoteBalancer() {
var retryCount int
for {
err, doBackoff := lb.callRemoteBalancer()
doBackoff, err := lb.callRemoteBalancer()
select {
case <-lb.doneCh:
return
Expand Down

0 comments on commit 091eb4a

Please sign in to comment.