Skip to content

Commit

Permalink
buildx: proxy to reuse conns in connecting state
Browse files Browse the repository at this point in the history
  • Loading branch information
gmichelo committed Oct 13, 2023
1 parent 3569e0a commit ebeb37e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/cli/cmd/cluster/grpcproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ func (g *grpcProxy) newBackendClient(ctx context.Context) (*grpc.ClientConn, err
defer g.mu.Unlock()

if g.backendClient != nil {
if g.backendClient.GetState() == connectivity.Ready {
fmt.Fprintf(console.Debug(ctx), "reused grpc connection\n")
connState := g.backendClient.GetState()
if connState == connectivity.Ready || connState == connectivity.Connecting {
fmt.Fprintf(console.Debug(ctx), "reused grpc connection: %v\n", connState)
return g.backendClient, nil
}

fmt.Fprintf(console.Debug(ctx), "cached grpc connection invalidated: %v\n", g.backendClient.GetState())
closingErr := g.backendClient.Close()
fmt.Fprintf(console.Debug(ctx), "cached grpc connection invalidated: %v, closing err: %v\n", connState, closingErr)
g.backendClient = nil
}

Expand Down

0 comments on commit ebeb37e

Please sign in to comment.