Skip to content

Commit

Permalink
grpc/proxy: Redial if connection unexpectedly shuts down
Browse files Browse the repository at this point in the history
  • Loading branch information
abukosek committed Mar 31, 2020
1 parent 06289ef commit 6e591d1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/common/grpc/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"

Expand Down Expand Up @@ -74,6 +75,12 @@ func (p *proxy) handler(srv interface{}, stream grpc.ServerStream) error {
// Pass subject header upstream.
upstreamCtx = metadata.AppendToOutgoingContext(upstreamCtx, policy.ForwardedSubjectMD, sub)

// Check if upstream connection was disconnected.
if p.upstreamConn != nil && p.upstreamConn.GetState() == connectivity.Shutdown {
// We need to redial if the connection was shut down.
p.upstreamConn = nil
}

// Dial upstream if necessary.
if p.upstreamConn == nil {
var grr error
Expand Down

0 comments on commit 6e591d1

Please sign in to comment.