Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2022-01-18 14:34:36 +0300
committerToon Claes <toon@gitlab.com>2022-01-20 19:59:01 +0300
commitbf41063be6f60730d5b1f2f1862089e74097ea64 (patch)
tree1893ad49af54c78ca934a37996cf4410dd27a99e /client
parent7cd8ef212eccee3ffd388f1b88ccdeca15971435 (diff)
client: Expose sidechannel server methods
This makes it easier to test sidechannel RPC's in downstream consumers (gitlab-workhorse, gitlab-shell). Changelog: other
Diffstat (limited to 'client')
-rw-r--r--client/sidechannel.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/client/sidechannel.go b/client/sidechannel.go
index 26729c138..fc79502ea 100644
--- a/client/sidechannel.go
+++ b/client/sidechannel.go
@@ -72,13 +72,10 @@ func TestSidechannelServer(
creds credentials.TransportCredentials,
handler func(interface{}, grpc.ServerStream, io.ReadWriteCloser) error,
) []grpc.ServerOption {
- lm := listenmux.New(creds)
- lm.Register(backchannel.NewServerHandshaker(logger, backchannel.NewRegistry(), nil))
-
return []grpc.ServerOption{
- grpc.Creds(lm),
+ SidechannelServer(logger, creds),
grpc.UnknownServiceHandler(func(srv interface{}, stream grpc.ServerStream) error {
- conn, err := sidechannel.OpenSidechannel(stream.Context())
+ conn, err := OpenServerSidechannel(stream.Context())
if err != nil {
return err
}
@@ -88,3 +85,16 @@ func TestSidechannelServer(
}),
}
}
+
+// SidechannelServer adds sidechannel support to a gRPC server
+func SidechannelServer(logger *logrus.Entry, creds credentials.TransportCredentials) grpc.ServerOption {
+ lm := listenmux.New(creds)
+ lm.Register(backchannel.NewServerHandshaker(logger, backchannel.NewRegistry(), nil))
+ return grpc.Creds(lm)
+}
+
+// OpenServerSidechannel opens a sidechannel on the server side. This
+// only works if the server was created using SidechannelServer().
+func OpenServerSidechannel(ctx context.Context) (io.ReadWriteCloser, error) {
+ return sidechannel.OpenSidechannel(ctx)
+}