mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit with typed errors support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
28
vendor/github.com/moby/buildkit/session/grpc.go
generated
vendored
28
vendor/github.com/moby/buildkit/session/grpc.go
generated
vendored
@ -6,7 +6,9 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
||||
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
|
||||
"github.com/moby/buildkit/util/grpcerrors"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -25,8 +27,11 @@ func serve(ctx context.Context, grpcServer *grpc.Server, conn net.Conn) {
|
||||
}
|
||||
|
||||
func grpcClientConn(ctx context.Context, conn net.Conn) (context.Context, *grpc.ClientConn, error) {
|
||||
var unary []grpc.UnaryClientInterceptor
|
||||
var stream []grpc.StreamClientInterceptor
|
||||
|
||||
var dialCount int64
|
||||
dialer := grpc.WithDialer(func(addr string, d time.Duration) (net.Conn, error) {
|
||||
dialer := grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
if c := atomic.AddInt64(&dialCount, 1); c > 1 {
|
||||
return nil, errors.Errorf("only one connection allowed")
|
||||
}
|
||||
@ -40,10 +45,23 @@ func grpcClientConn(ctx context.Context, conn net.Conn) (context.Context, *grpc.
|
||||
|
||||
if span := opentracing.SpanFromContext(ctx); span != nil {
|
||||
tracer := span.Tracer()
|
||||
dialOpts = append(dialOpts,
|
||||
grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(tracer, traceFilter())),
|
||||
grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(tracer, traceFilter())),
|
||||
)
|
||||
unary = append(unary, otgrpc.OpenTracingClientInterceptor(tracer, traceFilter()))
|
||||
stream = append(stream, otgrpc.OpenTracingStreamClientInterceptor(tracer, traceFilter()))
|
||||
}
|
||||
|
||||
unary = append(unary, grpcerrors.UnaryClientInterceptor)
|
||||
stream = append(stream, grpcerrors.StreamClientInterceptor)
|
||||
|
||||
if len(unary) == 1 {
|
||||
dialOpts = append(dialOpts, grpc.WithUnaryInterceptor(unary[0]))
|
||||
} else if len(unary) > 1 {
|
||||
dialOpts = append(dialOpts, grpc.WithUnaryInterceptor(grpc_middleware.ChainUnaryClient(unary...)))
|
||||
}
|
||||
|
||||
if len(stream) == 1 {
|
||||
dialOpts = append(dialOpts, grpc.WithStreamInterceptor(stream[0]))
|
||||
} else if len(stream) > 1 {
|
||||
dialOpts = append(dialOpts, grpc.WithStreamInterceptor(grpc_middleware.ChainStreamClient(stream...)))
|
||||
}
|
||||
|
||||
cc, err := grpc.DialContext(ctx, "", dialOpts...)
|
||||
|
Reference in New Issue
Block a user