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
diff options
context:
space:
mode:
authorBen Kochie <superq@gmail.com>2018-11-01 15:38:07 +0300
committerBen Kochie <superq@gmail.com>2018-11-01 15:38:07 +0300
commit53b6d2cc34e956dbbf759ccc72db235c38009089 (patch)
tree794537558b6e166d72d6e615d428f9590cf9d64a
parentd5530ab6715cbf9f365ce833fabeb8d17a37bd9b (diff)
Update vendor google.golang.org/grpc/...@v1.11bjk/grpc_vendor
-rw-r--r--vendor/google.golang.org/grpc/README.md3
-rw-r--r--vendor/google.golang.org/grpc/call.go23
-rw-r--r--vendor/google.golang.org/grpc/clientconn.go31
-rw-r--r--vendor/google.golang.org/grpc/go16.go29
-rw-r--r--vendor/google.golang.org/grpc/go17.go29
-rw-r--r--vendor/google.golang.org/grpc/interceptor.go4
-rw-r--r--vendor/google.golang.org/grpc/metadata/metadata.go8
-rw-r--r--vendor/google.golang.org/grpc/picker_wrapper.go19
-rw-r--r--vendor/google.golang.org/grpc/reflection/serverreflection.go223
-rw-r--r--vendor/google.golang.org/grpc/resolver_conn_wrapper.go5
-rw-r--r--vendor/google.golang.org/grpc/rpc_util.go258
-rw-r--r--vendor/google.golang.org/grpc/server.go84
-rw-r--r--vendor/google.golang.org/grpc/stats/stats.go2
-rw-r--r--vendor/google.golang.org/grpc/status/status.go14
-rw-r--r--vendor/google.golang.org/grpc/stream.go293
-rw-r--r--vendor/google.golang.org/grpc/transport/handler_server.go5
-rw-r--r--vendor/google.golang.org/grpc/transport/http2_client.go19
-rw-r--r--vendor/google.golang.org/grpc/transport/http2_server.go10
-rw-r--r--vendor/google.golang.org/grpc/transport/http_util.go4
-rw-r--r--vendor/google.golang.org/grpc/transport/transport.go23
-rw-r--r--vendor/vendor.json228
21 files changed, 785 insertions, 529 deletions
diff --git a/vendor/google.golang.org/grpc/README.md b/vendor/google.golang.org/grpc/README.md
index 118327bb1..789adfd65 100644
--- a/vendor/google.golang.org/grpc/README.md
+++ b/vendor/google.golang.org/grpc/README.md
@@ -16,8 +16,7 @@ $ go get -u google.golang.org/grpc
Prerequisites
-------------
-This requires Go 1.6 or later. Go 1.7 will be required as of the next gRPC-Go
-release (1.8).
+This requires Go 1.6 or later. Go 1.7 will be required soon.
Constraints
-----------
diff --git a/vendor/google.golang.org/grpc/call.go b/vendor/google.golang.org/grpc/call.go
index a66e3c2d9..f73b7d552 100644
--- a/vendor/google.golang.org/grpc/call.go
+++ b/vendor/google.golang.org/grpc/call.go
@@ -27,12 +27,31 @@ import (
//
// All errors returned by Invoke are compatible with the status package.
func (cc *ClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...CallOption) error {
+ // allow interceptor to see all applicable call options, which means those
+ // configured as defaults from dial option as well as per-call options
+ opts = combine(cc.dopts.callOptions, opts)
+
if cc.dopts.unaryInt != nil {
return cc.dopts.unaryInt(ctx, method, args, reply, cc, invoke, opts...)
}
return invoke(ctx, method, args, reply, cc, opts...)
}
+func combine(o1 []CallOption, o2 []CallOption) []CallOption {
+ // we don't use append because o1 could have extra capacity whose
+ // elements would be overwritten, which could cause inadvertent
+ // sharing (and race connditions) between concurrent calls
+ if len(o1) == 0 {
+ return o2
+ } else if len(o2) == 0 {
+ return o1
+ }
+ ret := make([]CallOption, len(o1)+len(o2))
+ copy(ret, o1)
+ copy(ret[len(o1):], o2)
+ return ret
+}
+
// Invoke sends the RPC request on the wire and returns after response is
// received. This is typically called by generated code.
//
@@ -54,7 +73,7 @@ func invoke(ctx context.Context, method string, req, reply interface{}, cc *Clie
}
cs := csInt.(*clientStream)
if err := cs.SendMsg(req); err != nil {
- if !cs.c.failFast && cs.s.Unprocessed() && firstAttempt {
+ if !cs.c.failFast && cs.attempt.s.Unprocessed() && firstAttempt {
// TODO: Add a field to header for grpc-transparent-retry-attempts
firstAttempt = false
continue
@@ -62,7 +81,7 @@ func invoke(ctx context.Context, method string, req, reply interface{}, cc *Clie
return err
}
if err := cs.RecvMsg(reply); err != nil {
- if !cs.c.failFast && cs.s.Unprocessed() && firstAttempt {
+ if !cs.c.failFast && cs.attempt.s.Unprocessed() && firstAttempt {
// TODO: Add a field to header for grpc-transparent-retry-attempts
firstAttempt = false
continue
diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go
index 208e3c9b6..638540729 100644
--- a/vendor/google.golang.org/grpc/clientconn.go
+++ b/vendor/google.golang.org/grpc/clientconn.go
@@ -45,6 +45,11 @@ import (
"google.golang.org/grpc/transport"
)
+const (
+ // minimum time to give a connection to complete
+ minConnectTimeout = 20 * time.Second
+)
+
var (
// ErrClientConnClosing indicates that the operation is illegal because
// the ClientConn is closing.
@@ -60,8 +65,11 @@ var (
errConnUnavailable = errors.New("grpc: the connection is unavailable")
// errBalancerClosed indicates that the balancer is closed.
errBalancerClosed = errors.New("grpc: balancer is closed")
- // minimum time to give a connection to complete
- minConnectTimeout = 20 * time.Second
+ // We use an accessor so that minConnectTimeout can be
+ // atomically read and updated while testing.
+ getMinConnectTimeout = func() time.Duration {
+ return minConnectTimeout
+ }
)
// The following errors are returned from Dial and DialContext
@@ -435,7 +443,8 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
if cc.dopts.copts.Dialer == nil {
cc.dopts.copts.Dialer = newProxyDialer(
func(ctx context.Context, addr string) (net.Conn, error) {
- return dialContext(ctx, "tcp", addr)
+ network, addr := parseDialTarget(addr)
+ return dialContext(ctx, network, addr)
},
)
}
@@ -883,7 +892,7 @@ func (ac *addrConn) tryUpdateAddrs(addrs []resolver.Address) bool {
// the corresponding MethodConfig.
// If there isn't an exact match for the input method, we look for the default config
// under the service (i.e /service/). If there is a default MethodConfig for
-// the serivce, we return it.
+// the service, we return it.
// Otherwise, we return an empty MethodConfig.
func (cc *ClientConn) GetMethodConfig(method string) MethodConfig {
// TODO: Avoid the locking here.
@@ -944,7 +953,7 @@ func (cc *ClientConn) resolveNow(o resolver.ResolveNowOption) {
// Close tears down the ClientConn and all underlying connections.
func (cc *ClientConn) Close() error {
- cc.cancel()
+ defer cc.cancel()
cc.mu.Lock()
if cc.conns == nil {
@@ -1073,7 +1082,7 @@ func (ac *addrConn) resetTransport() error {
// connection.
backoffFor := ac.dopts.bs.backoff(connectRetryNum) // time.Duration.
// This will be the duration that dial gets to finish.
- dialDuration := minConnectTimeout
+ dialDuration := getMinConnectTimeout()
if backoffFor > dialDuration {
// Give dial more time as we keep failing to connect.
dialDuration = backoffFor
@@ -1147,15 +1156,7 @@ func (ac *addrConn) createTransport(connectRetryNum, ridx int, backoffDeadline,
newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, target, copts, onPrefaceReceipt)
if err != nil {
cancel()
- if e, ok := err.(transport.ConnectionError); ok && !e.Temporary() {
- ac.mu.Lock()
- if ac.state != connectivity.Shutdown {
- ac.state = connectivity.TransientFailure
- ac.cc.handleSubConnStateChange(ac.acbw, ac.state)
- }
- ac.mu.Unlock()
- return false, err
- }
+ ac.cc.blockingpicker.updateConnectionError(err)
ac.mu.Lock()
if ac.state == connectivity.Shutdown {
// ac.tearDown(...) has been invoked.
diff --git a/vendor/google.golang.org/grpc/go16.go b/vendor/google.golang.org/grpc/go16.go
index 0ae4dbda9..535ee9356 100644
--- a/vendor/google.golang.org/grpc/go16.go
+++ b/vendor/google.golang.org/grpc/go16.go
@@ -25,7 +25,6 @@ import (
"io"
"net"
"net/http"
- "os"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
@@ -69,31 +68,3 @@ func toRPCErr(err error) error {
}
return status.Error(codes.Unknown, err.Error())
}
-
-// convertCode converts a standard Go error into its canonical code. Note that
-// this is only used to translate the error returned by the server applications.
-func convertCode(err error) codes.Code {
- switch err {
- case nil:
- return codes.OK
- case io.EOF:
- return codes.OutOfRange
- case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF:
- return codes.FailedPrecondition
- case os.ErrInvalid:
- return codes.InvalidArgument
- case context.Canceled:
- return codes.Canceled
- case context.DeadlineExceeded:
- return codes.DeadlineExceeded
- }
- switch {
- case os.IsExist(err):
- return codes.AlreadyExists
- case os.IsNotExist(err):
- return codes.NotFound
- case os.IsPermission(err):
- return codes.PermissionDenied
- }
- return codes.Unknown
-}
diff --git a/vendor/google.golang.org/grpc/go17.go b/vendor/google.golang.org/grpc/go17.go
index 539088280..ec676a93c 100644
--- a/vendor/google.golang.org/grpc/go17.go
+++ b/vendor/google.golang.org/grpc/go17.go
@@ -26,7 +26,6 @@ import (
"io"
"net"
"net/http"
- "os"
netctx "golang.org/x/net/context"
"google.golang.org/grpc/codes"
@@ -70,31 +69,3 @@ func toRPCErr(err error) error {
}
return status.Error(codes.Unknown, err.Error())
}
-
-// convertCode converts a standard Go error into its canonical code. Note that
-// this is only used to translate the error returned by the server applications.
-func convertCode(err error) codes.Code {
- switch err {
- case nil:
- return codes.OK
- case io.EOF:
- return codes.OutOfRange
- case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF:
- return codes.FailedPrecondition
- case os.ErrInvalid:
- return codes.InvalidArgument
- case context.Canceled, netctx.Canceled:
- return codes.Canceled
- case context.DeadlineExceeded, netctx.DeadlineExceeded:
- return codes.DeadlineExceeded
- }
- switch {
- case os.IsExist(err):
- return codes.AlreadyExists
- case os.IsNotExist(err):
- return codes.NotFound
- case os.IsPermission(err):
- return codes.PermissionDenied
- }
- return codes.Unknown
-}
diff --git a/vendor/google.golang.org/grpc/interceptor.go b/vendor/google.golang.org/grpc/interceptor.go
index 06dc825b9..1f6ef6780 100644
--- a/vendor/google.golang.org/grpc/interceptor.go
+++ b/vendor/google.golang.org/grpc/interceptor.go
@@ -48,7 +48,9 @@ type UnaryServerInfo struct {
}
// UnaryHandler defines the handler invoked by UnaryServerInterceptor to complete the normal
-// execution of a unary RPC.
+// execution of a unary RPC. If a UnaryHandler returns an error, it should be produced by the
+// status package, or else gRPC will use codes.Unknown as the status code and err.Error() as
+// the status message of the RPC.
type UnaryHandler func(ctx context.Context, req interface{}) (interface{}, error)
// UnaryServerInterceptor provides a hook to intercept the execution of a unary RPC on the server. info
diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go
index 15662b5d8..e7c994673 100644
--- a/vendor/google.golang.org/grpc/metadata/metadata.go
+++ b/vendor/google.golang.org/grpc/metadata/metadata.go
@@ -131,7 +131,11 @@ func AppendToOutgoingContext(ctx context.Context, kv ...string) context.Context
panic(fmt.Sprintf("metadata: AppendToOutgoingContext got an odd number of input pairs for metadata: %d", len(kv)))
}
md, _ := ctx.Value(mdOutgoingKey{}).(rawMD)
- return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: md.md, added: append(md.added, kv)})
+ added := make([][]string, len(md.added)+1)
+ copy(added, md.added)
+ added[len(added)-1] = make([]string, len(kv))
+ copy(added[len(added)-1], kv)
+ return context.WithValue(ctx, mdOutgoingKey{}, rawMD{md: md.md, added: added})
}
// FromIncomingContext returns the incoming metadata in ctx if it exists. The
@@ -159,7 +163,7 @@ func FromOutgoingContextRaw(ctx context.Context) (MD, [][]string, bool) {
// FromOutgoingContext returns the outgoing metadata in ctx if it exists. The
// returned MD should not be modified. Writing to it may cause races.
-// Modification should be made to the copies of the returned MD.
+// Modification should be made to copies of the returned MD.
func FromOutgoingContext(ctx context.Context) (MD, bool) {
raw, ok := ctx.Value(mdOutgoingKey{}).(rawMD)
if !ok {
diff --git a/vendor/google.golang.org/grpc/picker_wrapper.go b/vendor/google.golang.org/grpc/picker_wrapper.go
index db82bfb3a..4d0082593 100644
--- a/vendor/google.golang.org/grpc/picker_wrapper.go
+++ b/vendor/google.golang.org/grpc/picker_wrapper.go
@@ -36,6 +36,10 @@ type pickerWrapper struct {
done bool
blockingCh chan struct{}
picker balancer.Picker
+
+ // The latest connection happened.
+ connErrMu sync.Mutex
+ connErr error
}
func newPickerWrapper() *pickerWrapper {
@@ -43,6 +47,19 @@ func newPickerWrapper() *pickerWrapper {
return bp
}
+func (bp *pickerWrapper) updateConnectionError(err error) {
+ bp.connErrMu.Lock()
+ bp.connErr = err
+ bp.connErrMu.Unlock()
+}
+
+func (bp *pickerWrapper) connectionError() error {
+ bp.connErrMu.Lock()
+ err := bp.connErr
+ bp.connErrMu.Unlock()
+ return err
+}
+
// updatePicker is called by UpdateBalancerState. It unblocks all blocked pick.
func (bp *pickerWrapper) updatePicker(p balancer.Picker) {
bp.mu.Lock()
@@ -107,7 +124,7 @@ func (bp *pickerWrapper) pick(ctx context.Context, failfast bool, opts balancer.
if !failfast {
continue
}
- return nil, nil, status.Errorf(codes.Unavailable, "%v", err)
+ return nil, nil, status.Errorf(codes.Unavailable, "%v, latest connection error: %v", err, bp.connectionError())
default:
// err is some other error.
return nil, nil, toRPCErr(err)
diff --git a/vendor/google.golang.org/grpc/reflection/serverreflection.go b/vendor/google.golang.org/grpc/reflection/serverreflection.go
index 1bfbf3e78..dd22a2da7 100644
--- a/vendor/google.golang.org/grpc/reflection/serverreflection.go
+++ b/vendor/google.golang.org/grpc/reflection/serverreflection.go
@@ -45,7 +45,8 @@ import (
"io"
"io/ioutil"
"reflect"
- "strings"
+ "sort"
+ "sync"
"github.com/golang/protobuf/proto"
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
@@ -57,8 +58,10 @@ import (
type serverReflectionServer struct {
s *grpc.Server
- // TODO add more cache if necessary
- serviceInfo map[string]grpc.ServiceInfo // cache for s.GetServiceInfo()
+
+ initSymbols sync.Once
+ serviceNames []string
+ symbols map[string]*dpb.FileDescriptorProto // map of fully-qualified names to files
}
// Register registers the server reflection service on the given gRPC server.
@@ -76,6 +79,112 @@ type protoMessage interface {
Descriptor() ([]byte, []int)
}
+func (s *serverReflectionServer) getSymbols() (svcNames []string, symbolIndex map[string]*dpb.FileDescriptorProto) {
+ s.initSymbols.Do(func() {
+ serviceInfo := s.s.GetServiceInfo()
+
+ s.symbols = map[string]*dpb.FileDescriptorProto{}
+ s.serviceNames = make([]string, 0, len(serviceInfo))
+ processed := map[string]struct{}{}
+ for svc, info := range serviceInfo {
+ s.serviceNames = append(s.serviceNames, svc)
+ fdenc, ok := parseMetadata(info.Metadata)
+ if !ok {
+ continue
+ }
+ fd, err := decodeFileDesc(fdenc)
+ if err != nil {
+ continue
+ }
+ s.processFile(fd, processed)
+ }
+ sort.Strings(s.serviceNames)
+ })
+
+ return s.serviceNames, s.symbols
+}
+
+func (s *serverReflectionServer) processFile(fd *dpb.FileDescriptorProto, processed map[string]struct{}) {
+ filename := fd.GetName()
+ if _, ok := processed[filename]; ok {
+ return
+ }
+ processed[filename] = struct{}{}
+
+ prefix := fd.GetPackage()
+
+ for _, msg := range fd.MessageType {
+ s.processMessage(fd, prefix, msg)
+ }
+ for _, en := range fd.EnumType {
+ s.processEnum(fd, prefix, en)
+ }
+ for _, ext := range fd.Extension {
+ s.processField(fd, prefix, ext)
+ }
+ for _, svc := range fd.Service {
+ svcName := fqn(prefix, svc.GetName())
+ s.symbols[svcName] = fd
+ for _, meth := range svc.Method {
+ name := fqn(svcName, meth.GetName())
+ s.symbols[name] = fd
+ }
+ }
+
+ for _, dep := range fd.Dependency {
+ fdenc := proto.FileDescriptor(dep)
+ fdDep, err := decodeFileDesc(fdenc)
+ if err != nil {
+ continue
+ }
+ s.processFile(fdDep, processed)
+ }
+}
+
+func (s *serverReflectionServer) processMessage(fd *dpb.FileDescriptorProto, prefix string, msg *dpb.DescriptorProto) {
+ msgName := fqn(prefix, msg.GetName())
+ s.symbols[msgName] = fd
+
+ for _, nested := range msg.NestedType {
+ s.processMessage(fd, msgName, nested)
+ }
+ for _, en := range msg.EnumType {
+ s.processEnum(fd, msgName, en)
+ }
+ for _, ext := range msg.Extension {
+ s.processField(fd, msgName, ext)
+ }
+ for _, fld := range msg.Field {
+ s.processField(fd, msgName, fld)
+ }
+ for _, oneof := range msg.OneofDecl {
+ oneofName := fqn(msgName, oneof.GetName())
+ s.symbols[oneofName] = fd
+ }
+}
+
+func (s *serverReflectionServer) processEnum(fd *dpb.FileDescriptorProto, prefix string, en *dpb.EnumDescriptorProto) {
+ enName := fqn(prefix, en.GetName())
+ s.symbols[enName] = fd
+
+ for _, val := range en.Value {
+ valName := fqn(enName, val.GetName())
+ s.symbols[valName] = fd
+ }
+}
+
+func (s *serverReflectionServer) processField(fd *dpb.FileDescriptorProto, prefix string, fld *dpb.FieldDescriptorProto) {
+ fldName := fqn(prefix, fld.GetName())
+ s.symbols[fldName] = fd
+}
+
+func fqn(prefix, name string) string {
+ if prefix == "" {
+ return name
+ }
+ return prefix + "." + name
+}
+
// fileDescForType gets the file descriptor for the given type.
// The given type should be a proto message.
func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) {
@@ -85,12 +194,12 @@ func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDesc
}
enc, _ := m.Descriptor()
- return s.decodeFileDesc(enc)
+ return decodeFileDesc(enc)
}
// decodeFileDesc does decompression and unmarshalling on the given
// file descriptor byte slice.
-func (s *serverReflectionServer) decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) {
+func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) {
raw, err := decompress(enc)
if err != nil {
return nil, fmt.Errorf("failed to decompress enc: %v", err)
@@ -116,7 +225,7 @@ func decompress(b []byte) ([]byte, error) {
return out, nil
}
-func (s *serverReflectionServer) typeForName(name string) (reflect.Type, error) {
+func typeForName(name string) (reflect.Type, error) {
pt := proto.MessageType(name)
if pt == nil {
return nil, fmt.Errorf("unknown type: %q", name)
@@ -126,7 +235,7 @@ func (s *serverReflectionServer) typeForName(name string) (reflect.Type, error)
return st, nil
}
-func (s *serverReflectionServer) fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescriptorProto, error) {
+func fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescriptorProto, error) {
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to create message from type: %v", st)
@@ -144,7 +253,7 @@ func (s *serverReflectionServer) fileDescContainingExtension(st reflect.Type, ex
return nil, fmt.Errorf("failed to find registered extension for extension number %v", ext)
}
- return s.decodeFileDesc(proto.FileDescriptor(extDesc.Filename))
+ return decodeFileDesc(proto.FileDescriptor(extDesc.Filename))
}
func (s *serverReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]int32, error) {
@@ -168,53 +277,13 @@ func (s *serverReflectionServer) fileDescEncodingByFilename(name string) ([]byte
if enc == nil {
return nil, fmt.Errorf("unknown file: %v", name)
}
- fd, err := s.decodeFileDesc(enc)
+ fd, err := decodeFileDesc(enc)
if err != nil {
return nil, err
}
return proto.Marshal(fd)
}
-// serviceMetadataForSymbol finds the metadata for name in s.serviceInfo.
-// name should be a service name or a method name.
-func (s *serverReflectionServer) serviceMetadataForSymbol(name string) (interface{}, error) {
- if s.serviceInfo == nil {
- s.serviceInfo = s.s.GetServiceInfo()
- }
-
- // Check if it's a service name.
- if info, ok := s.serviceInfo[name]; ok {
- return info.Metadata, nil
- }
-
- // Check if it's a method name.
- pos := strings.LastIndex(name, ".")
- // Not a valid method name.
- if pos == -1 {
- return nil, fmt.Errorf("unknown symbol: %v", name)
- }
-
- info, ok := s.serviceInfo[name[:pos]]
- // Substring before last "." is not a service name.
- if !ok {
- return nil, fmt.Errorf("unknown symbol: %v", name)
- }
-
- // Search the method name in info.Methods.
- var found bool
- for _, m := range info.Methods {
- if m.Name == name[pos+1:] {
- found = true
- break
- }
- }
- if found {
- return info.Metadata, nil
- }
-
- return nil, fmt.Errorf("unknown symbol: %v", name)
-}
-
// parseMetadata finds the file descriptor bytes specified meta.
// For SupportPackageIsVersion4, m is the name of the proto file, we
// call proto.FileDescriptor to get the byte slice.
@@ -237,33 +306,21 @@ func parseMetadata(meta interface{}) ([]byte, bool) {
// does marshalling on it and returns the marshalled result.
// The given symbol can be a type, a service or a method.
func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string) ([]byte, error) {
- var (
- fd *dpb.FileDescriptorProto
- )
- // Check if it's a type name.
- if st, err := s.typeForName(name); err == nil {
- fd, err = s.fileDescForType(st)
- if err != nil {
- return nil, err
- }
- } else { // Check if it's a service name or a method name.
- meta, err := s.serviceMetadataForSymbol(name)
-
- // Metadata not found.
- if err != nil {
- return nil, err
- }
-
- // Metadata not valid.
- enc, ok := parseMetadata(meta)
- if !ok {
- return nil, fmt.Errorf("invalid file descriptor for symbol: %v", name)
+ _, symbols := s.getSymbols()
+ fd := symbols[name]
+ if fd == nil {
+ // Check if it's a type name that was not present in the
+ // transitive dependencies of the registered services.
+ if st, err := typeForName(name); err == nil {
+ fd, err = s.fileDescForType(st)
+ if err != nil {
+ return nil, err
+ }
}
+ }
- fd, err = s.decodeFileDesc(enc)
- if err != nil {
- return nil, err
- }
+ if fd == nil {
+ return nil, fmt.Errorf("unknown symbol: %v", name)
}
return proto.Marshal(fd)
@@ -272,11 +329,11 @@ func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string) (
// fileDescEncodingContainingExtension finds the file descriptor containing given extension,
// does marshalling on it and returns the marshalled result.
func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32) ([]byte, error) {
- st, err := s.typeForName(typeName)
+ st, err := typeForName(typeName)
if err != nil {
return nil, err
}
- fd, err := s.fileDescContainingExtension(st, extNum)
+ fd, err := fileDescContainingExtension(st, extNum)
if err != nil {
return nil, err
}
@@ -285,7 +342,7 @@ func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName st
// allExtensionNumbersForTypeName returns all extension numbers for the given type.
func (s *serverReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) {
- st, err := s.typeForName(name)
+ st, err := typeForName(name)
if err != nil {
return nil, err
}
@@ -374,14 +431,12 @@ func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflectio
}
}
case *rpb.ServerReflectionRequest_ListServices:
- if s.serviceInfo == nil {
- s.serviceInfo = s.s.GetServiceInfo()
- }
- serviceResponses := make([]*rpb.ServiceResponse, 0, len(s.serviceInfo))
- for n := range s.serviceInfo {
- serviceResponses = append(serviceResponses, &rpb.ServiceResponse{
+ svcNames, _ := s.getSymbols()
+ serviceResponses := make([]*rpb.ServiceResponse, len(svcNames))
+ for i, n := range svcNames {
+ serviceResponses[i] = &rpb.ServiceResponse{
Name: n,
- })
+ }
}
out.MessageResponse = &rpb.ServerReflectionResponse_ListServicesResponse{
ListServicesResponse: &rpb.ListServiceResponse{
diff --git a/vendor/google.golang.org/grpc/resolver_conn_wrapper.go b/vendor/google.golang.org/grpc/resolver_conn_wrapper.go
index d394c5349..75b8ce1eb 100644
--- a/vendor/google.golang.org/grpc/resolver_conn_wrapper.go
+++ b/vendor/google.golang.org/grpc/resolver_conn_wrapper.go
@@ -57,7 +57,10 @@ func parseTarget(target string) (ret resolver.Target) {
if !ok {
return resolver.Target{Endpoint: target}
}
- ret.Authority, ret.Endpoint, _ = split2(ret.Endpoint, "/")
+ ret.Authority, ret.Endpoint, ok = split2(ret.Endpoint, "/")
+ if !ok {
+ return resolver.Target{Endpoint: target}
+ }
return ret
}
diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go
index 58e6c538e..00a997660 100644
--- a/vendor/google.golang.org/grpc/rpc_util.go
+++ b/vendor/google.golang.org/grpc/rpc_util.go
@@ -22,9 +22,11 @@ import (
"bytes"
"compress/gzip"
"encoding/binary"
+ "fmt"
"io"
"io/ioutil"
"math"
+ "net/url"
"strings"
"sync"
"time"
@@ -55,13 +57,29 @@ type gzipCompressor struct {
// NewGZIPCompressor creates a Compressor based on GZIP.
func NewGZIPCompressor() Compressor {
+ c, _ := NewGZIPCompressorWithLevel(gzip.DefaultCompression)
+ return c
+}
+
+// NewGZIPCompressorWithLevel is like NewGZIPCompressor but specifies the gzip compression level instead
+// of assuming DefaultCompression.
+//
+// The error returned will be nil if the level is valid.
+func NewGZIPCompressorWithLevel(level int) (Compressor, error) {
+ if level < gzip.DefaultCompression || level > gzip.BestCompression {
+ return nil, fmt.Errorf("grpc: invalid compression level: %d", level)
+ }
return &gzipCompressor{
pool: sync.Pool{
New: func() interface{} {
- return gzip.NewWriter(ioutil.Discard)
+ w, err := gzip.NewWriterLevel(ioutil.Discard, level)
+ if err != nil {
+ panic(err)
+ }
+ return w
},
},
- }
+ }, nil
}
func (c *gzipCompressor) Do(w io.Writer, p []byte) error {
@@ -127,7 +145,7 @@ func (d *gzipDecompressor) Type() string {
type callInfo struct {
compressorType string
failFast bool
- stream *transport.Stream
+ stream *clientStream
traceInfo traceInfo // in trace.go
maxReceiveMessageSize *int
maxSendMessageSize *int
@@ -160,46 +178,66 @@ type EmptyCallOption struct{}
func (EmptyCallOption) before(*callInfo) error { return nil }
func (EmptyCallOption) after(*callInfo) {}
-type beforeCall func(c *callInfo) error
-
-func (o beforeCall) before(c *callInfo) error { return o(c) }
-func (o beforeCall) after(c *callInfo) {}
-
-type afterCall func(c *callInfo)
-
-func (o afterCall) before(c *callInfo) error { return nil }
-func (o afterCall) after(c *callInfo) { o(c) }
-
// Header returns a CallOptions that retrieves the header metadata
// for a unary RPC.
func Header(md *metadata.MD) CallOption {
- return afterCall(func(c *callInfo) {
- if c.stream != nil {
- *md, _ = c.stream.Header()
- }
- })
+ return HeaderCallOption{HeaderAddr: md}
+}
+
+// HeaderCallOption is a CallOption for collecting response header metadata.
+// The metadata field will be populated *after* the RPC completes.
+// This is an EXPERIMENTAL API.
+type HeaderCallOption struct {
+ HeaderAddr *metadata.MD
+}
+
+func (o HeaderCallOption) before(c *callInfo) error { return nil }
+func (o HeaderCallOption) after(c *callInfo) {
+ if c.stream != nil {
+ *o.HeaderAddr, _ = c.stream.Header()
+ }
}
// Trailer returns a CallOptions that retrieves the trailer metadata
// for a unary RPC.
func Trailer(md *metadata.MD) CallOption {
- return afterCall(func(c *callInfo) {
- if c.stream != nil {
- *md = c.stream.Trailer()
- }
- })
+ return TrailerCallOption{TrailerAddr: md}
+}
+
+// TrailerCallOption is a CallOption for collecting response trailer metadata.
+// The metadata field will be populated *after* the RPC completes.
+// This is an EXPERIMENTAL API.
+type TrailerCallOption struct {
+ TrailerAddr *metadata.MD
+}
+
+func (o TrailerCallOption) before(c *callInfo) error { return nil }
+func (o TrailerCallOption) after(c *callInfo) {
+ if c.stream != nil {
+ *o.TrailerAddr = c.stream.Trailer()
+ }
}
// Peer returns a CallOption that retrieves peer information for a
// unary RPC.
func Peer(p *peer.Peer) CallOption {
- return afterCall(func(c *callInfo) {
- if c.stream != nil {
- if x, ok := peer.FromContext(c.stream.Context()); ok {
- *p = *x
- }
+ return PeerCallOption{PeerAddr: p}
+}
+
+// PeerCallOption is a CallOption for collecting the identity of the remote
+// peer. The peer field will be populated *after* the RPC completes.
+// This is an EXPERIMENTAL API.
+type PeerCallOption struct {
+ PeerAddr *peer.Peer
+}
+
+func (o PeerCallOption) before(c *callInfo) error { return nil }
+func (o PeerCallOption) after(c *callInfo) {
+ if c.stream != nil {
+ if x, ok := peer.FromContext(c.stream.Context()); ok {
+ *o.PeerAddr = *x
}
- })
+ }
}
// FailFast configures the action to take when an RPC is attempted on broken
@@ -213,36 +251,76 @@ func Peer(p *peer.Peer) CallOption {
//
// By default, RPCs are "Fail Fast".
func FailFast(failFast bool) CallOption {
- return beforeCall(func(c *callInfo) error {
- c.failFast = failFast
- return nil
- })
+ return FailFastCallOption{FailFast: failFast}
+}
+
+// FailFastCallOption is a CallOption for indicating whether an RPC should fail
+// fast or not.
+// This is an EXPERIMENTAL API.
+type FailFastCallOption struct {
+ FailFast bool
}
+func (o FailFastCallOption) before(c *callInfo) error {
+ c.failFast = o.FailFast
+ return nil
+}
+func (o FailFastCallOption) after(c *callInfo) { return }
+
// MaxCallRecvMsgSize returns a CallOption which sets the maximum message size the client can receive.
func MaxCallRecvMsgSize(s int) CallOption {
- return beforeCall(func(o *callInfo) error {
- o.maxReceiveMessageSize = &s
- return nil
- })
+ return MaxRecvMsgSizeCallOption{MaxRecvMsgSize: s}
+}
+
+// MaxRecvMsgSizeCallOption is a CallOption that indicates the maximum message
+// size the client can receive.
+// This is an EXPERIMENTAL API.
+type MaxRecvMsgSizeCallOption struct {
+ MaxRecvMsgSize int
}
+func (o MaxRecvMsgSizeCallOption) before(c *callInfo) error {
+ c.maxReceiveMessageSize = &o.MaxRecvMsgSize
+ return nil
+}
+func (o MaxRecvMsgSizeCallOption) after(c *callInfo) { return }
+
// MaxCallSendMsgSize returns a CallOption which sets the maximum message size the client can send.
func MaxCallSendMsgSize(s int) CallOption {
- return beforeCall(func(o *callInfo) error {
- o.maxSendMessageSize = &s
- return nil
- })
+ return MaxSendMsgSizeCallOption{MaxSendMsgSize: s}
}
+// MaxSendMsgSizeCallOption is a CallOption that indicates the maximum message
+// size the client can send.
+// This is an EXPERIMENTAL API.
+type MaxSendMsgSizeCallOption struct {
+ MaxSendMsgSize int
+}
+
+func (o MaxSendMsgSizeCallOption) before(c *callInfo) error {
+ c.maxSendMessageSize = &o.MaxSendMsgSize
+ return nil
+}
+func (o MaxSendMsgSizeCallOption) after(c *callInfo) { return }
+
// PerRPCCredentials returns a CallOption that sets credentials.PerRPCCredentials
// for a call.
func PerRPCCredentials(creds credentials.PerRPCCredentials) CallOption {
- return beforeCall(func(c *callInfo) error {
- c.creds = creds
- return nil
- })
+ return PerRPCCredsCallOption{Creds: creds}
+}
+
+// PerRPCCredsCallOption is a CallOption that indicates the per-RPC
+// credentials to use for the call.
+// This is an EXPERIMENTAL API.
+type PerRPCCredsCallOption struct {
+ Creds credentials.PerRPCCredentials
+}
+
+func (o PerRPCCredsCallOption) before(c *callInfo) error {
+ c.creds = o.Creds
+ return nil
}
+func (o PerRPCCredsCallOption) after(c *callInfo) { return }
// UseCompressor returns a CallOption which sets the compressor used when
// sending the request. If WithCompressor is also set, UseCompressor has
@@ -250,11 +328,20 @@ func PerRPCCredentials(creds credentials.PerRPCCredentials) CallOption {
//
// This API is EXPERIMENTAL.
func UseCompressor(name string) CallOption {
- return beforeCall(func(c *callInfo) error {
- c.compressorType = name
- return nil
- })
+ return CompressorCallOption{CompressorType: name}
+}
+
+// CompressorCallOption is a CallOption that indicates the compressor to use.
+// This is an EXPERIMENTAL API.
+type CompressorCallOption struct {
+ CompressorType string
+}
+
+func (o CompressorCallOption) before(c *callInfo) error {
+ c.compressorType = o.CompressorType
+ return nil
}
+func (o CompressorCallOption) after(c *callInfo) { return }
// CallContentSubtype returns a CallOption that will set the content-subtype
// for a call. For example, if content-subtype is "json", the Content-Type over
@@ -273,13 +360,22 @@ func UseCompressor(name string) CallOption {
// response messages, with the content-subtype set to the given contentSubtype
// here for requests.
func CallContentSubtype(contentSubtype string) CallOption {
- contentSubtype = strings.ToLower(contentSubtype)
- return beforeCall(func(c *callInfo) error {
- c.contentSubtype = contentSubtype
- return nil
- })
+ return ContentSubtypeCallOption{ContentSubtype: strings.ToLower(contentSubtype)}
}
+// ContentSubtypeCallOption is a CallOption that indicates the content-subtype
+// used for marshaling messages.
+// This is an EXPERIMENTAL API.
+type ContentSubtypeCallOption struct {
+ ContentSubtype string
+}
+
+func (o ContentSubtypeCallOption) before(c *callInfo) error {
+ c.contentSubtype = o.ContentSubtype
+ return nil
+}
+func (o ContentSubtypeCallOption) after(c *callInfo) { return }
+
// CallCustomCodec returns a CallOption that will set the given Codec to be
// used for all request and response messages for a call. The result of calling
// String() will be used as the content-subtype in a case-insensitive manner.
@@ -293,12 +389,22 @@ func CallContentSubtype(contentSubtype string) CallOption {
// This function is provided for advanced users; prefer to use only
// CallContentSubtype to select a registered codec instead.
func CallCustomCodec(codec Codec) CallOption {
- return beforeCall(func(c *callInfo) error {
- c.codec = codec
- return nil
- })
+ return CustomCodecCallOption{Codec: codec}
+}
+
+// CustomCodecCallOption is a CallOption that indicates the codec used for
+// marshaling messages.
+// This is an EXPERIMENTAL API.
+type CustomCodecCallOption struct {
+ Codec Codec
}
+func (o CustomCodecCallOption) before(c *callInfo) error {
+ c.codec = o.Codec
+ return nil
+}
+func (o CustomCodecCallOption) after(c *callInfo) { return }
+
// The format of the payload: compressed or not?
type payloadFormat uint8
@@ -557,6 +663,40 @@ func setCallInfoCodec(c *callInfo) error {
return nil
}
+// parseDialTarget returns the network and address to pass to dialer
+func parseDialTarget(target string) (net string, addr string) {
+ net = "tcp"
+
+ m1 := strings.Index(target, ":")
+ m2 := strings.Index(target, ":/")
+
+ // handle unix:addr which will fail with url.Parse
+ if m1 >= 0 && m2 < 0 {
+ if n := target[0:m1]; n == "unix" {
+ net = n
+ addr = target[m1+1:]
+ return net, addr
+ }
+ }
+ if m2 >= 0 {
+ t, err := url.Parse(target)
+ if err != nil {
+ return net, target
+ }
+ scheme := t.Scheme
+ addr = t.Path
+ if scheme == "unix" {
+ net = scheme
+ if addr == "" {
+ addr = t.Host
+ }
+ return net, addr
+ }
+ }
+
+ return net, target
+}
+
// The SupportPackageIsVersion variables are referenced from generated protocol
// buffer files to ensure compatibility with the gRPC version used. The latest
// support package version is 5.
@@ -572,6 +712,6 @@ const (
)
// Version is the current grpc version.
-const Version = "1.10.1"
+const Version = "1.11.3"
const grpcUA = "grpc-go/" + Version
diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go
index 0f7ff5d60..c6b413b9d 100644
--- a/vendor/google.golang.org/grpc/server.go
+++ b/vendor/google.golang.org/grpc/server.go
@@ -777,13 +777,15 @@ func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Str
func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, md *MethodDesc, trInfo *traceInfo) (err error) {
sh := s.opts.statsHandler
if sh != nil {
+ beginTime := time.Now()
begin := &stats.Begin{
- BeginTime: time.Now(),
+ BeginTime: beginTime,
}
sh.HandleRPC(stream.Context(), begin)
defer func() {
end := &stats.End{
- EndTime: time.Now(),
+ BeginTime: beginTime,
+ EndTime: time.Now(),
}
if err != nil && err != io.EOF {
end.Error = toRPCErr(err)
@@ -917,12 +919,13 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
}
return nil
}
- reply, appErr := md.Handler(srv.server, stream.Context(), df, s.opts.unaryInt)
+ ctx := NewContextWithServerTransportStream(stream.Context(), stream)
+ reply, appErr := md.Handler(srv.server, ctx, df, s.opts.unaryInt)
if appErr != nil {
appStatus, ok := status.FromError(appErr)
if !ok {
// Convert appErr if it is not a grpc status error.
- appErr = status.Error(convertCode(appErr), appErr.Error())
+ appErr = status.Error(codes.Unknown, appErr.Error())
appStatus, _ = status.FromError(appErr)
}
if trInfo != nil {
@@ -977,13 +980,15 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, sd *StreamDesc, trInfo *traceInfo) (err error) {
sh := s.opts.statsHandler
if sh != nil {
+ beginTime := time.Now()
begin := &stats.Begin{
- BeginTime: time.Now(),
+ BeginTime: beginTime,
}
sh.HandleRPC(stream.Context(), begin)
defer func() {
end := &stats.End{
- EndTime: time.Now(),
+ BeginTime: beginTime,
+ EndTime: time.Now(),
}
if err != nil && err != io.EOF {
end.Error = toRPCErr(err)
@@ -991,7 +996,9 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
sh.HandleRPC(stream.Context(), end)
}()
}
+ ctx := NewContextWithServerTransportStream(stream.Context(), stream)
ss := &serverStream{
+ ctx: ctx,
t: t,
s: stream,
p: &parser{r: stream},
@@ -1065,7 +1072,7 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
case transport.StreamError:
appStatus = status.New(err.Code, err.Desc)
default:
- appStatus = status.New(convertCode(appErr), appErr.Error())
+ appStatus = status.New(codes.Unknown, appErr.Error())
}
appErr = appStatus.Err()
}
@@ -1085,7 +1092,6 @@ func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transp
ss.mu.Unlock()
}
return t.WriteStatus(ss.s, status.New(codes.OK, ""))
-
}
func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Stream, trInfo *traceInfo) {
@@ -1167,6 +1173,40 @@ func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Str
}
}
+// The key to save ServerTransportStream in the context.
+type streamKey struct{}
+
+// NewContextWithServerTransportStream creates a new context from ctx and
+// attaches stream to it.
+//
+// This API is EXPERIMENTAL.
+func NewContextWithServerTransportStream(ctx context.Context, stream ServerTransportStream) context.Context {
+ return context.WithValue(ctx, streamKey{}, stream)
+}
+
+// ServerTransportStream is a minimal interface that a transport stream must
+// implement. This can be used to mock an actual transport stream for tests of
+// handler code that use, for example, grpc.SetHeader (which requires some
+// stream to be in context).
+//
+// See also NewContextWithServerTransportStream.
+//
+// This API is EXPERIMENTAL.
+type ServerTransportStream interface {
+ Method() string
+ SetHeader(md metadata.MD) error
+ SendHeader(md metadata.MD) error
+ SetTrailer(md metadata.MD) error
+}
+
+// serverStreamFromContext returns the server stream saved in ctx. Returns
+// nil if the given context has no stream associated with it (which implies
+// it is not an RPC invocation context).
+func serverTransportStreamFromContext(ctx context.Context) ServerTransportStream {
+ s, _ := ctx.Value(streamKey{}).(ServerTransportStream)
+ return s
+}
+
// Stop stops the gRPC server. It immediately closes all open
// connections and listeners.
// It cancels all active RPCs on the server side and the corresponding
@@ -1287,8 +1327,8 @@ func SetHeader(ctx context.Context, md metadata.MD) error {
if md.Len() == 0 {
return nil
}
- stream, ok := transport.StreamFromContext(ctx)
- if !ok {
+ stream := serverTransportStreamFromContext(ctx)
+ if stream == nil {
return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
}
return stream.SetHeader(md)
@@ -1297,15 +1337,11 @@ func SetHeader(ctx context.Context, md metadata.MD) error {
// SendHeader sends header metadata. It may be called at most once.
// The provided md and headers set by SetHeader() will be sent.
func SendHeader(ctx context.Context, md metadata.MD) error {
- stream, ok := transport.StreamFromContext(ctx)
- if !ok {
+ stream := serverTransportStreamFromContext(ctx)
+ if stream == nil {
return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
}
- t := stream.ServerTransport()
- if t == nil {
- grpclog.Fatalf("grpc: SendHeader: %v has no ServerTransport to send header metadata.", stream)
- }
- if err := t.WriteHeader(stream, md); err != nil {
+ if err := stream.SendHeader(md); err != nil {
return toRPCErr(err)
}
return nil
@@ -1317,9 +1353,19 @@ func SetTrailer(ctx context.Context, md metadata.MD) error {
if md.Len() == 0 {
return nil
}
- stream, ok := transport.StreamFromContext(ctx)
- if !ok {
+ stream := serverTransportStreamFromContext(ctx)
+ if stream == nil {
return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
}
return stream.SetTrailer(md)
}
+
+// Method returns the method string for the server context. The returned
+// string is in the format of "/service/method".
+func Method(ctx context.Context) (string, bool) {
+ s := serverTransportStreamFromContext(ctx)
+ if s == nil {
+ return "", false
+ }
+ return s.Method(), true
+}
diff --git a/vendor/google.golang.org/grpc/stats/stats.go b/vendor/google.golang.org/grpc/stats/stats.go
index d5aa2f793..3f13190a0 100644
--- a/vendor/google.golang.org/grpc/stats/stats.go
+++ b/vendor/google.golang.org/grpc/stats/stats.go
@@ -169,6 +169,8 @@ func (s *OutTrailer) isRPCStats() {}
type End struct {
// Client is true if this End is from client side.
Client bool
+ // BeginTime is the time when the RPC began.
+ BeginTime time.Time
// EndTime is the time when the RPC ends.
EndTime time.Time
// Error is the error the RPC ended with. It is an error generated from
diff --git a/vendor/google.golang.org/grpc/status/status.go b/vendor/google.golang.org/grpc/status/status.go
index 3a42dc6de..9c61b0945 100644
--- a/vendor/google.golang.org/grpc/status/status.go
+++ b/vendor/google.golang.org/grpc/status/status.go
@@ -46,7 +46,7 @@ func (se *statusError) Error() string {
return fmt.Sprintf("rpc error: code = %s desc = %s", codes.Code(p.GetCode()), p.GetMessage())
}
-func (se *statusError) status() *Status {
+func (se *statusError) GRPCStatus() *Status {
return &Status{s: (*spb.Status)(se)}
}
@@ -120,14 +120,14 @@ func FromProto(s *spb.Status) *Status {
}
// FromError returns a Status representing err if it was produced from this
-// package. Otherwise, ok is false and a Status is returned with codes.Unknown
-// and the original error message.
+// package or has a method `GRPCStatus() *Status`. Otherwise, ok is false and a
+// Status is returned with codes.Unknown and the original error message.
func FromError(err error) (s *Status, ok bool) {
if err == nil {
return &Status{s: &spb.Status{Code: int32(codes.OK)}}, true
}
- if se, ok := err.(*statusError); ok {
- return se.status(), true
+ if se, ok := err.(interface{ GRPCStatus() *Status }); ok {
+ return se.GRPCStatus(), true
}
return New(codes.Unknown, err.Error()), false
}
@@ -182,8 +182,8 @@ func Code(err error) codes.Code {
if err == nil {
return codes.OK
}
- if se, ok := err.(*statusError); ok {
- return se.status().Code()
+ if se, ok := err.(interface{ GRPCStatus() *Status }); ok {
+ return se.GRPCStatus().Code()
}
return codes.Unknown
}
diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go
index deb735927..75a4e8d45 100644
--- a/vendor/google.golang.org/grpc/stream.go
+++ b/vendor/google.golang.org/grpc/stream.go
@@ -36,7 +36,10 @@ import (
)
// StreamHandler defines the handler called by gRPC server to complete the
-// execution of a streaming RPC.
+// execution of a streaming RPC. If a StreamHandler returns an error, it
+// should be produced by the status package, or else gRPC will use
+// codes.Unknown as the status code and err.Error() as the status message
+// of the RPC.
type StreamHandler func(srv interface{}, stream ServerStream) error
// StreamDesc represents a streaming RPC service's method specification.
@@ -99,6 +102,10 @@ type ClientStream interface {
// NewStream creates a new Stream for the client side. This is typically
// called by generated code.
func (cc *ClientConn) NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error) {
+ // allow interceptor to see all applicable call options, which means those
+ // configured as defaults from dial option as well as per-call options
+ opts = combine(cc.dopts.callOptions, opts)
+
if cc.dopts.streamInt != nil {
return cc.dopts.streamInt(ctx, desc, cc, method, newClientStream, opts...)
}
@@ -137,7 +144,6 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
}
}()
- opts = append(cc.dopts.callOptions, opts...)
for _, o := range opts {
if err := o.before(c); err != nil {
return nil, toRPCErr(err)
@@ -202,11 +208,13 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
}
ctx = newContextWithRPCInfo(ctx, c.failFast)
sh := cc.dopts.copts.StatsHandler
+ var beginTime time.Time
if sh != nil {
ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method, FailFast: c.failFast})
+ beginTime = time.Now()
begin := &stats.Begin{
Client: true,
- BeginTime: time.Now(),
+ BeginTime: beginTime,
FailFast: c.failFast,
}
sh.HandleRPC(ctx, begin)
@@ -214,8 +222,10 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
if err != nil {
// Only handle end stats if err != nil.
end := &stats.End{
- Client: true,
- Error: err,
+ Client: true,
+ Error: err,
+ BeginTime: beginTime,
+ EndTime: time.Now(),
}
sh.HandleRPC(ctx, end)
}
@@ -259,28 +269,28 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
break
}
- c.stream = s
cs := &clientStream{
opts: opts,
c: c,
desc: desc,
codec: c.codec,
cp: cp,
- dc: cc.dopts.dc,
comp: comp,
cancel: cancel,
-
- done: done,
- t: t,
- s: s,
- p: &parser{r: s},
-
- tracing: EnableTracing,
- trInfo: trInfo,
-
- statsCtx: ctx,
- statsHandler: cc.dopts.copts.StatsHandler,
- }
+ attempt: &csAttempt{
+ t: t,
+ s: s,
+ p: &parser{r: s},
+ done: done,
+ dc: cc.dopts.dc,
+ ctx: ctx,
+ trInfo: trInfo,
+ statsHandler: sh,
+ beginTime: beginTime,
+ },
+ }
+ cs.c.stream = cs
+ cs.attempt.cs = cs
if desc != unaryStreamDesc {
// Listen on cc and stream contexts to cleanup when the user closes the
// ClientConn or cancels the stream context. In all other cases, an error
@@ -292,7 +302,7 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
case <-cc.ctx.Done():
cs.finish(ErrClientConnClosing)
case <-ctx.Done():
- cs.finish(toRPCErr(s.Context().Err()))
+ cs.finish(toRPCErr(ctx.Err()))
}
}()
}
@@ -303,46 +313,56 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
type clientStream struct {
opts []CallOption
c *callInfo
+ desc *StreamDesc
+
+ codec baseCodec
+ cp Compressor
+ comp encoding.Compressor
+
+ cancel context.CancelFunc // cancels all attempts
+
+ sentLast bool // sent an end stream
+
+ mu sync.Mutex // guards finished
+ finished bool // TODO: replace with atomic cmpxchg or sync.Once?
+
+ attempt *csAttempt // the active client stream attempt
+ // TODO(hedging): hedging will have multiple attempts simultaneously.
+}
+
+// csAttempt implements a single transport stream attempt within a
+// clientStream.
+type csAttempt struct {
+ cs *clientStream
t transport.ClientTransport
s *transport.Stream
p *parser
- desc *StreamDesc
+ done func(balancer.DoneInfo)
- codec baseCodec
- cp Compressor
dc Decompressor
- comp encoding.Compressor
decomp encoding.Compressor
decompSet bool
- // cancel is only called when RecvMsg() returns non-nil error, which means
- // the stream finishes with error or with io.EOF.
- cancel context.CancelFunc
-
- tracing bool // set to EnableTracing when the clientStream is created.
+ ctx context.Context // the application's context, wrapped by stats/tracing
- mu sync.Mutex
- done func(balancer.DoneInfo)
- sentLast bool // sent an end stream
- finished bool
- // trInfo.tr is set when the clientStream is created (if EnableTracing is true),
- // and is set to nil when the clientStream's finish method is called.
+ mu sync.Mutex // guards trInfo.tr
+ // trInfo.tr is set when created (if EnableTracing is true),
+ // and cleared when the finish method is called.
trInfo traceInfo
- // statsCtx keeps the user context for stats handling.
- // All stats collection should use the statsCtx (instead of the stream context)
- // so that all the generated stats for a particular RPC can be associated in the processing phase.
- statsCtx context.Context
statsHandler stats.Handler
+ beginTime time.Time
}
func (cs *clientStream) Context() context.Context {
- return cs.s.Context()
+ // TODO(retry): commit the current attempt (the context has peer-aware data).
+ return cs.attempt.context()
}
func (cs *clientStream) Header() (metadata.MD, error) {
- m, err := cs.s.Header()
+ m, err := cs.attempt.header()
if err != nil {
+ // TODO(retry): maybe retry on error or commit attempt on success.
err = toRPCErr(err)
cs.finish(err)
}
@@ -350,20 +370,61 @@ func (cs *clientStream) Header() (metadata.MD, error) {
}
func (cs *clientStream) Trailer() metadata.MD {
- return cs.s.Trailer()
+ // TODO(retry): on error, maybe retry (trailers-only).
+ return cs.attempt.trailer()
}
func (cs *clientStream) SendMsg(m interface{}) (err error) {
- // TODO: Check cs.sentLast and error if we already ended the stream.
- if cs.tracing {
- cs.mu.Lock()
- if cs.trInfo.tr != nil {
- cs.trInfo.tr.LazyLog(&payload{sent: true, msg: m}, true)
- }
+ // TODO(retry): buffer message for replaying if not committed.
+ return cs.attempt.sendMsg(m)
+}
+
+func (cs *clientStream) RecvMsg(m interface{}) (err error) {
+ // TODO(retry): maybe retry on error or commit attempt on success.
+ return cs.attempt.recvMsg(m)
+}
+
+func (cs *clientStream) CloseSend() error {
+ cs.attempt.closeSend()
+ return nil
+}
+
+func (cs *clientStream) finish(err error) {
+ if err == io.EOF {
+ // Ending a stream with EOF indicates a success.
+ err = nil
+ }
+ cs.mu.Lock()
+ if cs.finished {
cs.mu.Unlock()
+ return
+ }
+ cs.finished = true
+ cs.mu.Unlock()
+ // TODO(retry): commit current attempt if necessary.
+ cs.attempt.finish(err)
+ for _, o := range cs.opts {
+ o.after(cs.c)
}
+ cs.cancel()
+}
+
+func (a *csAttempt) context() context.Context {
+ return a.s.Context()
+}
+
+func (a *csAttempt) header() (metadata.MD, error) {
+ return a.s.Header()
+}
+
+func (a *csAttempt) trailer() metadata.MD {
+ return a.s.Trailer()
+}
+
+func (a *csAttempt) sendMsg(m interface{}) (err error) {
// TODO Investigate how to signal the stats handling party.
// generate error stats if err != nil && err != io.EOF?
+ cs := a.cs
defer func() {
// For non-client-streaming RPCs, we return nil instead of EOF on success
// because the generated code requires it. finish is not called; RecvMsg()
@@ -372,14 +433,23 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
err = nil
}
if err != nil && err != io.EOF {
- // Call finish for errors generated by this SendMsg call. (Transport
+ // Call finish on the client stream for errors generated by this SendMsg
+ // call, as these indicate problems created by this client. (Transport
// errors are converted to an io.EOF error below; the real error will be
- // returned from RecvMsg eventually in that case.)
+ // returned from RecvMsg eventually in that case, or be retried.)
cs.finish(err)
}
}()
+ // TODO: Check cs.sentLast and error if we already ended the stream.
+ if EnableTracing {
+ a.mu.Lock()
+ if a.trInfo.tr != nil {
+ a.trInfo.tr.LazyLog(&payload{sent: true, msg: m}, true)
+ }
+ a.mu.Unlock()
+ }
var outPayload *stats.OutPayload
- if cs.statsHandler != nil {
+ if a.statsHandler != nil {
outPayload = &stats.OutPayload{
Client: true,
}
@@ -394,18 +464,19 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
if !cs.desc.ClientStreams {
cs.sentLast = true
}
- err = cs.t.Write(cs.s, hdr, data, &transport.Options{Last: !cs.desc.ClientStreams})
+ err = a.t.Write(a.s, hdr, data, &transport.Options{Last: !cs.desc.ClientStreams})
if err == nil {
if outPayload != nil {
outPayload.SentTime = time.Now()
- cs.statsHandler.HandleRPC(cs.statsCtx, outPayload)
+ a.statsHandler.HandleRPC(a.ctx, outPayload)
}
return nil
}
return io.EOF
}
-func (cs *clientStream) RecvMsg(m interface{}) (err error) {
+func (a *csAttempt) recvMsg(m interface{}) (err error) {
+ cs := a.cs
defer func() {
if err != nil || !cs.desc.ServerStreams {
// err != nil or non-server-streaming indicates end of stream.
@@ -413,46 +484,46 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) {
}
}()
var inPayload *stats.InPayload
- if cs.statsHandler != nil {
+ if a.statsHandler != nil {
inPayload = &stats.InPayload{
Client: true,
}
}
- if !cs.decompSet {
+ if !a.decompSet {
// Block until we receive headers containing received message encoding.
- if ct := cs.s.RecvCompress(); ct != "" && ct != encoding.Identity {
- if cs.dc == nil || cs.dc.Type() != ct {
+ if ct := a.s.RecvCompress(); ct != "" && ct != encoding.Identity {
+ if a.dc == nil || a.dc.Type() != ct {
// No configured decompressor, or it does not match the incoming
// message encoding; attempt to find a registered compressor that does.
- cs.dc = nil
- cs.decomp = encoding.GetCompressor(ct)
+ a.dc = nil
+ a.decomp = encoding.GetCompressor(ct)
}
} else {
// No compression is used; disable our decompressor.
- cs.dc = nil
+ a.dc = nil
}
// Only initialize this state once per stream.
- cs.decompSet = true
+ a.decompSet = true
}
- err = recv(cs.p, cs.codec, cs.s, cs.dc, m, *cs.c.maxReceiveMessageSize, inPayload, cs.decomp)
+ err = recv(a.p, cs.codec, a.s, a.dc, m, *cs.c.maxReceiveMessageSize, inPayload, a.decomp)
if err != nil {
if err == io.EOF {
- if statusErr := cs.s.Status().Err(); statusErr != nil {
+ if statusErr := a.s.Status().Err(); statusErr != nil {
return statusErr
}
return io.EOF // indicates successful end of stream.
}
return toRPCErr(err)
}
- if cs.tracing {
- cs.mu.Lock()
- if cs.trInfo.tr != nil {
- cs.trInfo.tr.LazyLog(&payload{sent: false, msg: m}, true)
+ if EnableTracing {
+ a.mu.Lock()
+ if a.trInfo.tr != nil {
+ a.trInfo.tr.LazyLog(&payload{sent: false, msg: m}, true)
}
- cs.mu.Unlock()
+ a.mu.Unlock()
}
if inPayload != nil {
- cs.statsHandler.HandleRPC(cs.statsCtx, inPayload)
+ a.statsHandler.HandleRPC(a.ctx, inPayload)
}
if cs.desc.ServerStreams {
// Subsequent messages should be received by subsequent RecvMsg calls.
@@ -461,74 +532,59 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) {
// Special handling for non-server-stream rpcs.
// This recv expects EOF or errors, so we don't collect inPayload.
- err = recv(cs.p, cs.codec, cs.s, cs.dc, m, *cs.c.maxReceiveMessageSize, nil, cs.decomp)
+ err = recv(a.p, cs.codec, a.s, a.dc, m, *cs.c.maxReceiveMessageSize, nil, a.decomp)
if err == nil {
return toRPCErr(errors.New("grpc: client streaming protocol violation: get <nil>, want <EOF>"))
}
if err == io.EOF {
- return cs.s.Status().Err() // non-server streaming Recv returns nil on success
+ return a.s.Status().Err() // non-server streaming Recv returns nil on success
}
return toRPCErr(err)
}
-func (cs *clientStream) CloseSend() error {
+func (a *csAttempt) closeSend() {
+ cs := a.cs
if cs.sentLast {
- return nil
+ return
}
cs.sentLast = true
- cs.t.Write(cs.s, nil, nil, &transport.Options{Last: true})
- // We ignore errors from Write and always return nil here. Any error it
- // would return would also be returned by a subsequent RecvMsg call, and the
- // user is supposed to always finish the stream by calling RecvMsg until it
- // returns err != nil.
- return nil
+ cs.attempt.t.Write(cs.attempt.s, nil, nil, &transport.Options{Last: true})
+ // We ignore errors from Write. Any error it would return would also be
+ // returned by a subsequent RecvMsg call, and the user is supposed to always
+ // finish the stream by calling RecvMsg until it returns err != nil.
}
-func (cs *clientStream) finish(err error) {
- if err == io.EOF {
- // Ending a stream with EOF indicates a success.
- err = nil
- }
- cs.mu.Lock()
- defer cs.mu.Unlock()
- if cs.finished {
- return
- }
- cs.finished = true
- cs.t.CloseStream(cs.s, err)
- for _, o := range cs.opts {
- o.after(cs.c)
- }
- if cs.done != nil {
- cs.done(balancer.DoneInfo{
+func (a *csAttempt) finish(err error) {
+ a.mu.Lock()
+ a.t.CloseStream(a.s, err)
+
+ if a.done != nil {
+ a.done(balancer.DoneInfo{
Err: err,
BytesSent: true,
- BytesReceived: cs.s.BytesReceived(),
+ BytesReceived: a.s.BytesReceived(),
})
- cs.done = nil
}
- if cs.statsHandler != nil {
+ if a.statsHandler != nil {
end := &stats.End{
- Client: true,
- EndTime: time.Now(),
- Error: err,
+ Client: true,
+ BeginTime: a.beginTime,
+ EndTime: time.Now(),
+ Error: err,
}
- cs.statsHandler.HandleRPC(cs.statsCtx, end)
+ a.statsHandler.HandleRPC(a.ctx, end)
}
- cs.cancel()
- if !cs.tracing {
- return
- }
- if cs.trInfo.tr != nil {
+ if a.trInfo.tr != nil {
if err == nil {
- cs.trInfo.tr.LazyPrintf("RPC: [OK]")
+ a.trInfo.tr.LazyPrintf("RPC: [OK]")
} else {
- cs.trInfo.tr.LazyPrintf("RPC: [%v]", err)
- cs.trInfo.tr.SetError()
+ a.trInfo.tr.LazyPrintf("RPC: [%v]", err)
+ a.trInfo.tr.SetError()
}
- cs.trInfo.tr.Finish()
- cs.trInfo.tr = nil
+ a.trInfo.tr.Finish()
+ a.trInfo.tr = nil
}
+ a.mu.Unlock()
}
// ServerStream defines the interface a server stream has to satisfy.
@@ -552,6 +608,7 @@ type ServerStream interface {
// serverStream implements a server side Stream.
type serverStream struct {
+ ctx context.Context
t transport.ServerTransport
s *transport.Stream
p *parser
@@ -572,7 +629,7 @@ type serverStream struct {
}
func (ss *serverStream) Context() context.Context {
- return ss.s.Context()
+ return ss.ctx
}
func (ss *serverStream) SetHeader(md metadata.MD) error {
@@ -675,9 +732,5 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) {
// MethodFromServerStream returns the method string for the input stream.
// The returned string is in the format of "/service/method".
func MethodFromServerStream(stream ServerStream) (string, bool) {
- s, ok := transport.StreamFromContext(stream.Context())
- if !ok {
- return "", ok
- }
- return s.Method(), ok
+ return Method(stream.Context())
}
diff --git a/vendor/google.golang.org/grpc/transport/handler_server.go b/vendor/google.golang.org/grpc/transport/handler_server.go
index 451d7e629..1a5e96c5a 100644
--- a/vendor/google.golang.org/grpc/transport/handler_server.go
+++ b/vendor/google.golang.org/grpc/transport/handler_server.go
@@ -98,7 +98,7 @@ func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats sta
for _, v := range vv {
v, err := decodeMetadataHeader(k, v)
if err != nil {
- return nil, streamErrorf(codes.InvalidArgument, "malformed binary metadata: %v", err)
+ return nil, streamErrorf(codes.Internal, "malformed binary metadata: %v", err)
}
metakv = append(metakv, k, v)
}
@@ -354,8 +354,7 @@ func (ht *serverHandlerTransport) HandleStreams(startStream func(*Stream), trace
pr.AuthInfo = credentials.TLSInfo{State: *req.TLS}
}
ctx = metadata.NewIncomingContext(ctx, ht.headerMD)
- ctx = peer.NewContext(ctx, pr)
- s.ctx = newContextWithStream(ctx, s)
+ s.ctx = peer.NewContext(ctx, pr)
if ht.stats != nil {
s.ctx = ht.stats.TagRPC(s.ctx, &stats.RPCTagInfo{FullMethodName: s.method})
inHeader := &stats.InHeader{
diff --git a/vendor/google.golang.org/grpc/transport/http2_client.go b/vendor/google.golang.org/grpc/transport/http2_client.go
index 56b434ef3..8b5be0d6d 100644
--- a/vendor/google.golang.org/grpc/transport/http2_client.go
+++ b/vendor/google.golang.org/grpc/transport/http2_client.go
@@ -121,18 +121,6 @@ func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error
}
func isTemporary(err error) bool {
- switch err {
- case io.EOF:
- // Connection closures may be resolved upon retry, and are thus
- // treated as temporary.
- return true
- case context.DeadlineExceeded:
- // In Go 1.7, context.DeadlineExceeded implements Timeout(), and this
- // special case is not needed. Until then, we need to keep this
- // clause.
- return true
- }
-
switch err := err.(type) {
case interface {
Temporary() bool
@@ -145,7 +133,7 @@ func isTemporary(err error) bool {
// temporary.
return err.Timeout()
}
- return false
+ return true
}
// newHTTP2Client constructs a connected ClientTransport to addr based on HTTP2
@@ -181,10 +169,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr TargetInfo, opts Conne
scheme = "https"
conn, authInfo, err = creds.ClientHandshake(connectCtx, addr.Authority, conn)
if err != nil {
- // Credentials handshake errors are typically considered permanent
- // to avoid retrying on e.g. bad certificates.
- temp := isTemporary(err)
- return nil, connectionErrorf(temp, err, "transport: authentication handshake failed: %v", err)
+ return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed: %v", err)
}
isSecure = true
}
diff --git a/vendor/google.golang.org/grpc/transport/http2_server.go b/vendor/google.golang.org/grpc/transport/http2_server.go
index 24c2c7e18..97b214c64 100644
--- a/vendor/google.golang.org/grpc/transport/http2_server.go
+++ b/vendor/google.golang.org/grpc/transport/http2_server.go
@@ -307,10 +307,6 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
pr.AuthInfo = t.authInfo
}
s.ctx = peer.NewContext(s.ctx, pr)
- // Cache the current stream to the context so that the server application
- // can find out. Required when the server wants to send some metadata
- // back to the client (unary call only).
- s.ctx = newContextWithStream(s.ctx, s)
// Attach the received metadata to the context.
if len(state.mdata) > 0 {
s.ctx = metadata.NewIncomingContext(s.ctx, state.mdata)
@@ -896,9 +892,6 @@ func (t *http2Server) Write(s *Stream, hdr []byte, data []byte, opts *Options) e
// ltq is only a soft limit.
streamQuota -= size
p := r[:size]
- // Reset ping strikes when sending data since this might cause
- // the peer to send ping.
- atomic.StoreUint32(&t.resetPingStrikes, 1)
success := func() {
ltq := ltq
t.controlBuf.put(&dataFrame{streamID: s.id, endStream: false, d: p, f: func() {
@@ -1013,6 +1006,9 @@ var goAwayPing = &ping{data: [8]byte{1, 6, 1, 8, 0, 3, 3, 9}}
func (t *http2Server) itemHandler(i item) error {
switch i := i.(type) {
case *dataFrame:
+ // Reset ping strikes when sending data since this might cause
+ // the peer to send ping.
+ atomic.StoreUint32(&t.resetPingStrikes, 1)
if err := t.framer.fr.WriteData(i.streamID, i.endStream, i.d); err != nil {
return err
}
diff --git a/vendor/google.golang.org/grpc/transport/http_util.go b/vendor/google.golang.org/grpc/transport/http_util.go
index 344767731..de37e38ec 100644
--- a/vendor/google.golang.org/grpc/transport/http_util.go
+++ b/vendor/google.golang.org/grpc/transport/http_util.go
@@ -70,7 +70,7 @@ var (
http2.ErrCodeConnect: codes.Internal,
http2.ErrCodeEnhanceYourCalm: codes.ResourceExhausted,
http2.ErrCodeInadequateSecurity: codes.PermissionDenied,
- http2.ErrCodeHTTP11Required: codes.FailedPrecondition,
+ http2.ErrCodeHTTP11Required: codes.Internal,
}
statusCodeConvTab = map[codes.Code]http2.ErrCode{
codes.Internal: http2.ErrCodeInternal,
@@ -283,7 +283,7 @@ func (d *decodeState) processHeaderField(f hpack.HeaderField) error {
case "content-type":
contentSubtype, validContentType := contentSubtype(f.Value)
if !validContentType {
- return streamErrorf(codes.FailedPrecondition, "transport: received the unexpected content-type %q", f.Value)
+ return streamErrorf(codes.Internal, "transport: received the unexpected content-type %q", f.Value)
}
d.contentSubtype = contentSubtype
// TODO: do we want to propagate the whole content-type in the metadata,
diff --git a/vendor/google.golang.org/grpc/transport/transport.go b/vendor/google.golang.org/grpc/transport/transport.go
index e68f89ec4..e0c1e343e 100644
--- a/vendor/google.golang.org/grpc/transport/transport.go
+++ b/vendor/google.golang.org/grpc/transport/transport.go
@@ -366,6 +366,14 @@ func (s *Stream) SetHeader(md metadata.MD) error {
return nil
}
+// SendHeader sends the given header metadata. The given metadata is
+// combined with any metadata set by previous calls to SetHeader and
+// then written to the transport stream.
+func (s *Stream) SendHeader(md metadata.MD) error {
+ t := s.ServerTransport()
+ return t.WriteHeader(s, md)
+}
+
// SetTrailer sets the trailer metadata which will be sent with the RPC status
// by the server. This can be called multiple times. Server side only.
func (s *Stream) SetTrailer(md metadata.MD) error {
@@ -445,21 +453,6 @@ func (s *Stream) GoString() string {
return fmt.Sprintf("<stream: %p, %v>", s, s.method)
}
-// The key to save transport.Stream in the context.
-type streamKey struct{}
-
-// newContextWithStream creates a new context from ctx and attaches stream
-// to it.
-func newContextWithStream(ctx context.Context, stream *Stream) context.Context {
- return context.WithValue(ctx, streamKey{}, stream)
-}
-
-// StreamFromContext returns the stream saved in ctx.
-func StreamFromContext(ctx context.Context) (s *Stream, ok bool) {
- s, ok = ctx.Value(streamKey{}).(*Stream)
- return
-}
-
// state of transport
type transportState int
diff --git a/vendor/vendor.json b/vendor/vendor.json
index d75f48abf..0ebbb29ed 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -437,220 +437,220 @@
"versionExact": "master"
},
{
- "checksumSHA1": "DGnsWyF+0V5UX3i9VVgKYZ8NwG0=",
+ "checksumSHA1": "Qi3LcG4b9bGoC1W4Mhlks4DI3Ss=",
"path": "google.golang.org/grpc",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "xBhmO0Vn4kzbmySioX+2gBImrkk=",
"path": "google.golang.org/grpc/balancer",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "CPWX/IgaQSR3+78j4sPrvHNkW+U=",
"path": "google.golang.org/grpc/balancer/base",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "DJ1AtOk4Pu7bqtUMob95Hw8HPNw=",
"path": "google.golang.org/grpc/balancer/roundrobin",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "j8Qs+yfgwYYOtodB/1bSlbzV5rs=",
"path": "google.golang.org/grpc/codes",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "XH2WYcDNwVO47zYShREJjcYXm0Y=",
"path": "google.golang.org/grpc/connectivity",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "KthiDKNPHMeIu967enqtE4NaZzI=",
"path": "google.golang.org/grpc/credentials",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "mJTBJC0n9J2CV+tHX+dJosYOZmg=",
"path": "google.golang.org/grpc/encoding",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "LKKkn7EYA+Do9Qwb2/SUKLFNxoo=",
"path": "google.golang.org/grpc/encoding/proto",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "H7SuPUqbPcdbNqgl+k3ohuwMAwE=",
"path": "google.golang.org/grpc/grpclb/grpc_lb_v1/messages",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "ntHev01vgZgeIh5VFRmbLx/BSTo=",
"path": "google.golang.org/grpc/grpclog",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "DyM0uqLtknaI4THSc3spn9XlL+g=",
"path": "google.golang.org/grpc/health",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "6vY7tYjV84pnr3sDctzx53Bs8b0=",
"path": "google.golang.org/grpc/health/grpc_health_v1",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "Qvf3zdmRCSsiM/VoBv0qB/naHtU=",
"path": "google.golang.org/grpc/internal",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "hcuHgKp8W0wIzoCnNfKI8NUss5o=",
"path": "google.golang.org/grpc/keepalive",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
- "checksumSHA1": "X1BGbIb3xaxiAG4O1Ot5YjPlh4g=",
+ "checksumSHA1": "RUgjR0iUFLCgdLAnNqiH+8jTzuk=",
"path": "google.golang.org/grpc/metadata",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "5dwF592DPvhF2Wcex3m7iV6aGRQ=",
"path": "google.golang.org/grpc/naming",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "n5EgDdBqFMa2KQFhtl+FF/4gIFo=",
"path": "google.golang.org/grpc/peer",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
- "checksumSHA1": "JF/KBFCo5JwVtXfrZ2kJnFRC6W8=",
+ "checksumSHA1": "780k7ZcT5M32PTx7AmxkxMlZ/Wk=",
"path": "google.golang.org/grpc/reflection",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "7Ax2K0St9CIi1rkA9Ju+2ERfe9E=",
"path": "google.golang.org/grpc/reflection/grpc_reflection_v1alpha",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "qbA3XLvX0RTvaqQefvFDtE9GaJs=",
"path": "google.golang.org/grpc/resolver",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "WpWF+bDzObsHf+bjoGpb/abeFxo=",
"path": "google.golang.org/grpc/resolver/dns",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "zs9M4xE8Lyg4wvuYvR00XoBxmuw=",
"path": "google.golang.org/grpc/resolver/passthrough",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
- "checksumSHA1": "G9lgXNi7qClo5sM2s6TbTHLFR3g=",
+ "checksumSHA1": "YclPgme2gT3S0hTkHVdE1zAxJdo=",
"path": "google.golang.org/grpc/stats",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
- "checksumSHA1": "/7i6dC0tFTtGMxykj9VduLEfBCU=",
+ "checksumSHA1": "FXiovlBmrYdS4QT0Z4nV+x+v5HI=",
"path": "google.golang.org/grpc/status",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
"checksumSHA1": "qvArRhlrww5WvRmbyMF2mUfbJew=",
"path": "google.golang.org/grpc/tap",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
},
{
- "checksumSHA1": "fgt81mMAzx0Zo0ZuI2Vv0/RYApA=",
+ "checksumSHA1": "sg7RY87LaWXaZMj0cuLQQaJJQYo=",
"path": "google.golang.org/grpc/transport",
- "revision": "61763f5bcf26276d4c255c89e9dcf8f9838a271b",
- "revisionTime": "2018-03-28T23:38:55Z",
- "version": "v1.10",
- "versionExact": "v1.10.1"
+ "revision": "d11072e7ca9811b1100b80ca0269ac831f06d024",
+ "revisionTime": "2018-04-09T20:31:48Z",
+ "version": "v1.11",
+ "versionExact": "v1.11.3"
}
],
"rootPath": "gitlab.com/gitlab-org/gitaly"