proxy: Use reva provided method for getting Gateway Client

This removes some duplicated code. And reuses the reva client code
we're also using everywhere else.
This commit is contained in:
Ralf Haferkamp
2022-10-05 08:45:05 +02:00
committed by Ralf Haferkamp
parent 1b0ec2c9d5
commit 083b9897a0
2 changed files with 2 additions and 41 deletions
+2 -2
View File
@@ -8,6 +8,7 @@ import (
"time"
"github.com/coreos/go-oidc/v3/oidc"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/v2/pkg/token/manager/jwt"
chimiddleware "github.com/go-chi/chi/v5/middleware"
"github.com/justinas/alice"
@@ -21,7 +22,6 @@ import (
storesvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/store/v0"
"github.com/owncloud/ocis/v2/services/proxy/pkg/config"
"github.com/owncloud/ocis/v2/services/proxy/pkg/config/parser"
"github.com/owncloud/ocis/v2/services/proxy/pkg/cs3"
"github.com/owncloud/ocis/v2/services/proxy/pkg/logging"
"github.com/owncloud/ocis/v2/services/proxy/pkg/metrics"
"github.com/owncloud/ocis/v2/services/proxy/pkg/middleware"
@@ -128,7 +128,7 @@ func Server(cfg *config.Config) *cli.Command {
func loadMiddlewares(ctx context.Context, logger log.Logger, cfg *config.Config) alice.Chain {
rolesClient := settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient())
revaClient, err := cs3.GetGatewayServiceClient(cfg.Reva.Address)
revaClient, err := pool.GetGatewayServiceClient(cfg.Reva.Address)
var userProvider backend.UserBackend
switch cfg.AccountBackend {
case "cs3":
-39
View File
@@ -1,39 +0,0 @@
package cs3
import (
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
proxytracing "github.com/owncloud/ocis/v2/services/proxy/pkg/tracing"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func newConn(endpoint string) (*grpc.ClientConn, error) {
conn, err := grpc.Dial(
endpoint,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithUnaryInterceptor(
otelgrpc.UnaryClientInterceptor(
otelgrpc.WithTracerProvider(
proxytracing.TraceProvider,
),
),
),
)
if err != nil {
return nil, err
}
return conn, nil
}
// GetGatewayServiceClient returns a new cs3 gateway client
func GetGatewayServiceClient(endpoint string) (gateway.GatewayAPIClient, error) {
// TODO: check connection pooling
conn, err := newConn(endpoint)
if err != nil {
return nil, err
}
return gateway.NewGatewayAPIClient(conn), nil
}