Files
ocis/proxy/pkg/cs3/client.go
T

39 lines
960 B
Go
Raw Normal View History

package cs3
import (
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
2021-08-12 11:18:55 +02:00
proxytracing "github.com/owncloud/ocis/proxy/pkg/tracing"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
2021-12-17 17:59:26 +01:00
"google.golang.org/grpc/credentials/insecure"
)
func newConn(endpoint string) (*grpc.ClientConn, error) {
2021-08-12 11:18:55 +02:00
conn, err := grpc.Dial(
endpoint,
2021-12-17 17:59:26 +01:00
grpc.WithTransportCredentials(insecure.NewCredentials()),
2021-08-12 11:18:55 +02:00
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
}