Skip to content
Snippets Groups Projects

client: add sidechannel support

Merged Jacob Vosmaer requested to merge jv-sidechannel-client into master
5 unresolved threads
Files
3
+ 20
0
@@ -3,8 +3,12 @@ package client
import (
"context"
"gitlab.com/gitlab-org/gitaly/v14/internal/backchannel"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/client"
"gitlab.com/gitlab-org/gitaly/v14/internal/listenmux"
"gitlab.com/gitlab-org/gitaly/v14/internal/sidechannel"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
)
@@ -30,6 +34,22 @@ func Dial(rawAddress string, connOpts []grpc.DialOption) (*grpc.ClientConn, erro
return DialContext(context.Background(), rawAddress, connOpts)
}
// DialSidechannel configures the dialer to establish a Gitaly
// backchannel connection instead of a regular gRPC connection. It also
// injects sr as a sidechannel registry, so that Gitaly can establish
// sidechannels back to the client.
func DialSidechannel(ctx context.Context, rawAddress string, sr *SidechannelRegistry, connOpts []grpc.DialOption) (*grpc.ClientConn, error) {
clientHandshaker := backchannel.NewClientHandshaker(
sr.logger,
func() backchannel.Server {
lm := listenmux.New(insecure.NewCredentials())
lm.Register(sidechannel.NewServerHandshaker(sr.registry))
return grpc.NewServer(grpc.Creds(lm))
},
)
return client.Dial(ctx, rawAddress, connOpts, clientHandshaker)
}
// FailOnNonTempDialError helps to identify if remote listener is ready to accept new connections.
func FailOnNonTempDialError() []grpc.DialOption {
return []grpc.DialOption{
Loading