Skip to content

Commit

Permalink
use single transport across varios YARPC outbounds for efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatali committed Aug 16, 2019
1 parent d9eb102 commit 503d1ba
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions runtime/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,18 +795,19 @@ func (gateway *Gateway) setupYARPCClientDispatcher(config *StaticConfig) error {

clientServiceNameMapping := make(map[string]string)
config.MustGetStruct("grpc.clientServiceNameMapping", &clientServiceNameMapping)
if len(clientServiceNameMapping) == 0 {
return nil
}

// TODO: no op if there is no YARPC clients
unaryOutbound := grpc.NewTransport(
grpc.Logger(gateway.Logger),
grpc.Tracer(gateway.Tracer),
).NewSingleOutbound(address)
outbounds := make(yarpc.Outbounds, len(clientServiceNameMapping))
for key, value := range clientServiceNameMapping {
outbounds[key] = transport.Outbounds{
ServiceName: value,
// TODO: this setup opens one TCP connection to the sidecar router per client
// Is it better to share the same TCP connection among the clients?
Unary: grpc.NewTransport(
grpc.Logger(gateway.Logger),
grpc.Tracer(gateway.Tracer),
).NewSingleOutbound(address),
Unary: unaryOutbound,
}
}

Expand Down

0 comments on commit 503d1ba

Please sign in to comment.