Update k8s dependencies to v1.22.0-rc.0
This commit is contained in:
30
vendor/google.golang.org/grpc/Makefile
generated
vendored
30
vendor/google.golang.org/grpc/Makefile
generated
vendored
@@ -1,13 +1,13 @@
|
||||
all: vet test testrace
|
||||
|
||||
build: deps
|
||||
build:
|
||||
go build google.golang.org/grpc/...
|
||||
|
||||
clean:
|
||||
go clean -i google.golang.org/grpc/...
|
||||
|
||||
deps:
|
||||
go get -d -v google.golang.org/grpc/...
|
||||
GO111MODULE=on go get -d -v google.golang.org/grpc/...
|
||||
|
||||
proto:
|
||||
@ if ! which protoc > /dev/null; then \
|
||||
@@ -16,30 +16,18 @@ proto:
|
||||
fi
|
||||
go generate google.golang.org/grpc/...
|
||||
|
||||
test: testdeps
|
||||
test:
|
||||
go test -cpu 1,4 -timeout 7m google.golang.org/grpc/...
|
||||
|
||||
testsubmodule: testdeps
|
||||
testsubmodule:
|
||||
cd security/advancedtls && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/advancedtls/...
|
||||
cd security/authorization && go test -cpu 1,4 -timeout 7m google.golang.org/grpc/security/authorization/...
|
||||
|
||||
testappengine: testappenginedeps
|
||||
goapp test -cpu 1,4 -timeout 7m google.golang.org/grpc/...
|
||||
|
||||
testappenginedeps:
|
||||
goapp get -d -v -t -tags 'appengine appenginevm' google.golang.org/grpc/...
|
||||
|
||||
testdeps:
|
||||
go get -d -v -t google.golang.org/grpc/...
|
||||
|
||||
testrace: testdeps
|
||||
testrace:
|
||||
go test -race -cpu 1,4 -timeout 7m google.golang.org/grpc/...
|
||||
|
||||
updatedeps:
|
||||
go get -d -v -u -f google.golang.org/grpc/...
|
||||
|
||||
updatetestdeps:
|
||||
go get -d -v -t -u -f google.golang.org/grpc/...
|
||||
testdeps:
|
||||
GO111MODULE=on go get -d -v -t google.golang.org/grpc/...
|
||||
|
||||
vet: vetdeps
|
||||
./vet.sh
|
||||
@@ -51,14 +39,10 @@ vetdeps:
|
||||
all \
|
||||
build \
|
||||
clean \
|
||||
deps \
|
||||
proto \
|
||||
test \
|
||||
testappengine \
|
||||
testappenginedeps \
|
||||
testdeps \
|
||||
testrace \
|
||||
updatedeps \
|
||||
updatetestdeps \
|
||||
vet \
|
||||
vetdeps
|
||||
|
3
vendor/google.golang.org/grpc/SECURITY.md
generated
vendored
Normal file
3
vendor/google.golang.org/grpc/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Security Policy
|
||||
|
||||
For information on gRPC Security Policy and reporting potentional security issues, please see [gRPC CVE Process](https://github.com/grpc/proposal/blob/master/P4-grpc-cve-process.md).
|
10
vendor/google.golang.org/grpc/balancer/balancer.go
generated
vendored
10
vendor/google.golang.org/grpc/balancer/balancer.go
generated
vendored
@@ -101,6 +101,9 @@ type SubConn interface {
|
||||
// a new connection will be created.
|
||||
//
|
||||
// This will trigger a state transition for the SubConn.
|
||||
//
|
||||
// Deprecated: This method is now part of the ClientConn interface and will
|
||||
// eventually be removed from here.
|
||||
UpdateAddresses([]resolver.Address)
|
||||
// Connect starts the connecting for this SubConn.
|
||||
Connect()
|
||||
@@ -143,6 +146,13 @@ type ClientConn interface {
|
||||
// RemoveSubConn removes the SubConn from ClientConn.
|
||||
// The SubConn will be shutdown.
|
||||
RemoveSubConn(SubConn)
|
||||
// UpdateAddresses updates the addresses used in the passed in SubConn.
|
||||
// gRPC checks if the currently connected address is still in the new list.
|
||||
// If so, the connection will be kept. Else, the connection will be
|
||||
// gracefully closed, and a new connection will be created.
|
||||
//
|
||||
// This will trigger a state transition for the SubConn.
|
||||
UpdateAddresses(SubConn, []resolver.Address)
|
||||
|
||||
// UpdateState notifies gRPC that the balancer's internal state has
|
||||
// changed.
|
||||
|
53
vendor/google.golang.org/grpc/balancer/base/balancer.go
generated
vendored
53
vendor/google.golang.org/grpc/balancer/base/balancer.go
generated
vendored
@@ -22,6 +22,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc/attributes"
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
@@ -41,7 +42,7 @@ func (bb *baseBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions)
|
||||
cc: cc,
|
||||
pickerBuilder: bb.pickerBuilder,
|
||||
|
||||
subConns: make(map[resolver.Address]balancer.SubConn),
|
||||
subConns: make(map[resolver.Address]subConnInfo),
|
||||
scStates: make(map[balancer.SubConn]connectivity.State),
|
||||
csEvltr: &balancer.ConnectivityStateEvaluator{},
|
||||
config: bb.config,
|
||||
@@ -57,6 +58,11 @@ func (bb *baseBuilder) Name() string {
|
||||
return bb.name
|
||||
}
|
||||
|
||||
type subConnInfo struct {
|
||||
subConn balancer.SubConn
|
||||
attrs *attributes.Attributes
|
||||
}
|
||||
|
||||
type baseBalancer struct {
|
||||
cc balancer.ClientConn
|
||||
pickerBuilder PickerBuilder
|
||||
@@ -64,7 +70,7 @@ type baseBalancer struct {
|
||||
csEvltr *balancer.ConnectivityStateEvaluator
|
||||
state connectivity.State
|
||||
|
||||
subConns map[resolver.Address]balancer.SubConn
|
||||
subConns map[resolver.Address]subConnInfo // `attributes` is stripped from the keys of this map (the addresses)
|
||||
scStates map[balancer.SubConn]connectivity.State
|
||||
picker balancer.Picker
|
||||
config Config
|
||||
@@ -101,23 +107,49 @@ func (b *baseBalancer) UpdateClientConnState(s balancer.ClientConnState) error {
|
||||
// addrsSet is the set converted from addrs, it's used for quick lookup of an address.
|
||||
addrsSet := make(map[resolver.Address]struct{})
|
||||
for _, a := range s.ResolverState.Addresses {
|
||||
addrsSet[a] = struct{}{}
|
||||
if _, ok := b.subConns[a]; !ok {
|
||||
// Strip attributes from addresses before using them as map keys. So
|
||||
// that when two addresses only differ in attributes pointers (but with
|
||||
// the same attribute content), they are considered the same address.
|
||||
//
|
||||
// Note that this doesn't handle the case where the attribute content is
|
||||
// different. So if users want to set different attributes to create
|
||||
// duplicate connections to the same backend, it doesn't work. This is
|
||||
// fine for now, because duplicate is done by setting Metadata today.
|
||||
//
|
||||
// TODO: read attributes to handle duplicate connections.
|
||||
aNoAttrs := a
|
||||
aNoAttrs.Attributes = nil
|
||||
addrsSet[aNoAttrs] = struct{}{}
|
||||
if scInfo, ok := b.subConns[aNoAttrs]; !ok {
|
||||
// a is a new address (not existing in b.subConns).
|
||||
//
|
||||
// When creating SubConn, the original address with attributes is
|
||||
// passed through. So that connection configurations in attributes
|
||||
// (like creds) will be used.
|
||||
sc, err := b.cc.NewSubConn([]resolver.Address{a}, balancer.NewSubConnOptions{HealthCheckEnabled: b.config.HealthCheck})
|
||||
if err != nil {
|
||||
logger.Warningf("base.baseBalancer: failed to create new SubConn: %v", err)
|
||||
continue
|
||||
}
|
||||
b.subConns[a] = sc
|
||||
b.subConns[aNoAttrs] = subConnInfo{subConn: sc, attrs: a.Attributes}
|
||||
b.scStates[sc] = connectivity.Idle
|
||||
sc.Connect()
|
||||
} else {
|
||||
// Always update the subconn's address in case the attributes
|
||||
// changed.
|
||||
//
|
||||
// The SubConn does a reflect.DeepEqual of the new and old
|
||||
// addresses. So this is a noop if the current address is the same
|
||||
// as the old one (including attributes).
|
||||
scInfo.attrs = a.Attributes
|
||||
b.subConns[aNoAttrs] = scInfo
|
||||
b.cc.UpdateAddresses(scInfo.subConn, []resolver.Address{a})
|
||||
}
|
||||
}
|
||||
for a, sc := range b.subConns {
|
||||
for a, scInfo := range b.subConns {
|
||||
// a was removed by resolver.
|
||||
if _, ok := addrsSet[a]; !ok {
|
||||
b.cc.RemoveSubConn(sc)
|
||||
b.cc.RemoveSubConn(scInfo.subConn)
|
||||
delete(b.subConns, a)
|
||||
// Keep the state of this sc in b.scStates until sc's state becomes Shutdown.
|
||||
// The entry will be deleted in UpdateSubConnState.
|
||||
@@ -160,9 +192,10 @@ func (b *baseBalancer) regeneratePicker() {
|
||||
readySCs := make(map[balancer.SubConn]SubConnInfo)
|
||||
|
||||
// Filter out all ready SCs from full subConn map.
|
||||
for addr, sc := range b.subConns {
|
||||
if st, ok := b.scStates[sc]; ok && st == connectivity.Ready {
|
||||
readySCs[sc] = SubConnInfo{Address: addr}
|
||||
for addr, scInfo := range b.subConns {
|
||||
if st, ok := b.scStates[scInfo.subConn]; ok && st == connectivity.Ready {
|
||||
addr.Attributes = scInfo.attrs
|
||||
readySCs[scInfo.subConn] = SubConnInfo{Address: addr}
|
||||
}
|
||||
}
|
||||
b.picker = b.pickerBuilder.Build(PickerBuildInfo{ReadySCs: readySCs})
|
||||
|
12
vendor/google.golang.org/grpc/balancer_conn_wrappers.go
generated
vendored
12
vendor/google.golang.org/grpc/balancer_conn_wrappers.go
generated
vendored
@@ -163,6 +163,14 @@ func (ccb *ccBalancerWrapper) RemoveSubConn(sc balancer.SubConn) {
|
||||
ccb.cc.removeAddrConn(acbw.getAddrConn(), errConnDrain)
|
||||
}
|
||||
|
||||
func (ccb *ccBalancerWrapper) UpdateAddresses(sc balancer.SubConn, addrs []resolver.Address) {
|
||||
acbw, ok := sc.(*acBalancerWrapper)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
acbw.UpdateAddresses(addrs)
|
||||
}
|
||||
|
||||
func (ccb *ccBalancerWrapper) UpdateState(s balancer.State) {
|
||||
ccb.mu.Lock()
|
||||
defer ccb.mu.Unlock()
|
||||
@@ -197,7 +205,7 @@ func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) {
|
||||
acbw.mu.Lock()
|
||||
defer acbw.mu.Unlock()
|
||||
if len(addrs) <= 0 {
|
||||
acbw.ac.tearDown(errConnDrain)
|
||||
acbw.ac.cc.removeAddrConn(acbw.ac, errConnDrain)
|
||||
return
|
||||
}
|
||||
if !acbw.ac.tryUpdateAddrs(addrs) {
|
||||
@@ -212,7 +220,7 @@ func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) {
|
||||
acbw.ac.acbw = nil
|
||||
acbw.ac.mu.Unlock()
|
||||
acState := acbw.ac.getState()
|
||||
acbw.ac.tearDown(errConnDrain)
|
||||
acbw.ac.cc.removeAddrConn(acbw.ac, errConnDrain)
|
||||
|
||||
if acState == connectivity.Shutdown {
|
||||
return
|
||||
|
18
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
18
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
@@ -109,11 +109,11 @@ type defaultConfigSelector struct {
|
||||
sc *ServiceConfig
|
||||
}
|
||||
|
||||
func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) *iresolver.RPCConfig {
|
||||
func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RPCConfig, error) {
|
||||
return &iresolver.RPCConfig{
|
||||
Context: rpcInfo.Context,
|
||||
MethodConfig: getMethodConfig(dcs.sc, rpcInfo.Method),
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DialContext creates a client connection to the given target. By default, it's
|
||||
@@ -143,6 +143,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
||||
firstResolveEvent: grpcsync.NewEvent(),
|
||||
}
|
||||
cc.retryThrottler.Store((*retryThrottler)(nil))
|
||||
cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{nil})
|
||||
cc.ctx, cc.cancel = context.WithCancel(context.Background())
|
||||
|
||||
for _, opt := range opts {
|
||||
@@ -270,7 +271,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
||||
cc.authority = creds.Info().ServerName
|
||||
} else if cc.dopts.insecure && cc.dopts.authority != "" {
|
||||
cc.authority = cc.dopts.authority
|
||||
} else if strings.HasPrefix(cc.target, "unix:") {
|
||||
} else if strings.HasPrefix(cc.target, "unix:") || strings.HasPrefix(cc.target, "unix-abstract:") {
|
||||
cc.authority = "localhost"
|
||||
} else if strings.HasPrefix(cc.parsedTarget.Endpoint, ":") {
|
||||
cc.authority = "localhost" + cc.parsedTarget.Endpoint
|
||||
@@ -1197,7 +1198,7 @@ func (ac *addrConn) resetTransport() {
|
||||
ac.mu.Lock()
|
||||
if ac.state == connectivity.Shutdown {
|
||||
ac.mu.Unlock()
|
||||
newTr.Close()
|
||||
newTr.Close(fmt.Errorf("reached connectivity state: SHUTDOWN"))
|
||||
return
|
||||
}
|
||||
ac.curAddr = addr
|
||||
@@ -1329,7 +1330,7 @@ func (ac *addrConn) createTransport(addr resolver.Address, copts transport.Conne
|
||||
select {
|
||||
case <-time.After(time.Until(connectDeadline)):
|
||||
// We didn't get the preface in time.
|
||||
newTr.Close()
|
||||
newTr.Close(fmt.Errorf("failed to receive server preface within timeout"))
|
||||
channelz.Warningf(logger, ac.channelzID, "grpc: addrConn.createTransport failed to connect to %v: didn't receive server preface in time. Reconnecting...", addr)
|
||||
return nil, nil, errors.New("timed out waiting for server handshake")
|
||||
case <-prefaceReceived:
|
||||
@@ -1446,10 +1447,9 @@ func (ac *addrConn) getReadyTransport() (transport.ClientTransport, bool) {
|
||||
}
|
||||
|
||||
// tearDown starts to tear down the addrConn.
|
||||
// TODO(zhaoq): Make this synchronous to avoid unbounded memory consumption in
|
||||
// some edge cases (e.g., the caller opens and closes many addrConn's in a
|
||||
// tight loop.
|
||||
// tearDown doesn't remove ac from ac.cc.conns.
|
||||
//
|
||||
// Note that tearDown doesn't remove ac from ac.cc.conns, so the addrConn struct
|
||||
// will leak. In most cases, call cc.removeAddrConn() instead.
|
||||
func (ac *addrConn) tearDown(err error) {
|
||||
ac.mu.Lock()
|
||||
if ac.state == connectivity.Shutdown {
|
||||
|
24
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
24
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/grpc/attributes"
|
||||
"google.golang.org/grpc/internal"
|
||||
icredentials "google.golang.org/grpc/internal/credentials"
|
||||
)
|
||||
|
||||
// PerRPCCredentials defines the common interface for the credentials which need to
|
||||
@@ -188,15 +188,12 @@ type RequestInfo struct {
|
||||
AuthInfo AuthInfo
|
||||
}
|
||||
|
||||
// requestInfoKey is a struct to be used as the key when attaching a RequestInfo to a context object.
|
||||
type requestInfoKey struct{}
|
||||
|
||||
// RequestInfoFromContext extracts the RequestInfo from the context if it exists.
|
||||
//
|
||||
// This API is experimental.
|
||||
func RequestInfoFromContext(ctx context.Context) (ri RequestInfo, ok bool) {
|
||||
ri, ok = ctx.Value(requestInfoKey{}).(RequestInfo)
|
||||
return
|
||||
ri, ok = icredentials.RequestInfoFromContext(ctx).(RequestInfo)
|
||||
return ri, ok
|
||||
}
|
||||
|
||||
// ClientHandshakeInfo holds data to be passed to ClientHandshake. This makes
|
||||
@@ -211,16 +208,12 @@ type ClientHandshakeInfo struct {
|
||||
Attributes *attributes.Attributes
|
||||
}
|
||||
|
||||
// clientHandshakeInfoKey is a struct used as the key to store
|
||||
// ClientHandshakeInfo in a context.
|
||||
type clientHandshakeInfoKey struct{}
|
||||
|
||||
// ClientHandshakeInfoFromContext returns the ClientHandshakeInfo struct stored
|
||||
// in ctx.
|
||||
//
|
||||
// This API is experimental.
|
||||
func ClientHandshakeInfoFromContext(ctx context.Context) ClientHandshakeInfo {
|
||||
chi, _ := ctx.Value(clientHandshakeInfoKey{}).(ClientHandshakeInfo)
|
||||
chi, _ := icredentials.ClientHandshakeInfoFromContext(ctx).(ClientHandshakeInfo)
|
||||
return chi
|
||||
}
|
||||
|
||||
@@ -249,15 +242,6 @@ func CheckSecurityLevel(ai AuthInfo, level SecurityLevel) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
internal.NewRequestInfoContext = func(ctx context.Context, ri RequestInfo) context.Context {
|
||||
return context.WithValue(ctx, requestInfoKey{}, ri)
|
||||
}
|
||||
internal.NewClientHandshakeInfoContext = func(ctx context.Context, chi ClientHandshakeInfo) context.Context {
|
||||
return context.WithValue(ctx, clientHandshakeInfoKey{}, chi)
|
||||
}
|
||||
}
|
||||
|
||||
// ChannelzSecurityInfo defines the interface that security protocols should implement
|
||||
// in order to provide security info to channelz.
|
||||
//
|
||||
|
17
vendor/google.golang.org/grpc/dialoptions.go
generated
vendored
17
vendor/google.golang.org/grpc/dialoptions.go
generated
vendored
@@ -66,11 +66,7 @@ type dialOptions struct {
|
||||
minConnectTimeout func() time.Duration
|
||||
defaultServiceConfig *ServiceConfig // defaultServiceConfig is parsed from defaultServiceConfigRawJSON.
|
||||
defaultServiceConfigRawJSON *string
|
||||
// This is used by ccResolverWrapper to backoff between successive calls to
|
||||
// resolver.ResolveNow(). The user will have no need to configure this, but
|
||||
// we need to be able to configure this in tests.
|
||||
resolveNowBackoff func(int) time.Duration
|
||||
resolvers []resolver.Builder
|
||||
resolvers []resolver.Builder
|
||||
}
|
||||
|
||||
// DialOption configures how we set up the connection.
|
||||
@@ -596,7 +592,6 @@ func defaultDialOptions() dialOptions {
|
||||
ReadBufferSize: defaultReadBufSize,
|
||||
UseProxy: true,
|
||||
},
|
||||
resolveNowBackoff: internalbackoff.DefaultExponential.Backoff,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,16 +606,6 @@ func withMinConnectDeadline(f func() time.Duration) DialOption {
|
||||
})
|
||||
}
|
||||
|
||||
// withResolveNowBackoff specifies the function that clientconn uses to backoff
|
||||
// between successive calls to resolver.ResolveNow().
|
||||
//
|
||||
// For testing purpose only.
|
||||
func withResolveNowBackoff(f func(int) time.Duration) DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.resolveNowBackoff = f
|
||||
})
|
||||
}
|
||||
|
||||
// WithResolvers allows a list of resolver implementations to be registered
|
||||
// locally with the ClientConn without needing to be globally registered via
|
||||
// resolver.Register. They will be matched against the scheme used for the
|
||||
|
14
vendor/google.golang.org/grpc/encoding/proto/proto.go
generated
vendored
14
vendor/google.golang.org/grpc/encoding/proto/proto.go
generated
vendored
@@ -21,6 +21,8 @@
|
||||
package proto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/grpc/encoding"
|
||||
)
|
||||
@@ -36,11 +38,19 @@ func init() {
|
||||
type codec struct{}
|
||||
|
||||
func (codec) Marshal(v interface{}) ([]byte, error) {
|
||||
return proto.Marshal(v.(proto.Message))
|
||||
vv, ok := v.(proto.Message)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
|
||||
}
|
||||
return proto.Marshal(vv)
|
||||
}
|
||||
|
||||
func (codec) Unmarshal(data []byte, v interface{}) error {
|
||||
return proto.Unmarshal(data, v.(proto.Message))
|
||||
vv, ok := v.(proto.Message)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
|
||||
}
|
||||
return proto.Unmarshal(data, vv)
|
||||
}
|
||||
|
||||
func (codec) Name() string {
|
||||
|
4
vendor/google.golang.org/grpc/go.mod
generated
vendored
4
vendor/google.golang.org/grpc/go.mod
generated
vendored
@@ -3,8 +3,8 @@ module google.golang.org/grpc
|
||||
go 1.11
|
||||
|
||||
require (
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354
|
||||
github.com/envoyproxy/go-control-plane v0.9.7
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
github.com/golang/protobuf v1.4.2
|
||||
github.com/google/go-cmp v0.5.0
|
||||
|
15
vendor/google.golang.org/grpc/go.sum
generated
vendored
15
vendor/google.golang.org/grpc/go.sum
generated
vendored
@@ -1,18 +1,17 @@
|
||||
cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ=
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354 h1:9kRtNpqLHbZVO/NNxhHp2ymxFxsHOe3x2efJGn//Tas=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403 h1:cqQfy1jclcSy/FwLjemeg3SR1yaINm74aQyupQ0Bl8M=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.7 h1:EARl0OvqMoxq/UMgMSCLnXzkaXbxzskluEBlMQCJPms=
|
||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d h1:QyzYnTnPE15SQyUeqU6qLbWxMkwyAyu+vGksa0b7j00=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
@@ -36,9 +35,11 @@ github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -87,7 +88,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
49
vendor/google.golang.org/grpc/internal/credentials/credentials.go
generated
vendored
Normal file
49
vendor/google.golang.org/grpc/internal/credentials/credentials.go
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2021 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package credentials
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// requestInfoKey is a struct to be used as the key to store RequestInfo in a
|
||||
// context.
|
||||
type requestInfoKey struct{}
|
||||
|
||||
// NewRequestInfoContext creates a context with ri.
|
||||
func NewRequestInfoContext(ctx context.Context, ri interface{}) context.Context {
|
||||
return context.WithValue(ctx, requestInfoKey{}, ri)
|
||||
}
|
||||
|
||||
// RequestInfoFromContext extracts the RequestInfo from ctx.
|
||||
func RequestInfoFromContext(ctx context.Context) interface{} {
|
||||
return ctx.Value(requestInfoKey{})
|
||||
}
|
||||
|
||||
// clientHandshakeInfoKey is a struct used as the key to store
|
||||
// ClientHandshakeInfo in a context.
|
||||
type clientHandshakeInfoKey struct{}
|
||||
|
||||
// ClientHandshakeInfoFromContext extracts the ClientHandshakeInfo from ctx.
|
||||
func ClientHandshakeInfoFromContext(ctx context.Context) interface{} {
|
||||
return ctx.Value(clientHandshakeInfoKey{})
|
||||
}
|
||||
|
||||
// NewClientHandshakeInfoContext creates a context with chi.
|
||||
func NewClientHandshakeInfoContext(ctx context.Context, chi interface{}) context.Context {
|
||||
return context.WithValue(ctx, clientHandshakeInfoKey{}, chi)
|
||||
}
|
33
vendor/google.golang.org/grpc/internal/grpcutil/target.go
generated
vendored
33
vendor/google.golang.org/grpc/internal/grpcutil/target.go
generated
vendored
@@ -41,16 +41,37 @@ func split2(s, sep string) (string, string, bool) {
|
||||
// not parse "unix:[path]" cases. This should be true in cases where a custom
|
||||
// dialer is present, to prevent a behavior change.
|
||||
//
|
||||
// If target is not a valid scheme://authority/endpoint, it returns {Endpoint:
|
||||
// target}.
|
||||
// If target is not a valid scheme://authority/endpoint as specified in
|
||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md,
|
||||
// it returns {Endpoint: target}.
|
||||
func ParseTarget(target string, skipUnixColonParsing bool) (ret resolver.Target) {
|
||||
var ok bool
|
||||
if strings.HasPrefix(target, "unix-abstract:") {
|
||||
if strings.HasPrefix(target, "unix-abstract://") {
|
||||
// Maybe, with Authority specified, try to parse it
|
||||
var remain string
|
||||
ret.Scheme, remain, _ = split2(target, "://")
|
||||
ret.Authority, ret.Endpoint, ok = split2(remain, "/")
|
||||
if !ok {
|
||||
// No Authority, add the "//" back
|
||||
ret.Endpoint = "//" + remain
|
||||
} else {
|
||||
// Found Authority, add the "/" back
|
||||
ret.Endpoint = "/" + ret.Endpoint
|
||||
}
|
||||
} else {
|
||||
// Without Authority specified, split target on ":"
|
||||
ret.Scheme, ret.Endpoint, _ = split2(target, ":")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
ret.Scheme, ret.Endpoint, ok = split2(target, "://")
|
||||
if !ok {
|
||||
if strings.HasPrefix(target, "unix:") && !skipUnixColonParsing {
|
||||
// Handle the "unix:[path]" case, because splitting on :// only
|
||||
// handles the "unix://[/absolute/path]" case. Only handle if the
|
||||
// dialer is nil, to avoid a behavior change with custom dialers.
|
||||
// Handle the "unix:[local/path]" and "unix:[/absolute/path]" cases,
|
||||
// because splitting on :// only handles the
|
||||
// "unix://[/absolute/path]" case. Only handle if the dialer is nil,
|
||||
// to avoid a behavior change with custom dialers.
|
||||
return resolver.Target{Scheme: "unix", Endpoint: target[len("unix:"):]}
|
||||
}
|
||||
return resolver.Target{Endpoint: target}
|
||||
@@ -61,7 +82,7 @@ func ParseTarget(target string, skipUnixColonParsing bool) (ret resolver.Target)
|
||||
}
|
||||
if ret.Scheme == "unix" {
|
||||
// Add the "/" back in the unix case, so the unix resolver receives the
|
||||
// actual endpoint.
|
||||
// actual endpoint in the "unix://[/absolute/path]" case.
|
||||
ret.Endpoint = "/" + ret.Endpoint
|
||||
}
|
||||
return ret
|
||||
|
17
vendor/google.golang.org/grpc/internal/internal.go
generated
vendored
17
vendor/google.golang.org/grpc/internal/internal.go
generated
vendored
@@ -38,12 +38,6 @@ var (
|
||||
// KeepaliveMinPingTime is the minimum ping interval. This must be 10s by
|
||||
// default, but tests may wish to set it lower for convenience.
|
||||
KeepaliveMinPingTime = 10 * time.Second
|
||||
// NewRequestInfoContext creates a new context based on the argument context attaching
|
||||
// the passed in RequestInfo to the new context.
|
||||
NewRequestInfoContext interface{} // func(context.Context, credentials.RequestInfo) context.Context
|
||||
// NewClientHandshakeInfoContext returns a copy of the input context with
|
||||
// the passed in ClientHandshakeInfo struct added to it.
|
||||
NewClientHandshakeInfoContext interface{} // func(context.Context, credentials.ClientHandshakeInfo) context.Context
|
||||
// ParseServiceConfigForTesting is for creating a fake
|
||||
// ClientConn for resolver testing only
|
||||
ParseServiceConfigForTesting interface{} // func(string) *serviceconfig.ParseResult
|
||||
@@ -60,7 +54,16 @@ var (
|
||||
// GetXDSHandshakeInfoForTesting returns a pointer to the xds.HandshakeInfo
|
||||
// stored in the passed in attributes. This is set by
|
||||
// credentials/xds/xds.go.
|
||||
GetXDSHandshakeInfoForTesting interface{} // func (attr *attributes.Attributes) *xds.HandshakeInfo
|
||||
GetXDSHandshakeInfoForTesting interface{} // func (*attributes.Attributes) *xds.HandshakeInfo
|
||||
// GetServerCredentials returns the transport credentials configured on a
|
||||
// gRPC server. An xDS-enabled server needs to know what type of credentials
|
||||
// is configured on the underlying gRPC server. This is set by server.go.
|
||||
GetServerCredentials interface{} // func (*grpc.Server) credentials.TransportCredentials
|
||||
// DrainServerTransports initiates a graceful close of existing connections
|
||||
// on a gRPC server accepted on the provided listener address. An
|
||||
// xDS-enabled server invokes this method on a grpc.Server when a particular
|
||||
// listener moves to "not-serving" mode.
|
||||
DrainServerTransports interface{} // func(*grpc.Server, string)
|
||||
)
|
||||
|
||||
// HealthChecker defines the signature of the client-side LB channel health checking function.
|
||||
|
50
vendor/google.golang.org/grpc/internal/metadata/metadata.go
generated
vendored
Normal file
50
vendor/google.golang.org/grpc/internal/metadata/metadata.go
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2020 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
// Package metadata contains functions to set and get metadata from addresses.
|
||||
//
|
||||
// This package is experimental.
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
type mdKeyType string
|
||||
|
||||
const mdKey = mdKeyType("grpc.internal.address.metadata")
|
||||
|
||||
// Get returns the metadata of addr.
|
||||
func Get(addr resolver.Address) metadata.MD {
|
||||
attrs := addr.Attributes
|
||||
if attrs == nil {
|
||||
return nil
|
||||
}
|
||||
md, _ := attrs.Value(mdKey).(metadata.MD)
|
||||
return md
|
||||
}
|
||||
|
||||
// Set sets (overrides) the metadata in addr.
|
||||
//
|
||||
// When a SubConn is created with this address, the RPCs sent on it will all
|
||||
// have this metadata.
|
||||
func Set(addr resolver.Address, md metadata.MD) resolver.Address {
|
||||
addr.Attributes = addr.Attributes.WithValues(mdKey, md)
|
||||
return addr
|
||||
}
|
77
vendor/google.golang.org/grpc/internal/resolver/config_selector.go
generated
vendored
77
vendor/google.golang.org/grpc/internal/resolver/config_selector.go
generated
vendored
@@ -24,13 +24,16 @@ import (
|
||||
"sync"
|
||||
|
||||
"google.golang.org/grpc/internal/serviceconfig"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
// ConfigSelector controls what configuration to use for every RPC.
|
||||
type ConfigSelector interface {
|
||||
// Selects the configuration for the RPC.
|
||||
SelectConfig(RPCInfo) *RPCConfig
|
||||
// Selects the configuration for the RPC, or terminates it using the error.
|
||||
// This error will be converted by the gRPC library to a status error with
|
||||
// code UNKNOWN if it is not returned as a status error.
|
||||
SelectConfig(RPCInfo) (*RPCConfig, error)
|
||||
}
|
||||
|
||||
// RPCInfo contains RPC information needed by a ConfigSelector.
|
||||
@@ -49,6 +52,74 @@ type RPCConfig struct {
|
||||
Context context.Context
|
||||
MethodConfig serviceconfig.MethodConfig // configuration to use for this RPC
|
||||
OnCommitted func() // Called when the RPC has been committed (retries no longer possible)
|
||||
Interceptor ClientInterceptor
|
||||
}
|
||||
|
||||
// ClientStream is the same as grpc.ClientStream, but defined here for circular
|
||||
// dependency reasons.
|
||||
type ClientStream interface {
|
||||
// Header returns the header metadata received from the server if there
|
||||
// is any. It blocks if the metadata is not ready to read.
|
||||
Header() (metadata.MD, error)
|
||||
// Trailer returns the trailer metadata from the server, if there is any.
|
||||
// It must only be called after stream.CloseAndRecv has returned, or
|
||||
// stream.Recv has returned a non-nil error (including io.EOF).
|
||||
Trailer() metadata.MD
|
||||
// CloseSend closes the send direction of the stream. It closes the stream
|
||||
// when non-nil error is met. It is also not safe to call CloseSend
|
||||
// concurrently with SendMsg.
|
||||
CloseSend() error
|
||||
// Context returns the context for this stream.
|
||||
//
|
||||
// It should not be called until after Header or RecvMsg has returned. Once
|
||||
// called, subsequent client-side retries are disabled.
|
||||
Context() context.Context
|
||||
// SendMsg is generally called by generated code. On error, SendMsg aborts
|
||||
// the stream. If the error was generated by the client, the status is
|
||||
// returned directly; otherwise, io.EOF is returned and the status of
|
||||
// the stream may be discovered using RecvMsg.
|
||||
//
|
||||
// SendMsg blocks until:
|
||||
// - There is sufficient flow control to schedule m with the transport, or
|
||||
// - The stream is done, or
|
||||
// - The stream breaks.
|
||||
//
|
||||
// SendMsg does not wait until the message is received by the server. An
|
||||
// untimely stream closure may result in lost messages. To ensure delivery,
|
||||
// users should ensure the RPC completed successfully using RecvMsg.
|
||||
//
|
||||
// It is safe to have a goroutine calling SendMsg and another goroutine
|
||||
// calling RecvMsg on the same stream at the same time, but it is not safe
|
||||
// to call SendMsg on the same stream in different goroutines. It is also
|
||||
// not safe to call CloseSend concurrently with SendMsg.
|
||||
SendMsg(m interface{}) error
|
||||
// RecvMsg blocks until it receives a message into m or the stream is
|
||||
// done. It returns io.EOF when the stream completes successfully. On
|
||||
// any other error, the stream is aborted and the error contains the RPC
|
||||
// status.
|
||||
//
|
||||
// It is safe to have a goroutine calling SendMsg and another goroutine
|
||||
// calling RecvMsg on the same stream at the same time, but it is not
|
||||
// safe to call RecvMsg on the same stream in different goroutines.
|
||||
RecvMsg(m interface{}) error
|
||||
}
|
||||
|
||||
// ClientInterceptor is an interceptor for gRPC client streams.
|
||||
type ClientInterceptor interface {
|
||||
// NewStream produces a ClientStream for an RPC which may optionally use
|
||||
// the provided function to produce a stream for delegation. Note:
|
||||
// RPCInfo.Context should not be used (will be nil).
|
||||
//
|
||||
// done is invoked when the RPC is finished using its connection, or could
|
||||
// not be assigned a connection. RPC operations may still occur on
|
||||
// ClientStream after done is called, since the interceptor is invoked by
|
||||
// application-layer operations. done must never be nil when called.
|
||||
NewStream(ctx context.Context, ri RPCInfo, done func(), newStream func(ctx context.Context, done func()) (ClientStream, error)) (ClientStream, error)
|
||||
}
|
||||
|
||||
// ServerInterceptor is unimplementable; do not use.
|
||||
type ServerInterceptor interface {
|
||||
notDefined()
|
||||
}
|
||||
|
||||
type csKeyType string
|
||||
@@ -86,7 +157,7 @@ func (scs *SafeConfigSelector) UpdateConfigSelector(cs ConfigSelector) {
|
||||
}
|
||||
|
||||
// SelectConfig defers to the current ConfigSelector in scs.
|
||||
func (scs *SafeConfigSelector) SelectConfig(r RPCInfo) *RPCConfig {
|
||||
func (scs *SafeConfigSelector) SelectConfig(r RPCInfo) (*RPCConfig, error) {
|
||||
scs.mu.RLock()
|
||||
defer scs.mu.RUnlock()
|
||||
return scs.cs.SelectConfig(r)
|
||||
|
43
vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
generated
vendored
43
vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
generated
vendored
@@ -34,6 +34,7 @@ import (
|
||||
|
||||
grpclbstate "google.golang.org/grpc/balancer/grpclb/state"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal/backoff"
|
||||
"google.golang.org/grpc/internal/envconfig"
|
||||
"google.golang.org/grpc/internal/grpcrand"
|
||||
"google.golang.org/grpc/resolver"
|
||||
@@ -46,6 +47,13 @@ var EnableSRVLookups = false
|
||||
|
||||
var logger = grpclog.Component("dns")
|
||||
|
||||
// Globals to stub out in tests. TODO: Perhaps these two can be combined into a
|
||||
// single variable for testing the resolver?
|
||||
var (
|
||||
newTimer = time.NewTimer
|
||||
newTimerDNSResRate = time.NewTimer
|
||||
)
|
||||
|
||||
func init() {
|
||||
resolver.Register(NewBuilder())
|
||||
}
|
||||
@@ -143,7 +151,6 @@ func (b *dnsBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts
|
||||
|
||||
d.wg.Add(1)
|
||||
go d.watcher()
|
||||
d.ResolveNow(resolver.ResolveNowOptions{})
|
||||
return d, nil
|
||||
}
|
||||
|
||||
@@ -201,28 +208,38 @@ func (d *dnsResolver) Close() {
|
||||
|
||||
func (d *dnsResolver) watcher() {
|
||||
defer d.wg.Done()
|
||||
backoffIndex := 1
|
||||
for {
|
||||
select {
|
||||
case <-d.ctx.Done():
|
||||
return
|
||||
case <-d.rn:
|
||||
}
|
||||
|
||||
state, err := d.lookup()
|
||||
if err != nil {
|
||||
// Report error to the underlying grpc.ClientConn.
|
||||
d.cc.ReportError(err)
|
||||
} else {
|
||||
d.cc.UpdateState(*state)
|
||||
err = d.cc.UpdateState(*state)
|
||||
}
|
||||
|
||||
// Sleep to prevent excessive re-resolutions. Incoming resolution requests
|
||||
// will be queued in d.rn.
|
||||
t := time.NewTimer(minDNSResRate)
|
||||
var timer *time.Timer
|
||||
if err == nil {
|
||||
// Success resolving, wait for the next ResolveNow. However, also wait 30 seconds at the very least
|
||||
// to prevent constantly re-resolving.
|
||||
backoffIndex = 1
|
||||
timer = newTimerDNSResRate(minDNSResRate)
|
||||
select {
|
||||
case <-d.ctx.Done():
|
||||
timer.Stop()
|
||||
return
|
||||
case <-d.rn:
|
||||
}
|
||||
} else {
|
||||
// Poll on an error found in DNS Resolver or an error received from ClientConn.
|
||||
timer = newTimer(backoff.DefaultExponential.Backoff(backoffIndex))
|
||||
backoffIndex++
|
||||
}
|
||||
select {
|
||||
case <-t.C:
|
||||
case <-d.ctx.Done():
|
||||
t.Stop()
|
||||
timer.Stop()
|
||||
return
|
||||
case <-timer.C:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
vendor/google.golang.org/grpc/internal/resolver/unix/unix.go
generated
vendored
28
vendor/google.golang.org/grpc/internal/resolver/unix/unix.go
generated
vendored
@@ -20,21 +20,34 @@
|
||||
package unix
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc/internal/transport/networktype"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
const scheme = "unix"
|
||||
const unixScheme = "unix"
|
||||
const unixAbstractScheme = "unix-abstract"
|
||||
|
||||
type builder struct{}
|
||||
type builder struct {
|
||||
scheme string
|
||||
}
|
||||
|
||||
func (*builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
cc.UpdateState(resolver.State{Addresses: []resolver.Address{networktype.Set(resolver.Address{Addr: target.Endpoint}, "unix")}})
|
||||
func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
if target.Authority != "" {
|
||||
return nil, fmt.Errorf("invalid (non-empty) authority: %v", target.Authority)
|
||||
}
|
||||
addr := resolver.Address{Addr: target.Endpoint}
|
||||
if b.scheme == unixAbstractScheme {
|
||||
// prepend "\x00" to address for unix-abstract
|
||||
addr.Addr = "\x00" + addr.Addr
|
||||
}
|
||||
cc.UpdateState(resolver.State{Addresses: []resolver.Address{networktype.Set(addr, "unix")}})
|
||||
return &nopResolver{}, nil
|
||||
}
|
||||
|
||||
func (*builder) Scheme() string {
|
||||
return scheme
|
||||
func (b *builder) Scheme() string {
|
||||
return b.scheme
|
||||
}
|
||||
|
||||
type nopResolver struct {
|
||||
@@ -45,5 +58,6 @@ func (*nopResolver) ResolveNow(resolver.ResolveNowOptions) {}
|
||||
func (*nopResolver) Close() {}
|
||||
|
||||
func init() {
|
||||
resolver.Register(&builder{})
|
||||
resolver.Register(&builder{scheme: unixScheme})
|
||||
resolver.Register(&builder{scheme: unixAbstractScheme})
|
||||
}
|
||||
|
16
vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go
generated
vendored
16
vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go
generated
vendored
@@ -46,6 +46,22 @@ type BalancerConfig struct {
|
||||
|
||||
type intermediateBalancerConfig []map[string]json.RawMessage
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
//
|
||||
// It marshals the balancer and config into a length-1 slice
|
||||
// ([]map[string]config).
|
||||
func (bc *BalancerConfig) MarshalJSON() ([]byte, error) {
|
||||
if bc.Config == nil {
|
||||
// If config is nil, return empty config `{}`.
|
||||
return []byte(fmt.Sprintf(`[{%q: %v}]`, bc.Name, "{}")), nil
|
||||
}
|
||||
c, err := json.Marshal(bc.Config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []byte(fmt.Sprintf(`[{%q: %s}]`, bc.Name, c)), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
//
|
||||
// ServiceConfig contains a list of loadBalancingConfigs, each with a name and
|
||||
|
20
vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go
generated
vendored
20
vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go
generated
vendored
@@ -44,25 +44,23 @@ func GetCPUTime() int64 {
|
||||
}
|
||||
|
||||
// Rusage is an alias for syscall.Rusage under linux environment.
|
||||
type Rusage syscall.Rusage
|
||||
type Rusage = syscall.Rusage
|
||||
|
||||
// GetRusage returns the resource usage of current process.
|
||||
func GetRusage() (rusage *Rusage) {
|
||||
rusage = new(Rusage)
|
||||
syscall.Getrusage(syscall.RUSAGE_SELF, (*syscall.Rusage)(rusage))
|
||||
return
|
||||
func GetRusage() *Rusage {
|
||||
rusage := new(Rusage)
|
||||
syscall.Getrusage(syscall.RUSAGE_SELF, rusage)
|
||||
return rusage
|
||||
}
|
||||
|
||||
// CPUTimeDiff returns the differences of user CPU time and system CPU time used
|
||||
// between two Rusage structs.
|
||||
func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
|
||||
f := (*syscall.Rusage)(first)
|
||||
l := (*syscall.Rusage)(latest)
|
||||
var (
|
||||
utimeDiffs = l.Utime.Sec - f.Utime.Sec
|
||||
utimeDiffus = l.Utime.Usec - f.Utime.Usec
|
||||
stimeDiffs = l.Stime.Sec - f.Stime.Sec
|
||||
stimeDiffus = l.Stime.Usec - f.Stime.Usec
|
||||
utimeDiffs = latest.Utime.Sec - first.Utime.Sec
|
||||
utimeDiffus = latest.Utime.Usec - first.Utime.Usec
|
||||
stimeDiffs = latest.Stime.Sec - first.Stime.Sec
|
||||
stimeDiffus = latest.Stime.Usec - first.Stime.Usec
|
||||
)
|
||||
|
||||
uTimeElapsed := float64(utimeDiffs) + float64(utimeDiffus)*1.0e-6
|
||||
|
2
vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go
generated
vendored
@@ -50,7 +50,7 @@ func GetCPUTime() int64 {
|
||||
type Rusage struct{}
|
||||
|
||||
// GetRusage is a no-op function under non-linux or appengine environment.
|
||||
func GetRusage() (rusage *Rusage) {
|
||||
func GetRusage() *Rusage {
|
||||
log()
|
||||
return nil
|
||||
}
|
||||
|
32
vendor/google.golang.org/grpc/internal/transport/controlbuf.go
generated
vendored
32
vendor/google.golang.org/grpc/internal/transport/controlbuf.go
generated
vendored
@@ -20,13 +20,17 @@ package transport
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
"google.golang.org/grpc/internal/grpcutil"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var updateHeaderTblSize = func(e *hpack.Encoder, v uint32) {
|
||||
@@ -128,6 +132,14 @@ type cleanupStream struct {
|
||||
|
||||
func (c *cleanupStream) isTransportResponseFrame() bool { return c.rst } // Results in a RST_STREAM
|
||||
|
||||
type earlyAbortStream struct {
|
||||
streamID uint32
|
||||
contentSubtype string
|
||||
status *status.Status
|
||||
}
|
||||
|
||||
func (*earlyAbortStream) isTransportResponseFrame() bool { return false }
|
||||
|
||||
type dataFrame struct {
|
||||
streamID uint32
|
||||
endStream bool
|
||||
@@ -749,6 +761,24 @@ func (l *loopyWriter) cleanupStreamHandler(c *cleanupStream) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *loopyWriter) earlyAbortStreamHandler(eas *earlyAbortStream) error {
|
||||
if l.side == clientSide {
|
||||
return errors.New("earlyAbortStream not handled on client")
|
||||
}
|
||||
|
||||
headerFields := []hpack.HeaderField{
|
||||
{Name: ":status", Value: "200"},
|
||||
{Name: "content-type", Value: grpcutil.ContentType(eas.contentSubtype)},
|
||||
{Name: "grpc-status", Value: strconv.Itoa(int(eas.status.Code()))},
|
||||
{Name: "grpc-message", Value: encodeGrpcMessage(eas.status.Message())},
|
||||
}
|
||||
|
||||
if err := l.writeHeader(eas.streamID, true, headerFields, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *loopyWriter) incomingGoAwayHandler(*incomingGoAway) error {
|
||||
if l.side == clientSide {
|
||||
l.draining = true
|
||||
@@ -787,6 +817,8 @@ func (l *loopyWriter) handle(i interface{}) error {
|
||||
return l.registerStreamHandler(i)
|
||||
case *cleanupStream:
|
||||
return l.cleanupStreamHandler(i)
|
||||
case *earlyAbortStream:
|
||||
return l.earlyAbortStreamHandler(i)
|
||||
case *incomingGoAway:
|
||||
return l.incomingGoAwayHandler(i)
|
||||
case *dataFrame:
|
||||
|
124
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
124
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
@@ -32,14 +32,14 @@ import (
|
||||
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
"google.golang.org/grpc/internal/grpcutil"
|
||||
"google.golang.org/grpc/internal/transport/networktype"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
icredentials "google.golang.org/grpc/internal/credentials"
|
||||
"google.golang.org/grpc/internal/grpcutil"
|
||||
imetadata "google.golang.org/grpc/internal/metadata"
|
||||
"google.golang.org/grpc/internal/syscall"
|
||||
"google.golang.org/grpc/internal/transport/networktype"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/peer"
|
||||
@@ -60,7 +60,7 @@ type http2Client struct {
|
||||
cancel context.CancelFunc
|
||||
ctxDone <-chan struct{} // Cache the ctx.Done() chan.
|
||||
userAgent string
|
||||
md interface{}
|
||||
md metadata.MD
|
||||
conn net.Conn // underlying communication channel
|
||||
loopy *loopyWriter
|
||||
remoteAddr net.Addr
|
||||
@@ -115,6 +115,9 @@ type http2Client struct {
|
||||
// goAwayReason records the http2.ErrCode and debug data received with the
|
||||
// GoAway frame.
|
||||
goAwayReason GoAwayReason
|
||||
// goAwayDebugMessage contains a detailed human readable string about a
|
||||
// GoAway frame, useful for error messages.
|
||||
goAwayDebugMessage string
|
||||
// A condition variable used to signal when the keepalive goroutine should
|
||||
// go dormant. The condition for dormancy is based on the number of active
|
||||
// streams and the `PermitWithoutStream` keepalive client parameter. And
|
||||
@@ -139,17 +142,26 @@ type http2Client struct {
|
||||
}
|
||||
|
||||
func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error), addr resolver.Address, useProxy bool, grpcUA string) (net.Conn, error) {
|
||||
address := addr.Addr
|
||||
networkType, ok := networktype.Get(addr)
|
||||
if fn != nil {
|
||||
return fn(ctx, addr.Addr)
|
||||
if networkType == "unix" && !strings.HasPrefix(address, "\x00") {
|
||||
// For backward compatibility, if the user dialed "unix:///path",
|
||||
// the passthrough resolver would be used and the user's custom
|
||||
// dialer would see "unix:///path". Since the unix resolver is used
|
||||
// and the address is now "/path", prepend "unix://" so the user's
|
||||
// custom dialer sees the same address.
|
||||
return fn(ctx, "unix://"+address)
|
||||
}
|
||||
return fn(ctx, address)
|
||||
}
|
||||
networkType := "tcp"
|
||||
if n, ok := networktype.Get(addr); ok {
|
||||
networkType = n
|
||||
if !ok {
|
||||
networkType, address = parseDialTarget(address)
|
||||
}
|
||||
if networkType == "tcp" && useProxy {
|
||||
return proxyDial(ctx, addr.Addr, grpcUA)
|
||||
return proxyDial(ctx, address, grpcUA)
|
||||
}
|
||||
return (&net.Dialer{}).DialContext(ctx, networkType, addr.Addr)
|
||||
return (&net.Dialer{}).DialContext(ctx, networkType, address)
|
||||
}
|
||||
|
||||
func isTemporary(err error) bool {
|
||||
@@ -228,8 +240,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
||||
// Attributes field of resolver.Address, which is shoved into connectCtx
|
||||
// and passed to the credential handshaker. This makes it possible for
|
||||
// address specific arbitrary data to reach the credential handshaker.
|
||||
contextWithHandshakeInfo := internal.NewClientHandshakeInfoContext.(func(context.Context, credentials.ClientHandshakeInfo) context.Context)
|
||||
connectCtx = contextWithHandshakeInfo(connectCtx, credentials.ClientHandshakeInfo{Attributes: addr.Attributes})
|
||||
connectCtx = icredentials.NewClientHandshakeInfoContext(connectCtx, credentials.ClientHandshakeInfo{Attributes: addr.Attributes})
|
||||
conn, authInfo, err = transportCreds.ClientHandshake(connectCtx, addr.ServerName, conn)
|
||||
if err != nil {
|
||||
return nil, connectionErrorf(isTemporary(err), err, "transport: authentication handshake failed: %v", err)
|
||||
@@ -268,7 +279,6 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
||||
ctxDone: ctx.Done(), // Cache Done chan.
|
||||
cancel: cancel,
|
||||
userAgent: opts.UserAgent,
|
||||
md: addr.Metadata,
|
||||
conn: conn,
|
||||
remoteAddr: conn.RemoteAddr(),
|
||||
localAddr: conn.LocalAddr(),
|
||||
@@ -296,6 +306,12 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
||||
keepaliveEnabled: keepaliveEnabled,
|
||||
bufferPool: newBufferPool(),
|
||||
}
|
||||
|
||||
if md, ok := addr.Metadata.(*metadata.MD); ok {
|
||||
t.md = *md
|
||||
} else if md := imetadata.Get(addr); md != nil {
|
||||
t.md = md
|
||||
}
|
||||
t.controlBuf = newControlBuffer(t.ctxDone)
|
||||
if opts.InitialWindowSize >= defaultWindowSize {
|
||||
t.initialWindowSize = opts.InitialWindowSize
|
||||
@@ -332,12 +348,14 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
||||
// Send connection preface to server.
|
||||
n, err := t.conn.Write(clientPreface)
|
||||
if err != nil {
|
||||
t.Close()
|
||||
return nil, connectionErrorf(true, err, "transport: failed to write client preface: %v", err)
|
||||
err = connectionErrorf(true, err, "transport: failed to write client preface: %v", err)
|
||||
t.Close(err)
|
||||
return nil, err
|
||||
}
|
||||
if n != len(clientPreface) {
|
||||
t.Close()
|
||||
return nil, connectionErrorf(true, err, "transport: preface mismatch, wrote %d bytes; want %d", n, len(clientPreface))
|
||||
err = connectionErrorf(true, nil, "transport: preface mismatch, wrote %d bytes; want %d", n, len(clientPreface))
|
||||
t.Close(err)
|
||||
return nil, err
|
||||
}
|
||||
var ss []http2.Setting
|
||||
|
||||
@@ -355,14 +373,16 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
||||
}
|
||||
err = t.framer.fr.WriteSettings(ss...)
|
||||
if err != nil {
|
||||
t.Close()
|
||||
return nil, connectionErrorf(true, err, "transport: failed to write initial settings frame: %v", err)
|
||||
err = connectionErrorf(true, err, "transport: failed to write initial settings frame: %v", err)
|
||||
t.Close(err)
|
||||
return nil, err
|
||||
}
|
||||
// Adjust the connection flow control window if needed.
|
||||
if delta := uint32(icwz - defaultWindowSize); delta > 0 {
|
||||
if err := t.framer.fr.WriteWindowUpdate(0, delta); err != nil {
|
||||
t.Close()
|
||||
return nil, connectionErrorf(true, err, "transport: failed to write window update: %v", err)
|
||||
err = connectionErrorf(true, err, "transport: failed to write window update: %v", err)
|
||||
t.Close(err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,6 +419,7 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream {
|
||||
buf: newRecvBuffer(),
|
||||
headerChan: make(chan struct{}),
|
||||
contentSubtype: callHdr.ContentSubtype,
|
||||
doneFunc: callHdr.DoneFunc,
|
||||
}
|
||||
s.wq = newWriteQuota(defaultWriteQuota, s.done)
|
||||
s.requestRead = func(n int) {
|
||||
@@ -438,7 +459,7 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr)
|
||||
Method: callHdr.Method,
|
||||
AuthInfo: t.authInfo,
|
||||
}
|
||||
ctxWithRequestInfo := internal.NewRequestInfoContext.(func(context.Context, credentials.RequestInfo) context.Context)(ctx, ri)
|
||||
ctxWithRequestInfo := icredentials.NewRequestInfoContext(ctx, ri)
|
||||
authData, err := t.getTrAuthData(ctxWithRequestInfo, aud)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -512,14 +533,12 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr)
|
||||
}
|
||||
}
|
||||
}
|
||||
if md, ok := t.md.(*metadata.MD); ok {
|
||||
for k, vv := range *md {
|
||||
if isReservedHeader(k) {
|
||||
continue
|
||||
}
|
||||
for _, v := range vv {
|
||||
headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)})
|
||||
}
|
||||
for k, vv := range t.md {
|
||||
if isReservedHeader(k) {
|
||||
continue
|
||||
}
|
||||
for _, v := range vv {
|
||||
headerFields = append(headerFields, hpack.HeaderField{Name: k, Value: encodeMetadataHeader(k, v)})
|
||||
}
|
||||
}
|
||||
return headerFields, nil
|
||||
@@ -819,6 +838,9 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2.
|
||||
t.controlBuf.executeAndPut(addBackStreamQuota, cleanup)
|
||||
// This will unblock write.
|
||||
close(s.done)
|
||||
if s.doneFunc != nil {
|
||||
s.doneFunc()
|
||||
}
|
||||
}
|
||||
|
||||
// Close kicks off the shutdown process of the transport. This should be called
|
||||
@@ -828,12 +850,12 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2.
|
||||
// This method blocks until the addrConn that initiated this transport is
|
||||
// re-connected. This happens because t.onClose() begins reconnect logic at the
|
||||
// addrConn level and blocks until the addrConn is successfully connected.
|
||||
func (t *http2Client) Close() error {
|
||||
func (t *http2Client) Close(err error) {
|
||||
t.mu.Lock()
|
||||
// Make sure we only Close once.
|
||||
if t.state == closing {
|
||||
t.mu.Unlock()
|
||||
return nil
|
||||
return
|
||||
}
|
||||
// Call t.onClose before setting the state to closing to prevent the client
|
||||
// from attempting to create new streams ASAP.
|
||||
@@ -849,13 +871,19 @@ func (t *http2Client) Close() error {
|
||||
t.mu.Unlock()
|
||||
t.controlBuf.finish()
|
||||
t.cancel()
|
||||
err := t.conn.Close()
|
||||
t.conn.Close()
|
||||
if channelz.IsOn() {
|
||||
channelz.RemoveEntry(t.channelzID)
|
||||
}
|
||||
// Append info about previous goaways if there were any, since this may be important
|
||||
// for understanding the root cause for this connection to be closed.
|
||||
_, goAwayDebugMessage := t.GetGoAwayReason()
|
||||
if len(goAwayDebugMessage) > 0 {
|
||||
err = fmt.Errorf("closing transport due to: %v, received prior goaway: %v", err, goAwayDebugMessage)
|
||||
}
|
||||
// Notify all active streams.
|
||||
for _, s := range streams {
|
||||
t.closeStream(s, ErrConnClosing, false, http2.ErrCodeNo, status.New(codes.Unavailable, ErrConnClosing.Desc), nil, false)
|
||||
t.closeStream(s, err, false, http2.ErrCodeNo, status.New(codes.Unavailable, err.Error()), nil, false)
|
||||
}
|
||||
if t.statsHandler != nil {
|
||||
connEnd := &stats.ConnEnd{
|
||||
@@ -863,7 +891,6 @@ func (t *http2Client) Close() error {
|
||||
}
|
||||
t.statsHandler.HandleConn(t.ctx, connEnd)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// GracefulClose sets the state to draining, which prevents new streams from
|
||||
@@ -882,7 +909,7 @@ func (t *http2Client) GracefulClose() {
|
||||
active := len(t.activeStreams)
|
||||
t.mu.Unlock()
|
||||
if active == 0 {
|
||||
t.Close()
|
||||
t.Close(ErrConnClosing)
|
||||
return
|
||||
}
|
||||
t.controlBuf.put(&incomingGoAway{})
|
||||
@@ -1128,9 +1155,9 @@ func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
|
||||
}
|
||||
}
|
||||
id := f.LastStreamID
|
||||
if id > 0 && id%2 != 1 {
|
||||
if id > 0 && id%2 == 0 {
|
||||
t.mu.Unlock()
|
||||
t.Close()
|
||||
t.Close(connectionErrorf(true, nil, "received goaway with non-zero even-numbered numbered stream id: %v", id))
|
||||
return
|
||||
}
|
||||
// A client can receive multiple GoAways from the server (see
|
||||
@@ -1148,7 +1175,7 @@ func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
|
||||
// If there are multiple GoAways the first one should always have an ID greater than the following ones.
|
||||
if id > t.prevGoAwayID {
|
||||
t.mu.Unlock()
|
||||
t.Close()
|
||||
t.Close(connectionErrorf(true, nil, "received goaway with stream id: %v, which exceeds stream id of previous goaway: %v", id, t.prevGoAwayID))
|
||||
return
|
||||
}
|
||||
default:
|
||||
@@ -1178,7 +1205,7 @@ func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) {
|
||||
active := len(t.activeStreams)
|
||||
t.mu.Unlock()
|
||||
if active == 0 {
|
||||
t.Close()
|
||||
t.Close(connectionErrorf(true, nil, "received goaway and there are no active streams"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,12 +1221,13 @@ func (t *http2Client) setGoAwayReason(f *http2.GoAwayFrame) {
|
||||
t.goAwayReason = GoAwayTooManyPings
|
||||
}
|
||||
}
|
||||
t.goAwayDebugMessage = fmt.Sprintf("code: %s, debug data: %v", f.ErrCode, string(f.DebugData()))
|
||||
}
|
||||
|
||||
func (t *http2Client) GetGoAwayReason() GoAwayReason {
|
||||
func (t *http2Client) GetGoAwayReason() (GoAwayReason, string) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
return t.goAwayReason
|
||||
return t.goAwayReason, t.goAwayDebugMessage
|
||||
}
|
||||
|
||||
func (t *http2Client) handleWindowUpdate(f *http2.WindowUpdateFrame) {
|
||||
@@ -1296,7 +1324,8 @@ func (t *http2Client) reader() {
|
||||
// Check the validity of server preface.
|
||||
frame, err := t.framer.fr.ReadFrame()
|
||||
if err != nil {
|
||||
t.Close() // this kicks off resetTransport, so must be last before return
|
||||
err = connectionErrorf(true, err, "error reading server preface: %v", err)
|
||||
t.Close(err) // this kicks off resetTransport, so must be last before return
|
||||
return
|
||||
}
|
||||
t.conn.SetReadDeadline(time.Time{}) // reset deadline once we get the settings frame (we didn't time out, yay!)
|
||||
@@ -1305,7 +1334,8 @@ func (t *http2Client) reader() {
|
||||
}
|
||||
sf, ok := frame.(*http2.SettingsFrame)
|
||||
if !ok {
|
||||
t.Close() // this kicks off resetTransport, so must be last before return
|
||||
// this kicks off resetTransport, so must be last before return
|
||||
t.Close(connectionErrorf(true, nil, "initial http2 frame from server is not a settings frame: %T", frame))
|
||||
return
|
||||
}
|
||||
t.onPrefaceReceipt()
|
||||
@@ -1341,7 +1371,7 @@ func (t *http2Client) reader() {
|
||||
continue
|
||||
} else {
|
||||
// Transport error.
|
||||
t.Close()
|
||||
t.Close(connectionErrorf(true, err, "error reading from server: %v", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1400,7 +1430,7 @@ func (t *http2Client) keepalive() {
|
||||
continue
|
||||
}
|
||||
if outstandingPing && timeoutLeft <= 0 {
|
||||
t.Close()
|
||||
t.Close(connectionErrorf(true, nil, "keepalive ping failed to receive ACK within timeout"))
|
||||
return
|
||||
}
|
||||
t.mu.Lock()
|
||||
|
54
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
54
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
@@ -26,6 +26,7 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -355,26 +356,6 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
||||
if state.data.statsTrace != nil {
|
||||
s.ctx = stats.SetIncomingTrace(s.ctx, state.data.statsTrace)
|
||||
}
|
||||
if t.inTapHandle != nil {
|
||||
var err error
|
||||
info := &tap.Info{
|
||||
FullMethodName: state.data.method,
|
||||
}
|
||||
s.ctx, err = t.inTapHandle(s.ctx, info)
|
||||
if err != nil {
|
||||
if logger.V(logLevel) {
|
||||
logger.Warningf("transport: http2Server.operateHeaders got an error from InTapHandle: %v", err)
|
||||
}
|
||||
t.controlBuf.put(&cleanupStream{
|
||||
streamID: s.id,
|
||||
rst: true,
|
||||
rstCode: http2.ErrCodeRefusedStream,
|
||||
onWrite: func() {},
|
||||
})
|
||||
s.cancel()
|
||||
return false
|
||||
}
|
||||
}
|
||||
t.mu.Lock()
|
||||
if t.state != reachable {
|
||||
t.mu.Unlock()
|
||||
@@ -402,6 +383,39 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
||||
return true
|
||||
}
|
||||
t.maxStreamID = streamID
|
||||
if state.data.httpMethod != http.MethodPost {
|
||||
t.mu.Unlock()
|
||||
if logger.V(logLevel) {
|
||||
logger.Warningf("transport: http2Server.operateHeaders parsed a :method field: %v which should be POST", state.data.httpMethod)
|
||||
}
|
||||
t.controlBuf.put(&cleanupStream{
|
||||
streamID: streamID,
|
||||
rst: true,
|
||||
rstCode: http2.ErrCodeProtocol,
|
||||
onWrite: func() {},
|
||||
})
|
||||
s.cancel()
|
||||
return false
|
||||
}
|
||||
if t.inTapHandle != nil {
|
||||
var err error
|
||||
if s.ctx, err = t.inTapHandle(s.ctx, &tap.Info{FullMethodName: state.data.method}); err != nil {
|
||||
t.mu.Unlock()
|
||||
if logger.V(logLevel) {
|
||||
logger.Infof("transport: http2Server.operateHeaders got an error from InTapHandle: %v", err)
|
||||
}
|
||||
stat, ok := status.FromError(err)
|
||||
if !ok {
|
||||
stat = status.New(codes.PermissionDenied, err.Error())
|
||||
}
|
||||
t.controlBuf.put(&earlyAbortStream{
|
||||
streamID: s.id,
|
||||
contentSubtype: s.contentSubtype,
|
||||
status: stat,
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
t.activeStreams[streamID] = s
|
||||
if len(t.activeStreams) == 1 {
|
||||
t.idle = time.Time{}
|
||||
|
32
vendor/google.golang.org/grpc/internal/transport/http_util.go
generated
vendored
32
vendor/google.golang.org/grpc/internal/transport/http_util.go
generated
vendored
@@ -27,6 +27,7 @@ import (
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -110,6 +111,7 @@ type parsedHeaderData struct {
|
||||
timeoutSet bool
|
||||
timeout time.Duration
|
||||
method string
|
||||
httpMethod string
|
||||
// key-value metadata map from the peer.
|
||||
mdata map[string][]string
|
||||
statsTags []byte
|
||||
@@ -362,6 +364,8 @@ func (d *decodeState) processHeaderField(f hpack.HeaderField) {
|
||||
}
|
||||
d.data.statsTrace = v
|
||||
d.addMetadata(f.Name, string(v))
|
||||
case ":method":
|
||||
d.data.httpMethod = f.Value
|
||||
default:
|
||||
if isReservedHeader(f.Name) && !isWhitelistedHeader(f.Name) {
|
||||
break
|
||||
@@ -598,3 +602,31 @@ func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, maxHeaderList
|
||||
f.fr.ReadMetaHeaders = hpack.NewDecoder(http2InitHeaderTableSize, nil)
|
||||
return f
|
||||
}
|
||||
|
||||
// parseDialTarget returns the network and address to pass to dialer.
|
||||
func parseDialTarget(target string) (string, 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" {
|
||||
return n, target[m1+1:]
|
||||
}
|
||||
}
|
||||
if m2 >= 0 {
|
||||
t, err := url.Parse(target)
|
||||
if err != nil {
|
||||
return net, target
|
||||
}
|
||||
scheme := t.Scheme
|
||||
addr := t.Path
|
||||
if scheme == "unix" {
|
||||
if addr == "" {
|
||||
addr = t.Host
|
||||
}
|
||||
return scheme, addr
|
||||
}
|
||||
}
|
||||
return net, target
|
||||
}
|
||||
|
10
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
10
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
@@ -241,6 +241,7 @@ type Stream struct {
|
||||
ctx context.Context // the associated context of the stream
|
||||
cancel context.CancelFunc // always nil for client side Stream
|
||||
done chan struct{} // closed at the end of stream to unblock writers. On the client side.
|
||||
doneFunc func() // invoked at the end of stream on client side.
|
||||
ctxDone <-chan struct{} // same as done chan but for server side. Cache of ctx.Done() (for performance)
|
||||
method string // the associated RPC method of the stream
|
||||
recvCompress string
|
||||
@@ -611,6 +612,8 @@ type CallHdr struct {
|
||||
ContentSubtype string
|
||||
|
||||
PreviousAttempts int // value of grpc-previous-rpc-attempts header to set
|
||||
|
||||
DoneFunc func() // called when the stream is finished
|
||||
}
|
||||
|
||||
// ClientTransport is the common interface for all gRPC client-side transport
|
||||
@@ -619,7 +622,7 @@ type ClientTransport interface {
|
||||
// Close tears down this transport. Once it returns, the transport
|
||||
// should not be accessed any more. The caller must make sure this
|
||||
// is called only once.
|
||||
Close() error
|
||||
Close(err error)
|
||||
|
||||
// GracefulClose starts to tear down the transport: the transport will stop
|
||||
// accepting new RPCs and NewStream will return error. Once all streams are
|
||||
@@ -653,8 +656,9 @@ type ClientTransport interface {
|
||||
// HTTP/2).
|
||||
GoAway() <-chan struct{}
|
||||
|
||||
// GetGoAwayReason returns the reason why GoAway frame was received.
|
||||
GetGoAwayReason() GoAwayReason
|
||||
// GetGoAwayReason returns the reason why GoAway frame was received, along
|
||||
// with a human readable string with debug info.
|
||||
GetGoAwayReason() (GoAwayReason, string)
|
||||
|
||||
// RemoteAddr returns the remote network address.
|
||||
RemoteAddr() net.Addr
|
||||
|
40
vendor/google.golang.org/grpc/internal/xds_handshake_cluster.go
generated
vendored
Normal file
40
vendor/google.golang.org/grpc/internal/xds_handshake_cluster.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2021 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc/attributes"
|
||||
"google.golang.org/grpc/resolver"
|
||||
)
|
||||
|
||||
// handshakeClusterNameKey is the type used as the key to store cluster name in
|
||||
// the Attributes field of resolver.Address.
|
||||
type handshakeClusterNameKey struct{}
|
||||
|
||||
// SetXDSHandshakeClusterName returns a copy of addr in which the Attributes field
|
||||
// is updated with the cluster name.
|
||||
func SetXDSHandshakeClusterName(addr resolver.Address, clusterName string) resolver.Address {
|
||||
addr.Attributes = addr.Attributes.WithValues(handshakeClusterNameKey{}, clusterName)
|
||||
return addr
|
||||
}
|
||||
|
||||
// GetXDSHandshakeClusterName returns cluster name stored in attr.
|
||||
func GetXDSHandshakeClusterName(attr *attributes.Attributes) (string, bool) {
|
||||
v := attr.Value(handshakeClusterNameKey{})
|
||||
name, ok := v.(string)
|
||||
return name, ok
|
||||
}
|
26
vendor/google.golang.org/grpc/metadata/metadata.go
generated
vendored
26
vendor/google.golang.org/grpc/metadata/metadata.go
generated
vendored
@@ -75,13 +75,9 @@ func Pairs(kv ...string) MD {
|
||||
panic(fmt.Sprintf("metadata: Pairs got the odd number of input pairs for metadata: %d", len(kv)))
|
||||
}
|
||||
md := MD{}
|
||||
var key string
|
||||
for i, s := range kv {
|
||||
if i%2 == 0 {
|
||||
key = strings.ToLower(s)
|
||||
continue
|
||||
}
|
||||
md[key] = append(md[key], s)
|
||||
for i := 0; i < len(kv); i += 2 {
|
||||
key := strings.ToLower(kv[i])
|
||||
md[key] = append(md[key], kv[i+1])
|
||||
}
|
||||
return md
|
||||
}
|
||||
@@ -195,12 +191,18 @@ func FromOutgoingContext(ctx context.Context) (MD, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
mds := make([]MD, 0, len(raw.added)+1)
|
||||
mds = append(mds, raw.md)
|
||||
for _, vv := range raw.added {
|
||||
mds = append(mds, Pairs(vv...))
|
||||
out := raw.md.Copy()
|
||||
for _, added := range raw.added {
|
||||
if len(added)%2 == 1 {
|
||||
panic(fmt.Sprintf("metadata: FromOutgoingContext got an odd number of input pairs for metadata: %d", len(added)))
|
||||
}
|
||||
|
||||
for i := 0; i < len(added); i += 2 {
|
||||
key := strings.ToLower(added[i])
|
||||
out[key] = append(out[key], added[i+1])
|
||||
}
|
||||
}
|
||||
return Join(mds...), ok
|
||||
return out, ok
|
||||
}
|
||||
|
||||
type rawMD struct {
|
||||
|
2
vendor/google.golang.org/grpc/pickfirst.go
generated
vendored
2
vendor/google.golang.org/grpc/pickfirst.go
generated
vendored
@@ -84,7 +84,7 @@ func (b *pickfirstBalancer) UpdateClientConnState(cs balancer.ClientConnState) e
|
||||
b.cc.UpdateState(balancer.State{ConnectivityState: connectivity.Idle, Picker: &picker{result: balancer.PickResult{SubConn: b.sc}}})
|
||||
b.sc.Connect()
|
||||
} else {
|
||||
b.sc.UpdateAddresses(cs.ResolverState.Addresses)
|
||||
b.cc.UpdateAddresses(b.sc, cs.ResolverState.Addresses)
|
||||
b.sc.Connect()
|
||||
}
|
||||
return nil
|
||||
|
14
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go
generated
vendored
14
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go
generated
vendored
@@ -1,4 +1,8 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.1.0
|
||||
// - protoc v3.14.0
|
||||
// source: reflection/grpc_reflection_v1alpha/reflection.proto
|
||||
|
||||
package grpc_reflection_v1alpha
|
||||
|
||||
@@ -11,6 +15,7 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// ServerReflectionClient is the client API for ServerReflection service.
|
||||
@@ -31,7 +36,7 @@ func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClie
|
||||
}
|
||||
|
||||
func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &_ServerReflection_serviceDesc.Streams[0], "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo", opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -86,7 +91,7 @@ type UnsafeServerReflectionServer interface {
|
||||
}
|
||||
|
||||
func RegisterServerReflectionServer(s grpc.ServiceRegistrar, srv ServerReflectionServer) {
|
||||
s.RegisterService(&_ServerReflection_serviceDesc, srv)
|
||||
s.RegisterService(&ServerReflection_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
@@ -115,7 +120,10 @@ func (x *serverReflectionServerReflectionInfoServer) Recv() (*ServerReflectionRe
|
||||
return m, nil
|
||||
}
|
||||
|
||||
var _ServerReflection_serviceDesc = grpc.ServiceDesc{
|
||||
// ServerReflection_ServiceDesc is the grpc.ServiceDesc for ServerReflection service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var ServerReflection_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "grpc.reflection.v1alpha.ServerReflection",
|
||||
HandlerType: (*ServerReflectionServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
|
14
vendor/google.golang.org/grpc/reflection/serverreflection.go
generated
vendored
14
vendor/google.golang.org/grpc/reflection/serverreflection.go
generated
vendored
@@ -54,9 +54,19 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// GRPCServer is the interface provided by a gRPC server. It is implemented by
|
||||
// *grpc.Server, but could also be implemented by other concrete types. It acts
|
||||
// as a registry, for accumulating the services exposed by the server.
|
||||
type GRPCServer interface {
|
||||
grpc.ServiceRegistrar
|
||||
GetServiceInfo() map[string]grpc.ServiceInfo
|
||||
}
|
||||
|
||||
var _ GRPCServer = (*grpc.Server)(nil)
|
||||
|
||||
type serverReflectionServer struct {
|
||||
rpb.UnimplementedServerReflectionServer
|
||||
s *grpc.Server
|
||||
s GRPCServer
|
||||
|
||||
initSymbols sync.Once
|
||||
serviceNames []string
|
||||
@@ -64,7 +74,7 @@ type serverReflectionServer struct {
|
||||
}
|
||||
|
||||
// Register registers the server reflection service on the given gRPC server.
|
||||
func Register(s *grpc.Server) {
|
||||
func Register(s GRPCServer) {
|
||||
rpb.RegisterServerReflectionServer(s, &serverReflectionServer{
|
||||
s: s,
|
||||
})
|
||||
|
42
vendor/google.golang.org/grpc/regenerate.sh
generated
vendored
42
vendor/google.golang.org/grpc/regenerate.sh
generated
vendored
@@ -40,29 +40,14 @@ echo "go install cmd/protoc-gen-go-grpc"
|
||||
echo "git clone https://github.com/grpc/grpc-proto"
|
||||
git clone --quiet https://github.com/grpc/grpc-proto ${WORKDIR}/grpc-proto
|
||||
|
||||
echo "git clone https://github.com/protocolbuffers/protobuf"
|
||||
git clone --quiet https://github.com/protocolbuffers/protobuf ${WORKDIR}/protobuf
|
||||
|
||||
# Pull in code.proto as a proto dependency
|
||||
mkdir -p ${WORKDIR}/googleapis/google/rpc
|
||||
echo "curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto"
|
||||
curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > ${WORKDIR}/googleapis/google/rpc/code.proto
|
||||
|
||||
# Pull in the following repos to build the MeshCA config proto.
|
||||
ENVOY_API_REPOS=(
|
||||
"https://github.com/envoyproxy/data-plane-api"
|
||||
"https://github.com/cncf/udpa"
|
||||
"https://github.com/envoyproxy/protoc-gen-validate"
|
||||
)
|
||||
for repo in ${ENVOY_API_REPOS[@]}; do
|
||||
dirname=$(basename ${repo})
|
||||
mkdir -p ${WORKDIR}/${dirname}
|
||||
echo "git clone ${repo}"
|
||||
git clone --quiet ${repo} ${WORKDIR}/${dirname}
|
||||
done
|
||||
|
||||
# Pull in the MeshCA service proto.
|
||||
mkdir -p ${WORKDIR}/istio/istio/google/security/meshca/v1
|
||||
echo "curl https://raw.githubusercontent.com/istio/istio/master/security/proto/providers/google/meshca.proto"
|
||||
curl --silent https://raw.githubusercontent.com/istio/istio/master/security/proto/providers/google/meshca.proto > ${WORKDIR}/istio/istio/google/security/meshca/v1/meshca.proto
|
||||
|
||||
mkdir -p ${WORKDIR}/out
|
||||
|
||||
# Generates sources without the embed requirement
|
||||
@@ -84,15 +69,14 @@ SOURCES=(
|
||||
${WORKDIR}/grpc-proto/grpc/lookup/v1/rls.proto
|
||||
${WORKDIR}/grpc-proto/grpc/lookup/v1/rls_config.proto
|
||||
${WORKDIR}/grpc-proto/grpc/service_config/service_config.proto
|
||||
${WORKDIR}/grpc-proto/grpc/tls/provider/meshca/experimental/config.proto
|
||||
${WORKDIR}/istio/istio/google/security/meshca/v1/meshca.proto
|
||||
${WORKDIR}/grpc-proto/grpc/testing/*.proto
|
||||
${WORKDIR}/grpc-proto/grpc/core/*.proto
|
||||
)
|
||||
|
||||
# These options of the form 'Mfoo.proto=bar' instruct the codegen to use an
|
||||
# import path of 'bar' in the generated code when 'foo.proto' is imported in
|
||||
# one of the sources.
|
||||
OPTS=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config,\
|
||||
Menvoy/config/core/v3/config_source.proto=github.com/envoyproxy/go-control-plane/envoy/config/core/v3
|
||||
OPTS=Mgrpc/service_config/service_config.proto=/internal/proto/grpc_service_config,Mgrpc/core/stats.proto=google.golang.org/grpc/interop/grpc_testing/core
|
||||
|
||||
for src in ${SOURCES[@]}; do
|
||||
echo "protoc ${src}"
|
||||
@@ -100,9 +84,7 @@ for src in ${SOURCES[@]}; do
|
||||
-I"." \
|
||||
-I${WORKDIR}/grpc-proto \
|
||||
-I${WORKDIR}/googleapis \
|
||||
-I${WORKDIR}/data-plane-api \
|
||||
-I${WORKDIR}/udpa \
|
||||
-I${WORKDIR}/protoc-gen-validate \
|
||||
-I${WORKDIR}/protobuf/src \
|
||||
-I${WORKDIR}/istio \
|
||||
${src}
|
||||
done
|
||||
@@ -113,9 +95,7 @@ for src in ${LEGACY_SOURCES[@]}; do
|
||||
-I"." \
|
||||
-I${WORKDIR}/grpc-proto \
|
||||
-I${WORKDIR}/googleapis \
|
||||
-I${WORKDIR}/data-plane-api \
|
||||
-I${WORKDIR}/udpa \
|
||||
-I${WORKDIR}/protoc-gen-validate \
|
||||
-I${WORKDIR}/protobuf/src \
|
||||
-I${WORKDIR}/istio \
|
||||
${src}
|
||||
done
|
||||
@@ -132,8 +112,8 @@ rm ${WORKDIR}/out/google.golang.org/grpc/reflection/grpc_testingv3/*.pb.go
|
||||
# grpc/service_config/service_config.proto does not have a go_package option.
|
||||
mv ${WORKDIR}/out/grpc/service_config/service_config.pb.go internal/proto/grpc_service_config
|
||||
|
||||
# istio/google/security/meshca/v1/meshca.proto does not have a go_package option.
|
||||
mkdir -p ${WORKDIR}/out/google.golang.org/grpc/credentials/tls/certprovider/meshca/internal/v1/
|
||||
mv ${WORKDIR}/out/istio/google/security/meshca/v1/* ${WORKDIR}/out/google.golang.org/grpc/credentials/tls/certprovider/meshca/internal/v1/
|
||||
# grpc/testing does not have a go_package option.
|
||||
mv ${WORKDIR}/out/grpc/testing/*.pb.go interop/grpc_testing/
|
||||
mv ${WORKDIR}/out/grpc/core/*.pb.go interop/grpc_testing/core/
|
||||
|
||||
cp -R ${WORKDIR}/out/google.golang.org/grpc/* .
|
||||
|
2
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
2
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
@@ -181,7 +181,7 @@ type State struct {
|
||||
// gRPC to add new methods to this interface.
|
||||
type ClientConn interface {
|
||||
// UpdateState updates the state of the ClientConn appropriately.
|
||||
UpdateState(State)
|
||||
UpdateState(State) error
|
||||
// ReportError notifies the ClientConn that the Resolver encountered an
|
||||
// error. The ClientConn will notify the load balancer and begin calling
|
||||
// ResolveNow on the Resolver with exponential backoff.
|
||||
|
63
vendor/google.golang.org/grpc/resolver_conn_wrapper.go
generated
vendored
63
vendor/google.golang.org/grpc/resolver_conn_wrapper.go
generated
vendored
@@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/balancer"
|
||||
"google.golang.org/grpc/credentials"
|
||||
@@ -40,9 +39,6 @@ type ccResolverWrapper struct {
|
||||
resolver resolver.Resolver
|
||||
done *grpcsync.Event
|
||||
curState resolver.State
|
||||
|
||||
pollingMu sync.Mutex
|
||||
polling chan struct{}
|
||||
}
|
||||
|
||||
// newCCResolverWrapper uses the resolver.Builder to build a Resolver and
|
||||
@@ -93,59 +89,19 @@ func (ccr *ccResolverWrapper) close() {
|
||||
ccr.resolverMu.Unlock()
|
||||
}
|
||||
|
||||
// poll begins or ends asynchronous polling of the resolver based on whether
|
||||
// err is ErrBadResolverState.
|
||||
func (ccr *ccResolverWrapper) poll(err error) {
|
||||
ccr.pollingMu.Lock()
|
||||
defer ccr.pollingMu.Unlock()
|
||||
if err != balancer.ErrBadResolverState {
|
||||
// stop polling
|
||||
if ccr.polling != nil {
|
||||
close(ccr.polling)
|
||||
ccr.polling = nil
|
||||
}
|
||||
return
|
||||
}
|
||||
if ccr.polling != nil {
|
||||
// already polling
|
||||
return
|
||||
}
|
||||
p := make(chan struct{})
|
||||
ccr.polling = p
|
||||
go func() {
|
||||
for i := 0; ; i++ {
|
||||
ccr.resolveNow(resolver.ResolveNowOptions{})
|
||||
t := time.NewTimer(ccr.cc.dopts.resolveNowBackoff(i))
|
||||
select {
|
||||
case <-p:
|
||||
t.Stop()
|
||||
return
|
||||
case <-ccr.done.Done():
|
||||
// Resolver has been closed.
|
||||
t.Stop()
|
||||
return
|
||||
case <-t.C:
|
||||
select {
|
||||
case <-p:
|
||||
return
|
||||
default:
|
||||
}
|
||||
// Timer expired; re-resolve.
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (ccr *ccResolverWrapper) UpdateState(s resolver.State) {
|
||||
func (ccr *ccResolverWrapper) UpdateState(s resolver.State) error {
|
||||
if ccr.done.HasFired() {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
channelz.Infof(logger, ccr.cc.channelzID, "ccResolverWrapper: sending update to cc: %v", s)
|
||||
if channelz.IsOn() {
|
||||
ccr.addChannelzTraceEvent(s)
|
||||
}
|
||||
ccr.curState = s
|
||||
ccr.poll(ccr.cc.updateResolverState(ccr.curState, nil))
|
||||
if err := ccr.cc.updateResolverState(ccr.curState, nil); err == balancer.ErrBadResolverState {
|
||||
return balancer.ErrBadResolverState
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ccr *ccResolverWrapper) ReportError(err error) {
|
||||
@@ -153,7 +109,7 @@ func (ccr *ccResolverWrapper) ReportError(err error) {
|
||||
return
|
||||
}
|
||||
channelz.Warningf(logger, ccr.cc.channelzID, "ccResolverWrapper: reporting error to cc: %v", err)
|
||||
ccr.poll(ccr.cc.updateResolverState(resolver.State{}, err))
|
||||
ccr.cc.updateResolverState(resolver.State{}, err)
|
||||
}
|
||||
|
||||
// NewAddress is called by the resolver implementation to send addresses to gRPC.
|
||||
@@ -166,7 +122,7 @@ func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) {
|
||||
ccr.addChannelzTraceEvent(resolver.State{Addresses: addrs, ServiceConfig: ccr.curState.ServiceConfig})
|
||||
}
|
||||
ccr.curState.Addresses = addrs
|
||||
ccr.poll(ccr.cc.updateResolverState(ccr.curState, nil))
|
||||
ccr.cc.updateResolverState(ccr.curState, nil)
|
||||
}
|
||||
|
||||
// NewServiceConfig is called by the resolver implementation to send service
|
||||
@@ -183,14 +139,13 @@ func (ccr *ccResolverWrapper) NewServiceConfig(sc string) {
|
||||
scpr := parseServiceConfig(sc)
|
||||
if scpr.Err != nil {
|
||||
channelz.Warningf(logger, ccr.cc.channelzID, "ccResolverWrapper: error parsing service config: %v", scpr.Err)
|
||||
ccr.poll(balancer.ErrBadResolverState)
|
||||
return
|
||||
}
|
||||
if channelz.IsOn() {
|
||||
ccr.addChannelzTraceEvent(resolver.State{Addresses: ccr.curState.Addresses, ServiceConfig: scpr})
|
||||
}
|
||||
ccr.curState.ServiceConfig = scpr
|
||||
ccr.poll(ccr.cc.updateResolverState(ccr.curState, nil))
|
||||
ccr.cc.updateResolverState(ccr.curState, nil)
|
||||
}
|
||||
|
||||
func (ccr *ccResolverWrapper) ParseServiceConfig(scJSON string) *serviceconfig.ParseResult {
|
||||
|
22
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
22
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
@@ -429,9 +429,10 @@ func (o ContentSubtypeCallOption) before(c *callInfo) error {
|
||||
}
|
||||
func (o ContentSubtypeCallOption) after(c *callInfo, attempt *csAttempt) {}
|
||||
|
||||
// ForceCodec 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.
|
||||
// ForceCodec returns a CallOption that will set codec to be used for all
|
||||
// request and response messages for a call. The result of calling Name() will
|
||||
// be used as the content-subtype after converting to lowercase, unless
|
||||
// CallContentSubtype is also used.
|
||||
//
|
||||
// See Content-Type on
|
||||
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for
|
||||
@@ -853,7 +854,17 @@ func toRPCErr(err error) error {
|
||||
// setCallInfoCodec should only be called after CallOptions have been applied.
|
||||
func setCallInfoCodec(c *callInfo) error {
|
||||
if c.codec != nil {
|
||||
// codec was already set by a CallOption; use it.
|
||||
// codec was already set by a CallOption; use it, but set the content
|
||||
// subtype if it is not set.
|
||||
if c.contentSubtype == "" {
|
||||
// c.codec is a baseCodec to hide the difference between grpc.Codec and
|
||||
// encoding.Codec (Name vs. String method name). We only support
|
||||
// setting content subtype from encoding.Codec to avoid a behavior
|
||||
// change with the deprecated version.
|
||||
if ec, ok := c.codec.(encoding.Codec); ok {
|
||||
c.contentSubtype = strings.ToLower(ec.Name())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -888,8 +899,7 @@ type channelzData struct {
|
||||
// buffer files to ensure compatibility with the gRPC version used. The latest
|
||||
// support package version is 7.
|
||||
//
|
||||
// Older versions are kept for compatibility. They may be removed if
|
||||
// compatibility cannot be maintained.
|
||||
// Older versions are kept for compatibility.
|
||||
//
|
||||
// These constants should not be referenced from any other code.
|
||||
const (
|
||||
|
120
vendor/google.golang.org/grpc/server.go
generated
vendored
120
vendor/google.golang.org/grpc/server.go
generated
vendored
@@ -40,6 +40,7 @@ import (
|
||||
"google.golang.org/grpc/encoding"
|
||||
"google.golang.org/grpc/encoding/proto"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/internal"
|
||||
"google.golang.org/grpc/internal/binarylog"
|
||||
"google.golang.org/grpc/internal/channelz"
|
||||
"google.golang.org/grpc/internal/grpcrand"
|
||||
@@ -56,8 +57,24 @@ import (
|
||||
const (
|
||||
defaultServerMaxReceiveMessageSize = 1024 * 1024 * 4
|
||||
defaultServerMaxSendMessageSize = math.MaxInt32
|
||||
|
||||
// Server transports are tracked in a map which is keyed on listener
|
||||
// address. For regular gRPC traffic, connections are accepted in Serve()
|
||||
// through a call to Accept(), and we use the actual listener address as key
|
||||
// when we add it to the map. But for connections received through
|
||||
// ServeHTTP(), we do not have a listener and hence use this dummy value.
|
||||
listenerAddressForServeHTTP = "listenerAddressForServeHTTP"
|
||||
)
|
||||
|
||||
func init() {
|
||||
internal.GetServerCredentials = func(srv *Server) credentials.TransportCredentials {
|
||||
return srv.opts.creds
|
||||
}
|
||||
internal.DrainServerTransports = func(srv *Server, addr string) {
|
||||
srv.drainServerTransports(addr)
|
||||
}
|
||||
}
|
||||
|
||||
var statusOK = status.New(codes.OK, "")
|
||||
var logger = grpclog.Component("core")
|
||||
|
||||
@@ -100,9 +117,12 @@ type serverWorkerData struct {
|
||||
type Server struct {
|
||||
opts serverOptions
|
||||
|
||||
mu sync.Mutex // guards following
|
||||
lis map[net.Listener]bool
|
||||
conns map[transport.ServerTransport]bool
|
||||
mu sync.Mutex // guards following
|
||||
lis map[net.Listener]bool
|
||||
// conns contains all active server transports. It is a map keyed on a
|
||||
// listener address with the value being the set of active transports
|
||||
// belonging to that listener.
|
||||
conns map[string]map[transport.ServerTransport]bool
|
||||
serve bool
|
||||
drain bool
|
||||
cv *sync.Cond // signaled when connections close for GracefulStop
|
||||
@@ -259,6 +279,35 @@ func CustomCodec(codec Codec) ServerOption {
|
||||
})
|
||||
}
|
||||
|
||||
// ForceServerCodec returns a ServerOption that sets a codec for message
|
||||
// marshaling and unmarshaling.
|
||||
//
|
||||
// This will override any lookups by content-subtype for Codecs registered
|
||||
// with RegisterCodec.
|
||||
//
|
||||
// See Content-Type on
|
||||
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests for
|
||||
// more details. Also see the documentation on RegisterCodec and
|
||||
// CallContentSubtype for more details on the interaction between encoding.Codec
|
||||
// and content-subtype.
|
||||
//
|
||||
// This function is provided for advanced users; prefer to register codecs
|
||||
// using encoding.RegisterCodec.
|
||||
// The server will automatically use registered codecs based on the incoming
|
||||
// requests' headers. See also
|
||||
// https://github.com/grpc/grpc-go/blob/master/Documentation/encoding.md#using-a-codec.
|
||||
// Will be supported throughout 1.x.
|
||||
//
|
||||
// Experimental
|
||||
//
|
||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
||||
// later release.
|
||||
func ForceServerCodec(codec encoding.Codec) ServerOption {
|
||||
return newFuncServerOption(func(o *serverOptions) {
|
||||
o.codec = codec
|
||||
})
|
||||
}
|
||||
|
||||
// RPCCompressor returns a ServerOption that sets a compressor for outbound
|
||||
// messages. For backward compatibility, all outbound messages will be sent
|
||||
// using this compressor, regardless of incoming message compression. By
|
||||
@@ -369,6 +418,11 @@ func ChainStreamInterceptor(interceptors ...StreamServerInterceptor) ServerOptio
|
||||
|
||||
// InTapHandle returns a ServerOption that sets the tap handle for all the server
|
||||
// transport to be created. Only one can be installed.
|
||||
//
|
||||
// Experimental
|
||||
//
|
||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
||||
// later release.
|
||||
func InTapHandle(h tap.ServerInHandle) ServerOption {
|
||||
return newFuncServerOption(func(o *serverOptions) {
|
||||
if o.inTapHandle != nil {
|
||||
@@ -512,7 +566,7 @@ func NewServer(opt ...ServerOption) *Server {
|
||||
s := &Server{
|
||||
lis: make(map[net.Listener]bool),
|
||||
opts: opts,
|
||||
conns: make(map[transport.ServerTransport]bool),
|
||||
conns: make(map[string]map[transport.ServerTransport]bool),
|
||||
services: make(map[string]*serviceInfo),
|
||||
quit: grpcsync.NewEvent(),
|
||||
done: grpcsync.NewEvent(),
|
||||
@@ -771,7 +825,7 @@ func (s *Server) Serve(lis net.Listener) error {
|
||||
// s.conns before this conn can be added.
|
||||
s.serveWG.Add(1)
|
||||
go func() {
|
||||
s.handleRawConn(rawConn)
|
||||
s.handleRawConn(lis.Addr().String(), rawConn)
|
||||
s.serveWG.Done()
|
||||
}()
|
||||
}
|
||||
@@ -779,7 +833,7 @@ func (s *Server) Serve(lis net.Listener) error {
|
||||
|
||||
// handleRawConn forks a goroutine to handle a just-accepted connection that
|
||||
// has not had any I/O performed on it yet.
|
||||
func (s *Server) handleRawConn(rawConn net.Conn) {
|
||||
func (s *Server) handleRawConn(lisAddr string, rawConn net.Conn) {
|
||||
if s.quit.HasFired() {
|
||||
rawConn.Close()
|
||||
return
|
||||
@@ -807,15 +861,24 @@ func (s *Server) handleRawConn(rawConn net.Conn) {
|
||||
}
|
||||
|
||||
rawConn.SetDeadline(time.Time{})
|
||||
if !s.addConn(st) {
|
||||
if !s.addConn(lisAddr, st) {
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
s.serveStreams(st)
|
||||
s.removeConn(st)
|
||||
s.removeConn(lisAddr, st)
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *Server) drainServerTransports(addr string) {
|
||||
s.mu.Lock()
|
||||
conns := s.conns[addr]
|
||||
for st := range conns {
|
||||
st.Drain()
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// newHTTP2Transport sets up a http/2 transport (using the
|
||||
// gRPC http2 server transport in transport/http2_server.go).
|
||||
func (s *Server) newHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) transport.ServerTransport {
|
||||
@@ -917,10 +980,10 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if !s.addConn(st) {
|
||||
if !s.addConn(listenerAddressForServeHTTP, st) {
|
||||
return
|
||||
}
|
||||
defer s.removeConn(st)
|
||||
defer s.removeConn(listenerAddressForServeHTTP, st)
|
||||
s.serveStreams(st)
|
||||
}
|
||||
|
||||
@@ -948,7 +1011,7 @@ func (s *Server) traceInfo(st transport.ServerTransport, stream *transport.Strea
|
||||
return trInfo
|
||||
}
|
||||
|
||||
func (s *Server) addConn(st transport.ServerTransport) bool {
|
||||
func (s *Server) addConn(addr string, st transport.ServerTransport) bool {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.conns == nil {
|
||||
@@ -960,15 +1023,28 @@ func (s *Server) addConn(st transport.ServerTransport) bool {
|
||||
// immediately.
|
||||
st.Drain()
|
||||
}
|
||||
s.conns[st] = true
|
||||
|
||||
if s.conns[addr] == nil {
|
||||
// Create a map entry if this is the first connection on this listener.
|
||||
s.conns[addr] = make(map[transport.ServerTransport]bool)
|
||||
}
|
||||
s.conns[addr][st] = true
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *Server) removeConn(st transport.ServerTransport) {
|
||||
func (s *Server) removeConn(addr string, st transport.ServerTransport) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.conns != nil {
|
||||
delete(s.conns, st)
|
||||
|
||||
conns := s.conns[addr]
|
||||
if conns != nil {
|
||||
delete(conns, st)
|
||||
if len(conns) == 0 {
|
||||
// If the last connection for this address is being removed, also
|
||||
// remove the map entry corresponding to the address. This is used
|
||||
// in GracefulStop() when waiting for all connections to be closed.
|
||||
delete(s.conns, addr)
|
||||
}
|
||||
s.cv.Broadcast()
|
||||
}
|
||||
}
|
||||
@@ -1632,7 +1708,7 @@ func (s *Server) Stop() {
|
||||
s.mu.Lock()
|
||||
listeners := s.lis
|
||||
s.lis = nil
|
||||
st := s.conns
|
||||
conns := s.conns
|
||||
s.conns = nil
|
||||
// interrupt GracefulStop if Stop and GracefulStop are called concurrently.
|
||||
s.cv.Broadcast()
|
||||
@@ -1641,8 +1717,10 @@ func (s *Server) Stop() {
|
||||
for lis := range listeners {
|
||||
lis.Close()
|
||||
}
|
||||
for c := range st {
|
||||
c.Close()
|
||||
for _, cs := range conns {
|
||||
for st := range cs {
|
||||
st.Close()
|
||||
}
|
||||
}
|
||||
if s.opts.numServerWorkers > 0 {
|
||||
s.stopServerWorkers()
|
||||
@@ -1679,8 +1757,10 @@ func (s *Server) GracefulStop() {
|
||||
}
|
||||
s.lis = nil
|
||||
if !s.drain {
|
||||
for st := range s.conns {
|
||||
st.Drain()
|
||||
for _, conns := range s.conns {
|
||||
for st := range conns {
|
||||
st.Drain()
|
||||
}
|
||||
}
|
||||
s.drain = true
|
||||
}
|
||||
|
8
vendor/google.golang.org/grpc/status/status.go
generated
vendored
8
vendor/google.golang.org/grpc/status/status.go
generated
vendored
@@ -73,9 +73,11 @@ func FromProto(s *spb.Status) *Status {
|
||||
return status.FromProto(s)
|
||||
}
|
||||
|
||||
// FromError returns a Status representing err if it was produced from this
|
||||
// package or has a method `GRPCStatus() *Status`. Otherwise, ok is false and a
|
||||
// Status is returned with codes.Unknown and the original error message.
|
||||
// FromError returns a Status representing err if it was produced by this
|
||||
// package or has a method `GRPCStatus() *Status`.
|
||||
// If err is nil, a Status is returned with codes.OK and no message.
|
||||
// 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 nil, true
|
||||
|
47
vendor/google.golang.org/grpc/stream.go
generated
vendored
47
vendor/google.golang.org/grpc/stream.go
generated
vendored
@@ -52,14 +52,20 @@ import (
|
||||
// of the RPC.
|
||||
type StreamHandler func(srv interface{}, stream ServerStream) error
|
||||
|
||||
// StreamDesc represents a streaming RPC service's method specification.
|
||||
// StreamDesc represents a streaming RPC service's method specification. Used
|
||||
// on the server when registering services and on the client when initiating
|
||||
// new streams.
|
||||
type StreamDesc struct {
|
||||
StreamName string
|
||||
Handler StreamHandler
|
||||
// StreamName and Handler are only used when registering handlers on a
|
||||
// server.
|
||||
StreamName string // the name of the method excluding the service
|
||||
Handler StreamHandler // the handler called for the method
|
||||
|
||||
// At least one of these is true.
|
||||
ServerStreams bool
|
||||
ClientStreams bool
|
||||
// ServerStreams and ClientStreams are used for registering handlers on a
|
||||
// server as well as defining RPC behavior when passed to NewClientStream
|
||||
// and ClientConn.NewStream. At least one must be true.
|
||||
ServerStreams bool // indicates the server can perform streaming sends
|
||||
ClientStreams bool // indicates the client can perform streaming sends
|
||||
}
|
||||
|
||||
// Stream defines the common interface a client or server stream has to satisfy.
|
||||
@@ -166,7 +172,6 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
|
||||
}
|
||||
}()
|
||||
}
|
||||
c := defaultCallInfo()
|
||||
// Provide an opportunity for the first RPC to see the first service config
|
||||
// provided by the resolver.
|
||||
if err := cc.waitForResolvedAddrs(ctx); err != nil {
|
||||
@@ -175,15 +180,40 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
|
||||
|
||||
var mc serviceconfig.MethodConfig
|
||||
var onCommit func()
|
||||
rpcConfig := cc.safeConfigSelector.SelectConfig(iresolver.RPCInfo{Context: ctx, Method: method})
|
||||
var newStream = func(ctx context.Context, done func()) (iresolver.ClientStream, error) {
|
||||
return newClientStreamWithParams(ctx, desc, cc, method, mc, onCommit, done, opts...)
|
||||
}
|
||||
|
||||
rpcInfo := iresolver.RPCInfo{Context: ctx, Method: method}
|
||||
rpcConfig, err := cc.safeConfigSelector.SelectConfig(rpcInfo)
|
||||
if err != nil {
|
||||
return nil, toRPCErr(err)
|
||||
}
|
||||
|
||||
if rpcConfig != nil {
|
||||
if rpcConfig.Context != nil {
|
||||
ctx = rpcConfig.Context
|
||||
}
|
||||
mc = rpcConfig.MethodConfig
|
||||
onCommit = rpcConfig.OnCommitted
|
||||
if rpcConfig.Interceptor != nil {
|
||||
rpcInfo.Context = nil
|
||||
ns := newStream
|
||||
newStream = func(ctx context.Context, done func()) (iresolver.ClientStream, error) {
|
||||
cs, err := rpcConfig.Interceptor.NewStream(ctx, rpcInfo, done, ns)
|
||||
if err != nil {
|
||||
return nil, toRPCErr(err)
|
||||
}
|
||||
return cs, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newStream(ctx, func() {})
|
||||
}
|
||||
|
||||
func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, mc serviceconfig.MethodConfig, onCommit, doneFunc func(), opts ...CallOption) (_ iresolver.ClientStream, err error) {
|
||||
c := defaultCallInfo()
|
||||
if mc.WaitForReady != nil {
|
||||
c.failFast = !*mc.WaitForReady
|
||||
}
|
||||
@@ -220,6 +250,7 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
|
||||
Host: cc.authority,
|
||||
Method: method,
|
||||
ContentSubtype: c.contentSubtype,
|
||||
DoneFunc: doneFunc,
|
||||
}
|
||||
|
||||
// Set our outgoing compression according to the UseCompressor CallOption, if
|
||||
|
16
vendor/google.golang.org/grpc/tap/tap.go
generated
vendored
16
vendor/google.golang.org/grpc/tap/tap.go
generated
vendored
@@ -37,16 +37,16 @@ type Info struct {
|
||||
// TODO: More to be added.
|
||||
}
|
||||
|
||||
// ServerInHandle defines the function which runs before a new stream is created
|
||||
// on the server side. If it returns a non-nil error, the stream will not be
|
||||
// created and a RST_STREAM will be sent back to the client with REFUSED_STREAM.
|
||||
// The client will receive an RPC error "code = Unavailable, desc = stream
|
||||
// terminated by RST_STREAM with error code: REFUSED_STREAM".
|
||||
// ServerInHandle defines the function which runs before a new stream is
|
||||
// created on the server side. If it returns a non-nil error, the stream will
|
||||
// not be created and an error will be returned to the client. If the error
|
||||
// returned is a status error, that status code and message will be used,
|
||||
// otherwise PermissionDenied will be the code and err.Error() will be the
|
||||
// message.
|
||||
//
|
||||
// It's intended to be used in situations where you don't want to waste the
|
||||
// resources to accept the new stream (e.g. rate-limiting). And the content of
|
||||
// the error will be ignored and won't be sent back to the client. For other
|
||||
// general usages, please use interceptors.
|
||||
// resources to accept the new stream (e.g. rate-limiting). For other general
|
||||
// usages, please use interceptors.
|
||||
//
|
||||
// Note that it is executed in the per-connection I/O goroutine(s) instead of
|
||||
// per-RPC goroutine. Therefore, users should NOT have any
|
||||
|
2
vendor/google.golang.org/grpc/version.go
generated
vendored
2
vendor/google.golang.org/grpc/version.go
generated
vendored
@@ -19,4 +19,4 @@
|
||||
package grpc
|
||||
|
||||
// Version is the current grpc version.
|
||||
const Version = "1.34.0"
|
||||
const Version = "1.38.0"
|
||||
|
43
vendor/google.golang.org/grpc/vet.sh
generated
vendored
43
vendor/google.golang.org/grpc/vet.sh
generated
vendored
@@ -28,7 +28,8 @@ cleanup() {
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
|
||||
PATH="${HOME}/go/bin:${GOROOT}/bin:${PATH}"
|
||||
go version
|
||||
|
||||
if [[ "$1" = "-install" ]]; then
|
||||
# Check for module support
|
||||
@@ -104,12 +105,6 @@ git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' ':(exclude)*.
|
||||
# TODO: Remove when we drop Go 1.10 support
|
||||
go list -f {{.Dir}} ./... | xargs go run test/go_vet/vet.go
|
||||
|
||||
# - gofmt, goimports, golint (with exceptions for generated code), go vet.
|
||||
gofmt -s -d -l . 2>&1 | fail_on_output
|
||||
goimports -l . 2>&1 | not grep -vE "\.pb\.go"
|
||||
golint ./... 2>&1 | not grep -vE "\.pb\.go:"
|
||||
go vet -all ./...
|
||||
|
||||
misspell -error .
|
||||
|
||||
# - Check that generated proto files are up to date.
|
||||
@@ -119,12 +114,22 @@ if [[ -z "${VET_SKIP_PROTO}" ]]; then
|
||||
(git status; git --no-pager diff; exit 1)
|
||||
fi
|
||||
|
||||
# - Check that our modules are tidy.
|
||||
if go help mod >& /dev/null; then
|
||||
find . -name 'go.mod' | xargs -IXXX bash -c 'cd $(dirname XXX); go mod tidy'
|
||||
# - gofmt, goimports, golint (with exceptions for generated code), go vet,
|
||||
# go mod tidy.
|
||||
# Perform these checks on each module inside gRPC.
|
||||
for MOD_FILE in $(find . -name 'go.mod'); do
|
||||
MOD_DIR=$(dirname ${MOD_FILE})
|
||||
pushd ${MOD_DIR}
|
||||
go vet -all ./... | fail_on_output
|
||||
gofmt -s -d -l . 2>&1 | fail_on_output
|
||||
goimports -l . 2>&1 | not grep -vE "\.pb\.go"
|
||||
golint ./... 2>&1 | not grep -vE "/testv3\.pb\.go:"
|
||||
|
||||
go mod tidy
|
||||
git status --porcelain 2>&1 | fail_on_output || \
|
||||
(git status; git --no-pager diff; exit 1)
|
||||
fi
|
||||
popd
|
||||
done
|
||||
|
||||
# - Collection of static analysis checks
|
||||
#
|
||||
@@ -141,8 +146,11 @@ not grep -Fv '.CredsBundle
|
||||
.NewAddress
|
||||
.NewServiceConfig
|
||||
.Type is deprecated: use Attributes
|
||||
BuildVersion is deprecated
|
||||
balancer.ErrTransientFailure
|
||||
balancer.Picker
|
||||
extDesc.Filename is deprecated
|
||||
github.com/golang/protobuf/jsonpb is deprecated
|
||||
grpc.CallCustomCodec
|
||||
grpc.Code
|
||||
grpc.Compressor
|
||||
@@ -164,13 +172,7 @@ grpc.WithServiceConfig
|
||||
grpc.WithTimeout
|
||||
http.CloseNotifier
|
||||
info.SecurityVersion
|
||||
resolver.Backend
|
||||
resolver.GRPCLB
|
||||
extDesc.Filename is deprecated
|
||||
BuildVersion is deprecated
|
||||
github.com/golang/protobuf/jsonpb is deprecated
|
||||
proto is deprecated
|
||||
xxx_messageInfo_
|
||||
proto.InternalMessageInfo is deprecated
|
||||
proto.EnumName is deprecated
|
||||
proto.ErrInternalBadWireType is deprecated
|
||||
@@ -184,7 +186,12 @@ proto.RegisterExtension is deprecated
|
||||
proto.RegisteredExtension is deprecated
|
||||
proto.RegisteredExtensions is deprecated
|
||||
proto.RegisterMapType is deprecated
|
||||
proto.Unmarshaler is deprecated' "${SC_OUT}"
|
||||
proto.Unmarshaler is deprecated
|
||||
resolver.Backend
|
||||
resolver.GRPCLB
|
||||
Target is deprecated: Use the Target field in the BuildOptions instead.
|
||||
xxx_messageInfo_
|
||||
' "${SC_OUT}"
|
||||
|
||||
# - special golint on package comments.
|
||||
lint_package_comment_per_package() {
|
||||
|
30
vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
30
vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
@@ -6,7 +6,6 @@ package prototext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
@@ -23,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
// Unmarshal reads the given []byte into the given proto.Message.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func Unmarshal(b []byte, m proto.Message) error {
|
||||
return UnmarshalOptions{}.Unmarshal(b, m)
|
||||
}
|
||||
@@ -51,8 +51,9 @@ type UnmarshalOptions struct {
|
||||
}
|
||||
}
|
||||
|
||||
// Unmarshal reads the given []byte and populates the given proto.Message using options in
|
||||
// UnmarshalOptions object.
|
||||
// Unmarshal reads the given []byte and populates the given proto.Message
|
||||
// using options in the UnmarshalOptions object.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
|
||||
return o.unmarshal(b, m)
|
||||
}
|
||||
@@ -158,21 +159,11 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
switch tok.NameKind() {
|
||||
case text.IdentName:
|
||||
name = pref.Name(tok.IdentName())
|
||||
fd = fieldDescs.ByName(name)
|
||||
if fd == nil {
|
||||
// The proto name of a group field is in all lowercase,
|
||||
// while the textproto field name is the group message name.
|
||||
gd := fieldDescs.ByName(pref.Name(strings.ToLower(string(name))))
|
||||
if gd != nil && gd.Kind() == pref.GroupKind && gd.Message().Name() == name {
|
||||
fd = gd
|
||||
}
|
||||
} else if fd.Kind() == pref.GroupKind && fd.Message().Name() != name {
|
||||
fd = nil // reset since field name is actually the message name
|
||||
}
|
||||
fd = fieldDescs.ByTextName(string(name))
|
||||
|
||||
case text.TypeName:
|
||||
// Handle extensions only. This code path is not for Any.
|
||||
xt, xtErr = d.findExtension(pref.FullName(tok.TypeName()))
|
||||
xt, xtErr = d.opts.Resolver.FindExtensionByName(pref.FullName(tok.TypeName()))
|
||||
|
||||
case text.FieldNumber:
|
||||
isFieldNumberName = true
|
||||
@@ -269,15 +260,6 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// findExtension returns protoreflect.ExtensionType from the Resolver if found.
|
||||
func (d decoder) findExtension(xtName pref.FullName) (pref.ExtensionType, error) {
|
||||
xt, err := d.opts.Resolver.FindExtensionByName(xtName)
|
||||
if err == nil {
|
||||
return xt, nil
|
||||
}
|
||||
return messageset.FindMessageSetExtension(d.opts.Resolver, xtName)
|
||||
}
|
||||
|
||||
// unmarshalSingular unmarshals a non-repeated field value specified by the
|
||||
// given FieldDescriptor.
|
||||
func (d decoder) unmarshalSingular(fd pref.FieldDescriptor, m pref.Message) error {
|
||||
|
84
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
84
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
@@ -6,7 +6,6 @@ package prototext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"unicode/utf8"
|
||||
|
||||
@@ -16,10 +15,11 @@ import (
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/mapsort"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
@@ -169,35 +169,15 @@ func (e encoder) marshalMessage(m pref.Message, inclDelims bool) error {
|
||||
// If unable to expand, continue on to marshal Any as a regular message.
|
||||
}
|
||||
|
||||
// Marshal known fields.
|
||||
fieldDescs := messageDesc.Fields()
|
||||
size := fieldDescs.Len()
|
||||
for i := 0; i < size; {
|
||||
fd := fieldDescs.Get(i)
|
||||
if od := fd.ContainingOneof(); od != nil {
|
||||
fd = m.WhichOneof(od)
|
||||
i += od.Fields().Len()
|
||||
} else {
|
||||
i++
|
||||
// Marshal fields.
|
||||
var err error
|
||||
order.RangeFields(m, order.IndexNameFieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||
if err = e.marshalField(fd.TextName(), v, fd); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if fd == nil || !m.Has(fd) {
|
||||
continue
|
||||
}
|
||||
|
||||
name := fd.Name()
|
||||
// Use type name for group field name.
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
name = fd.Message().Name()
|
||||
}
|
||||
val := m.Get(fd)
|
||||
if err := e.marshalField(string(name), val, fd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Marshal extensions.
|
||||
if err := e.marshalExtensions(m); err != nil {
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -290,7 +270,7 @@ func (e encoder) marshalList(name string, list pref.List, fd pref.FieldDescripto
|
||||
// marshalMap marshals the given protoreflect.Map as multiple name-value fields.
|
||||
func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor) error {
|
||||
var err error
|
||||
mapsort.Range(mmap, fd.MapKey().Kind(), func(key pref.MapKey, val pref.Value) bool {
|
||||
order.RangeEntries(mmap, order.GenericKeyOrder, func(key pref.MapKey, val pref.Value) bool {
|
||||
e.WriteName(name)
|
||||
e.StartMessage()
|
||||
defer e.EndMessage()
|
||||
@@ -311,48 +291,6 @@ func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor)
|
||||
return err
|
||||
}
|
||||
|
||||
// marshalExtensions marshals extension fields.
|
||||
func (e encoder) marshalExtensions(m pref.Message) error {
|
||||
type entry struct {
|
||||
key string
|
||||
value pref.Value
|
||||
desc pref.FieldDescriptor
|
||||
}
|
||||
|
||||
// Get a sorted list based on field key first.
|
||||
var entries []entry
|
||||
m.Range(func(fd pref.FieldDescriptor, v pref.Value) bool {
|
||||
if !fd.IsExtension() {
|
||||
return true
|
||||
}
|
||||
// For MessageSet extensions, the name used is the parent message.
|
||||
name := fd.FullName()
|
||||
if messageset.IsMessageSetExtension(fd) {
|
||||
name = name.Parent()
|
||||
}
|
||||
entries = append(entries, entry{
|
||||
key: string(name),
|
||||
value: v,
|
||||
desc: fd,
|
||||
})
|
||||
return true
|
||||
})
|
||||
// Sort extensions lexicographically.
|
||||
sort.Slice(entries, func(i, j int) bool {
|
||||
return entries[i].key < entries[j].key
|
||||
})
|
||||
|
||||
// Write out sorted list.
|
||||
for _, entry := range entries {
|
||||
// Extension field name is the proto field name enclosed in [].
|
||||
name := "[" + entry.key + "]"
|
||||
if err := e.marshalField(name, entry.value, entry.desc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// marshalUnknown parses the given []byte and marshals fields out.
|
||||
// This function assumes proper encoding in the given []byte.
|
||||
func (e encoder) marshalUnknown(b []byte) {
|
||||
|
2
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
@@ -42,6 +42,8 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||
name = "FileImports"
|
||||
case pref.Descriptor:
|
||||
name = reflect.ValueOf(vs).MethodByName("Get").Type().Out(0).Name() + "s"
|
||||
default:
|
||||
name = reflect.ValueOf(vs).Elem().Type().Name()
|
||||
}
|
||||
start, end = name+"{", "}"
|
||||
}
|
||||
|
8
vendor/google.golang.org/protobuf/internal/detrand/rand.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/detrand/rand.go
generated
vendored
@@ -26,6 +26,14 @@ func Bool() bool {
|
||||
return randSeed%2 == 1
|
||||
}
|
||||
|
||||
// Intn returns a deterministically random integer between 0 and n-1, inclusive.
|
||||
func Intn(n int) int {
|
||||
if n <= 0 {
|
||||
panic("must be positive")
|
||||
}
|
||||
return int(randSeed % uint64(n))
|
||||
}
|
||||
|
||||
// randSeed is a best-effort at an approximate hash of the Go binary.
|
||||
var randSeed = binaryHash()
|
||||
|
||||
|
35
vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
generated
vendored
35
vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
generated
vendored
@@ -11,10 +11,9 @@ import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// The MessageSet wire format is equivalent to a message defiend as follows,
|
||||
// The MessageSet wire format is equivalent to a message defined as follows,
|
||||
// where each Item defines an extension field with a field number of 'type_id'
|
||||
// and content of 'message'. MessageSet extensions must be non-repeated message
|
||||
// fields.
|
||||
@@ -48,33 +47,17 @@ func IsMessageSet(md pref.MessageDescriptor) bool {
|
||||
return ok && xmd.IsMessageSet()
|
||||
}
|
||||
|
||||
// IsMessageSetExtension reports this field extends a MessageSet.
|
||||
// IsMessageSetExtension reports this field properly extends a MessageSet.
|
||||
func IsMessageSetExtension(fd pref.FieldDescriptor) bool {
|
||||
if fd.Name() != ExtensionName {
|
||||
switch {
|
||||
case fd.Name() != ExtensionName:
|
||||
return false
|
||||
case !IsMessageSet(fd.ContainingMessage()):
|
||||
return false
|
||||
case fd.FullName().Parent() != fd.Message().FullName():
|
||||
return false
|
||||
}
|
||||
if fd.FullName().Parent() != fd.Message().FullName() {
|
||||
return false
|
||||
}
|
||||
return IsMessageSet(fd.ContainingMessage())
|
||||
}
|
||||
|
||||
// FindMessageSetExtension locates a MessageSet extension field by name.
|
||||
// In text and JSON formats, the extension name used is the message itself.
|
||||
// The extension field name is derived by appending ExtensionName.
|
||||
func FindMessageSetExtension(r preg.ExtensionTypeResolver, s pref.FullName) (pref.ExtensionType, error) {
|
||||
name := s.Append(ExtensionName)
|
||||
xt, err := r.FindExtensionByName(name)
|
||||
if err != nil {
|
||||
if err == preg.NotFound {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrap(err, "%q", name)
|
||||
}
|
||||
if !IsMessageSetExtension(xt.TypeDescriptor()) {
|
||||
return nil, preg.NotFound
|
||||
}
|
||||
return xt, nil
|
||||
return true
|
||||
}
|
||||
|
||||
// SizeField returns the size of a MessageSet item field containing an extension
|
||||
|
2
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
@@ -104,7 +104,7 @@ func Unmarshal(tag string, goType reflect.Type, evs pref.EnumValueDescriptors) p
|
||||
case strings.HasPrefix(s, "json="):
|
||||
jsonName := s[len("json="):]
|
||||
if jsonName != strs.JSONCamelCase(string(f.L0.FullName.Name())) {
|
||||
f.L1.JSONName.Init(jsonName)
|
||||
f.L1.StringName.InitJSON(jsonName)
|
||||
}
|
||||
case s == "packed":
|
||||
f.L1.HasPacked = true
|
||||
|
8
vendor/google.golang.org/protobuf/internal/encoding/text/encode.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/encoding/text/encode.go
generated
vendored
@@ -32,7 +32,6 @@ type Encoder struct {
|
||||
encoderState
|
||||
|
||||
indent string
|
||||
newline string // set to "\n" if len(indent) > 0
|
||||
delims [2]byte
|
||||
outputASCII bool
|
||||
}
|
||||
@@ -61,7 +60,6 @@ func NewEncoder(indent string, delims [2]byte, outputASCII bool) (*Encoder, erro
|
||||
return nil, errors.New("indent may only be composed of space and tab characters")
|
||||
}
|
||||
e.indent = indent
|
||||
e.newline = "\n"
|
||||
}
|
||||
switch delims {
|
||||
case [2]byte{0, 0}:
|
||||
@@ -126,7 +124,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||
// are used to represent both the proto string and bytes type.
|
||||
r = rune(in[0])
|
||||
fallthrough
|
||||
case r < ' ' || r == '"' || r == '\\':
|
||||
case r < ' ' || r == '"' || r == '\\' || r == 0x7f:
|
||||
out = append(out, '\\')
|
||||
switch r {
|
||||
case '"', '\\':
|
||||
@@ -143,7 +141,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||
out = strconv.AppendUint(out, uint64(r), 16)
|
||||
}
|
||||
in = in[n:]
|
||||
case outputASCII && r >= utf8.RuneSelf:
|
||||
case r >= utf8.RuneSelf && (outputASCII || r <= 0x009f):
|
||||
out = append(out, '\\')
|
||||
if r <= math.MaxUint16 {
|
||||
out = append(out, 'u')
|
||||
@@ -168,7 +166,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||
// escaping. If no characters need escaping, this returns the input length.
|
||||
func indexNeedEscapeInString(s string) int {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if c := s[i]; c < ' ' || c == '"' || c == '\'' || c == '\\' || c >= utf8.RuneSelf {
|
||||
if c := s[i]; c < ' ' || c == '"' || c == '\'' || c == '\\' || c >= 0x7f {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
40
vendor/google.golang.org/protobuf/internal/fieldsort/fieldsort.go
generated
vendored
40
vendor/google.golang.org/protobuf/internal/fieldsort/fieldsort.go
generated
vendored
@@ -1,40 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package fieldsort defines an ordering of fields.
|
||||
//
|
||||
// The ordering defined by this package matches the historic behavior of the proto
|
||||
// package, placing extensions first and oneofs last.
|
||||
//
|
||||
// There is no guarantee about stability of the wire encoding, and users should not
|
||||
// depend on the order defined in this package as it is subject to change without
|
||||
// notice.
|
||||
package fieldsort
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// Less returns true if field a comes before field j in ordered wire marshal output.
|
||||
func Less(a, b protoreflect.FieldDescriptor) bool {
|
||||
ea := a.IsExtension()
|
||||
eb := b.IsExtension()
|
||||
oa := a.ContainingOneof()
|
||||
ob := b.ContainingOneof()
|
||||
switch {
|
||||
case ea != eb:
|
||||
return ea
|
||||
case oa != nil && ob != nil:
|
||||
if oa == ob {
|
||||
return a.Number() < b.Number()
|
||||
}
|
||||
return oa.Index() < ob.Index()
|
||||
case oa != nil && !oa.IsSynthetic():
|
||||
return false
|
||||
case ob != nil && !ob.IsSynthetic():
|
||||
return true
|
||||
default:
|
||||
return a.Number() < b.Number()
|
||||
}
|
||||
}
|
3
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
@@ -3,6 +3,9 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package filedesc provides functionality for constructing descriptors.
|
||||
//
|
||||
// The types in this package implement interfaces in the protoreflect package
|
||||
// related to protobuf descripriptors.
|
||||
package filedesc
|
||||
|
||||
import (
|
||||
|
77
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
77
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
@@ -13,6 +13,7 @@ import (
|
||||
"google.golang.org/protobuf/internal/descfmt"
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
"google.golang.org/protobuf/internal/encoding/defval"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
@@ -99,15 +100,6 @@ func (fd *File) lazyInitOnce() {
|
||||
fd.mu.Unlock()
|
||||
}
|
||||
|
||||
// ProtoLegacyRawDesc is a pseudo-internal API for allowing the v1 code
|
||||
// to be able to retrieve the raw descriptor.
|
||||
//
|
||||
// WARNING: This method is exempt from the compatibility promise and may be
|
||||
// removed in the future without warning.
|
||||
func (fd *File) ProtoLegacyRawDesc() []byte {
|
||||
return fd.builder.RawDescriptor
|
||||
}
|
||||
|
||||
// GoPackagePath is a pseudo-internal API for determining the Go package path
|
||||
// that this file descriptor is declared in.
|
||||
//
|
||||
@@ -207,7 +199,7 @@ type (
|
||||
Number pref.FieldNumber
|
||||
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
||||
Kind pref.Kind
|
||||
JSONName jsonName
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||
@@ -277,8 +269,9 @@ func (fd *Field) Options() pref.ProtoMessage {
|
||||
func (fd *Field) Number() pref.FieldNumber { return fd.L1.Number }
|
||||
func (fd *Field) Cardinality() pref.Cardinality { return fd.L1.Cardinality }
|
||||
func (fd *Field) Kind() pref.Kind { return fd.L1.Kind }
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.JSONName.has }
|
||||
func (fd *Field) JSONName() string { return fd.L1.JSONName.get(fd) }
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||
func (fd *Field) TextName() string { return fd.L1.StringName.getText(fd) }
|
||||
func (fd *Field) HasPresence() bool {
|
||||
return fd.L1.Cardinality != pref.Repeated && (fd.L0.ParentFile.L1.Syntax == pref.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
|
||||
}
|
||||
@@ -373,7 +366,7 @@ type (
|
||||
}
|
||||
ExtensionL2 struct {
|
||||
Options func() pref.ProtoMessage
|
||||
JSONName jsonName
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
@@ -391,8 +384,9 @@ func (xd *Extension) Options() pref.ProtoMessage {
|
||||
func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
|
||||
func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
|
||||
func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().JSONName.has }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().JSONName.get(xd) }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().StringName.hasJSON }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().StringName.getJSON(xd) }
|
||||
func (xd *Extension) TextName() string { return xd.lazyInit().StringName.getText(xd) }
|
||||
func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != pref.Repeated }
|
||||
func (xd *Extension) HasOptionalKeyword() bool {
|
||||
return (xd.L0.ParentFile.L1.Syntax == pref.Proto2 && xd.L1.Cardinality == pref.Optional) || xd.lazyInit().IsProto3Optional
|
||||
@@ -506,27 +500,50 @@ func (d *Base) Syntax() pref.Syntax { return d.L0.ParentFile.Syn
|
||||
func (d *Base) IsPlaceholder() bool { return false }
|
||||
func (d *Base) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
type jsonName struct {
|
||||
has bool
|
||||
once sync.Once
|
||||
name string
|
||||
type stringName struct {
|
||||
hasJSON bool
|
||||
once sync.Once
|
||||
nameJSON string
|
||||
nameText string
|
||||
}
|
||||
|
||||
// Init initializes the name. It is exported for use by other internal packages.
|
||||
func (js *jsonName) Init(s string) {
|
||||
js.has = true
|
||||
js.name = s
|
||||
// InitJSON initializes the name. It is exported for use by other internal packages.
|
||||
func (s *stringName) InitJSON(name string) {
|
||||
s.hasJSON = true
|
||||
s.nameJSON = name
|
||||
}
|
||||
|
||||
func (js *jsonName) get(fd pref.FieldDescriptor) string {
|
||||
if !js.has {
|
||||
js.once.Do(func() {
|
||||
js.name = strs.JSONCamelCase(string(fd.Name()))
|
||||
})
|
||||
}
|
||||
return js.name
|
||||
func (s *stringName) lazyInit(fd pref.FieldDescriptor) *stringName {
|
||||
s.once.Do(func() {
|
||||
if fd.IsExtension() {
|
||||
// For extensions, JSON and text are formatted the same way.
|
||||
var name string
|
||||
if messageset.IsMessageSetExtension(fd) {
|
||||
name = string("[" + fd.FullName().Parent() + "]")
|
||||
} else {
|
||||
name = string("[" + fd.FullName() + "]")
|
||||
}
|
||||
s.nameJSON = name
|
||||
s.nameText = name
|
||||
} else {
|
||||
// Format the JSON name.
|
||||
if !s.hasJSON {
|
||||
s.nameJSON = strs.JSONCamelCase(string(fd.Name()))
|
||||
}
|
||||
|
||||
// Format the text name.
|
||||
s.nameText = string(fd.Name())
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
s.nameText = string(fd.Message().Name())
|
||||
}
|
||||
}
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *stringName) getJSON(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameJSON }
|
||||
func (s *stringName) getText(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameText }
|
||||
|
||||
func DefaultValue(v pref.Value, ev pref.EnumValueDescriptor) defaultValue {
|
||||
dv := defaultValue{has: v.IsValid(), val: v, enum: ev}
|
||||
if b, ok := v.Interface().([]byte); ok {
|
||||
|
4
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
4
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
@@ -451,7 +451,7 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||
case genid.FieldDescriptorProto_Name_field_number:
|
||||
fd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
fd.L1.JSONName.Init(sb.MakeString(v))
|
||||
fd.L1.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
@@ -551,7 +551,7 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
xd.L2.JSONName.Init(sb.MakeString(v))
|
||||
xd.L2.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
|
172
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
172
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
@@ -6,9 +6,12 @@ package filedesc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/descfmt"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
@@ -245,6 +248,7 @@ type OneofFields struct {
|
||||
once sync.Once
|
||||
byName map[pref.Name]pref.FieldDescriptor // protected by once
|
||||
byJSON map[string]pref.FieldDescriptor // protected by once
|
||||
byText map[string]pref.FieldDescriptor // protected by once
|
||||
byNum map[pref.FieldNumber]pref.FieldDescriptor // protected by once
|
||||
}
|
||||
|
||||
@@ -252,6 +256,7 @@ func (p *OneofFields) Len() int { return
|
||||
func (p *OneofFields) Get(i int) pref.FieldDescriptor { return p.List[i] }
|
||||
func (p *OneofFields) ByName(s pref.Name) pref.FieldDescriptor { return p.lazyInit().byName[s] }
|
||||
func (p *OneofFields) ByJSONName(s string) pref.FieldDescriptor { return p.lazyInit().byJSON[s] }
|
||||
func (p *OneofFields) ByTextName(s string) pref.FieldDescriptor { return p.lazyInit().byText[s] }
|
||||
func (p *OneofFields) ByNumber(n pref.FieldNumber) pref.FieldDescriptor { return p.lazyInit().byNum[n] }
|
||||
func (p *OneofFields) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||
func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
|
||||
@@ -261,11 +266,13 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||
if len(p.List) > 0 {
|
||||
p.byName = make(map[pref.Name]pref.FieldDescriptor, len(p.List))
|
||||
p.byJSON = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byText = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byNum = make(map[pref.FieldNumber]pref.FieldDescriptor, len(p.List))
|
||||
for _, f := range p.List {
|
||||
// Field names and numbers are guaranteed to be unique.
|
||||
p.byName[f.Name()] = f
|
||||
p.byJSON[f.JSONName()] = f
|
||||
p.byText[f.TextName()] = f
|
||||
p.byNum[f.Number()] = f
|
||||
}
|
||||
}
|
||||
@@ -274,9 +281,170 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||
}
|
||||
|
||||
type SourceLocations struct {
|
||||
// List is a list of SourceLocations.
|
||||
// The SourceLocation.Next field does not need to be populated
|
||||
// as it will be lazily populated upon first need.
|
||||
List []pref.SourceLocation
|
||||
|
||||
// File is the parent file descriptor that these locations are relative to.
|
||||
// If non-nil, ByDescriptor verifies that the provided descriptor
|
||||
// is a child of this file descriptor.
|
||||
File pref.FileDescriptor
|
||||
|
||||
once sync.Once
|
||||
byPath map[pathKey]int
|
||||
}
|
||||
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.List[i] }
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.lazyInit().List[i] }
|
||||
func (p *SourceLocations) byKey(k pathKey) pref.SourceLocation {
|
||||
if i, ok := p.lazyInit().byPath[k]; ok {
|
||||
return p.List[i]
|
||||
}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
func (p *SourceLocations) ByPath(path pref.SourcePath) pref.SourceLocation {
|
||||
return p.byKey(newPathKey(path))
|
||||
}
|
||||
func (p *SourceLocations) ByDescriptor(desc pref.Descriptor) pref.SourceLocation {
|
||||
if p.File != nil && desc != nil && p.File != desc.ParentFile() {
|
||||
return pref.SourceLocation{} // mismatching parent files
|
||||
}
|
||||
var pathArr [16]int32
|
||||
path := pathArr[:0]
|
||||
for {
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
// Reverse the path since it was constructed in reverse.
|
||||
for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 {
|
||||
path[i], path[j] = path[j], path[i]
|
||||
}
|
||||
return p.byKey(newPathKey(path))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_MessageType_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_NestedType_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.FieldDescriptor:
|
||||
isExtension := desc.(pref.FieldDescriptor).IsExtension()
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
if isExtension {
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Extension_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Extension_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
} else {
|
||||
switch desc.(type) {
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Field_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
case pref.OneofDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_OneofDecl_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_EnumType_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_EnumType_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.EnumValueDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(genid.EnumDescriptorProto_Value_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Service_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.MethodDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(genid.ServiceDescriptorProto_Method_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
}
|
||||
func (p *SourceLocations) lazyInit() *SourceLocations {
|
||||
p.once.Do(func() {
|
||||
if len(p.List) > 0 {
|
||||
// Collect all the indexes for a given path.
|
||||
pathIdxs := make(map[pathKey][]int, len(p.List))
|
||||
for i, l := range p.List {
|
||||
k := newPathKey(l.Path)
|
||||
pathIdxs[k] = append(pathIdxs[k], i)
|
||||
}
|
||||
|
||||
// Update the next index for all locations.
|
||||
p.byPath = make(map[pathKey]int, len(p.List))
|
||||
for k, idxs := range pathIdxs {
|
||||
for i := 0; i < len(idxs)-1; i++ {
|
||||
p.List[idxs[i]].Next = idxs[i+1]
|
||||
}
|
||||
p.List[idxs[len(idxs)-1]].Next = 0
|
||||
p.byPath[k] = idxs[0] // record the first location for this path
|
||||
}
|
||||
}
|
||||
})
|
||||
return p
|
||||
}
|
||||
func (p *SourceLocations) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
// pathKey is a comparable representation of protoreflect.SourcePath.
|
||||
type pathKey struct {
|
||||
arr [16]uint8 // first n-1 path segments; last element is the length
|
||||
str string // used if the path does not fit in arr
|
||||
}
|
||||
|
||||
func newPathKey(p pref.SourcePath) (k pathKey) {
|
||||
if len(p) < len(k.arr) {
|
||||
for i, ps := range p {
|
||||
if ps < 0 || math.MaxUint8 <= ps {
|
||||
return pathKey{str: p.String()}
|
||||
}
|
||||
k.arr[i] = uint8(ps)
|
||||
}
|
||||
k.arr[len(k.arr)-1] = uint8(len(p))
|
||||
return k
|
||||
}
|
||||
return pathKey{str: p.String()}
|
||||
}
|
||||
|
11
vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go
generated
vendored
11
vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go
generated
vendored
@@ -142,6 +142,7 @@ type Fields struct {
|
||||
once sync.Once
|
||||
byName map[protoreflect.Name]*Field // protected by once
|
||||
byJSON map[string]*Field // protected by once
|
||||
byText map[string]*Field // protected by once
|
||||
byNum map[protoreflect.FieldNumber]*Field // protected by once
|
||||
}
|
||||
|
||||
@@ -163,6 +164,12 @@ func (p *Fields) ByJSONName(s string) protoreflect.FieldDescriptor {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (p *Fields) ByTextName(s string) protoreflect.FieldDescriptor {
|
||||
if d := p.lazyInit().byText[s]; d != nil {
|
||||
return d
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (p *Fields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
|
||||
if d := p.lazyInit().byNum[n]; d != nil {
|
||||
return d
|
||||
@@ -178,6 +185,7 @@ func (p *Fields) lazyInit() *Fields {
|
||||
if len(p.List) > 0 {
|
||||
p.byName = make(map[protoreflect.Name]*Field, len(p.List))
|
||||
p.byJSON = make(map[string]*Field, len(p.List))
|
||||
p.byText = make(map[string]*Field, len(p.List))
|
||||
p.byNum = make(map[protoreflect.FieldNumber]*Field, len(p.List))
|
||||
for i := range p.List {
|
||||
d := &p.List[i]
|
||||
@@ -187,6 +195,9 @@ func (p *Fields) lazyInit() *Fields {
|
||||
if _, ok := p.byJSON[d.JSONName()]; !ok {
|
||||
p.byJSON[d.JSONName()] = d
|
||||
}
|
||||
if _, ok := p.byText[d.TextName()]; !ok {
|
||||
p.byText[d.TextName()] = d
|
||||
}
|
||||
if _, ok := p.byNum[d.Number()]; !ok {
|
||||
p.byNum[d.Number()] = d
|
||||
}
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
@@ -167,7 +167,7 @@ func (Export) MessageTypeOf(m message) pref.MessageType {
|
||||
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
||||
return mv.ProtoReflect().Type()
|
||||
}
|
||||
return legacyLoadMessageInfo(reflect.TypeOf(m), "")
|
||||
return legacyLoadMessageType(reflect.TypeOf(m), "")
|
||||
}
|
||||
|
||||
// MessageStringOf returns the message value as a string,
|
||||
|
18
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
18
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
@@ -10,6 +10,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
@@ -20,6 +21,7 @@ type errInvalidUTF8 struct{}
|
||||
|
||||
func (errInvalidUTF8) Error() string { return "string field contains invalid UTF-8" }
|
||||
func (errInvalidUTF8) InvalidUTF8() bool { return true }
|
||||
func (errInvalidUTF8) Unwrap() error { return errors.Error }
|
||||
|
||||
// initOneofFieldCoders initializes the fast-path functions for the fields in a oneof.
|
||||
//
|
||||
@@ -242,7 +244,7 @@ func consumeMessageInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFieldI
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if p.Elem().IsNil() {
|
||||
p.SetPointer(pointerOfValue(reflect.New(f.mi.GoReflectType.Elem())))
|
||||
@@ -276,7 +278,7 @@ func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarsh
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: v,
|
||||
@@ -420,7 +422,7 @@ func consumeGroup(b []byte, m proto.Message, num protowire.Number, wtyp protowir
|
||||
}
|
||||
b, n := protowire.ConsumeGroup(num, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: b,
|
||||
@@ -494,7 +496,7 @@ func consumeMessageSliceInfo(b []byte, p pointer, wtyp protowire.Type, f *coderF
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
m := reflect.New(f.mi.GoReflectType.Elem()).Interface()
|
||||
mp := pointerOfIface(m)
|
||||
@@ -550,7 +552,7 @@ func consumeMessageSlice(b []byte, p pointer, goType reflect.Type, wtyp protowir
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
mp := reflect.New(goType.Elem())
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
@@ -613,7 +615,7 @@ func consumeMessageSliceValue(b []byte, listv pref.Value, _ protowire.Number, wt
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return pref.Value{}, out, protowire.ParseError(n)
|
||||
return pref.Value{}, out, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
@@ -681,7 +683,7 @@ func consumeGroupSliceValue(b []byte, listv pref.Value, num protowire.Number, wt
|
||||
}
|
||||
b, n := protowire.ConsumeGroup(num, b)
|
||||
if n < 0 {
|
||||
return pref.Value{}, out, protowire.ParseError(n)
|
||||
return pref.Value{}, out, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
@@ -767,7 +769,7 @@ func consumeGroupSlice(b []byte, p pointer, num protowire.Number, wtyp protowire
|
||||
}
|
||||
b, n := protowire.ConsumeGroup(num, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
mp := reflect.New(goType.Elem())
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
|
974
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
974
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
File diff suppressed because it is too large
Load Diff
19
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
19
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
@@ -5,7 +5,6 @@
|
||||
package impl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"sort"
|
||||
|
||||
@@ -118,7 +117,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
}
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
var (
|
||||
key = mapi.keyZero
|
||||
@@ -127,10 +126,10 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
for len(b) > 0 {
|
||||
num, wtyp, n := protowire.ConsumeTag(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if num > protowire.MaxValidNumber {
|
||||
return out, errors.New("invalid field number")
|
||||
return out, errDecode
|
||||
}
|
||||
b = b[n:]
|
||||
err := errUnknown
|
||||
@@ -157,7 +156,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
if err == errUnknown {
|
||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
} else if err != nil {
|
||||
return out, err
|
||||
@@ -175,7 +174,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
}
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
var (
|
||||
key = mapi.keyZero
|
||||
@@ -184,10 +183,10 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
for len(b) > 0 {
|
||||
num, wtyp, n := protowire.ConsumeTag(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if num > protowire.MaxValidNumber {
|
||||
return out, errors.New("invalid field number")
|
||||
return out, errDecode
|
||||
}
|
||||
b = b[n:]
|
||||
err := errUnknown
|
||||
@@ -208,7 +207,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
var v []byte
|
||||
v, n = protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
var o unmarshalOutput
|
||||
o, err = f.mi.unmarshalPointer(v, pointerOfValue(val), 0, opts)
|
||||
@@ -221,7 +220,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
if err == errUnknown {
|
||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
} else if err != nil {
|
||||
return out, err
|
||||
|
68
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
68
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/fieldsort"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
@@ -27,6 +27,7 @@ type coderMessageInfo struct {
|
||||
coderFields map[protowire.Number]*coderFieldInfo
|
||||
sizecacheOffset offset
|
||||
unknownOffset offset
|
||||
unknownPtrKind bool
|
||||
extensionOffset offset
|
||||
needsInitCheck bool
|
||||
isMessageSet bool
|
||||
@@ -47,9 +48,20 @@ type coderFieldInfo struct {
|
||||
}
|
||||
|
||||
func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
mi.sizecacheOffset = si.sizecacheOffset
|
||||
mi.unknownOffset = si.unknownOffset
|
||||
mi.extensionOffset = si.extensionOffset
|
||||
mi.sizecacheOffset = invalidOffset
|
||||
mi.unknownOffset = invalidOffset
|
||||
mi.extensionOffset = invalidOffset
|
||||
|
||||
if si.sizecacheOffset.IsValid() && si.sizecacheType == sizecacheType {
|
||||
mi.sizecacheOffset = si.sizecacheOffset
|
||||
}
|
||||
if si.unknownOffset.IsValid() && (si.unknownType == unknownFieldsAType || si.unknownType == unknownFieldsBType) {
|
||||
mi.unknownOffset = si.unknownOffset
|
||||
mi.unknownPtrKind = si.unknownType.Kind() == reflect.Ptr
|
||||
}
|
||||
if si.extensionOffset.IsValid() && si.extensionType == extensionFieldsType {
|
||||
mi.extensionOffset = si.extensionOffset
|
||||
}
|
||||
|
||||
mi.coderFields = make(map[protowire.Number]*coderFieldInfo)
|
||||
fields := mi.Desc.Fields()
|
||||
@@ -73,6 +85,27 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
var funcs pointerCoderFuncs
|
||||
var childMessage *MessageInfo
|
||||
switch {
|
||||
case ft == nil:
|
||||
// This never occurs for generated message types.
|
||||
// It implies that a hand-crafted type has missing Go fields
|
||||
// for specific protobuf message fields.
|
||||
funcs = pointerCoderFuncs{
|
||||
size: func(p pointer, f *coderFieldInfo, opts marshalOptions) int {
|
||||
return 0
|
||||
},
|
||||
marshal: func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
return nil, nil
|
||||
},
|
||||
unmarshal: func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
isInit: func(p pointer, f *coderFieldInfo) error {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
merge: func(dst, src pointer, f *coderFieldInfo, opts mergeOptions) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
}
|
||||
case isOneof:
|
||||
fieldOffset = offsetOf(fs, mi.Exporter)
|
||||
case fd.IsWeak():
|
||||
@@ -136,7 +169,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
sort.Slice(mi.orderedCoderFields, func(i, j int) bool {
|
||||
fi := fields.ByNumber(mi.orderedCoderFields[i].num)
|
||||
fj := fields.ByNumber(mi.orderedCoderFields[j].num)
|
||||
return fieldsort.Less(fi, fj)
|
||||
return order.LegacyFieldOrder(fi, fj)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -157,3 +190,28 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
mi.methods.Merge = mi.merge
|
||||
}
|
||||
}
|
||||
|
||||
// getUnknownBytes returns a *[]byte for the unknown fields.
|
||||
// It is the caller's responsibility to check whether the pointer is nil.
|
||||
// This function is specially designed to be inlineable.
|
||||
func (mi *MessageInfo) getUnknownBytes(p pointer) *[]byte {
|
||||
if mi.unknownPtrKind {
|
||||
return *p.Apply(mi.unknownOffset).BytesPtr()
|
||||
} else {
|
||||
return p.Apply(mi.unknownOffset).Bytes()
|
||||
}
|
||||
}
|
||||
|
||||
// mutableUnknownBytes returns a *[]byte for the unknown fields.
|
||||
// The returned pointer is guaranteed to not be nil.
|
||||
func (mi *MessageInfo) mutableUnknownBytes(p pointer) *[]byte {
|
||||
if mi.unknownPtrKind {
|
||||
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||
if *bp == nil {
|
||||
*bp = new([]byte)
|
||||
}
|
||||
return *bp
|
||||
} else {
|
||||
return p.Apply(mi.unknownOffset).Bytes()
|
||||
}
|
||||
}
|
||||
|
21
vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
generated
vendored
21
vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
generated
vendored
@@ -29,8 +29,9 @@ func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int)
|
||||
size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts)
|
||||
}
|
||||
|
||||
unknown := *p.Apply(mi.unknownOffset).Bytes()
|
||||
size += messageset.SizeUnknown(unknown)
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
size += messageset.SizeUnknown(*u)
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
@@ -69,10 +70,12 @@ func marshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts marshalOptions
|
||||
}
|
||||
}
|
||||
|
||||
unknown := *p.Apply(mi.unknownOffset).Bytes()
|
||||
b, err := messageset.AppendUnknown(b, unknown)
|
||||
if err != nil {
|
||||
return b, err
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
var err error
|
||||
b, err = messageset.AppendUnknown(b, *u)
|
||||
if err != nil {
|
||||
return b, err
|
||||
}
|
||||
}
|
||||
|
||||
return b, nil
|
||||
@@ -100,13 +103,13 @@ func unmarshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts unmarshalOpt
|
||||
*ep = make(map[int32]ExtensionField)
|
||||
}
|
||||
ext := *ep
|
||||
unknown := p.Apply(mi.unknownOffset).Bytes()
|
||||
initialized := true
|
||||
err = messageset.Unmarshal(b, true, func(num protowire.Number, v []byte) error {
|
||||
o, err := mi.unmarshalExtension(v, num, protowire.BytesType, ext, opts)
|
||||
if err == errUnknown {
|
||||
*unknown = protowire.AppendTag(*unknown, num, protowire.BytesType)
|
||||
*unknown = append(*unknown, v...)
|
||||
u := mi.mutableUnknownBytes(p)
|
||||
*u = protowire.AppendTag(*u, num, protowire.BytesType)
|
||||
*u = append(*u, v...)
|
||||
return nil
|
||||
}
|
||||
if !o.initialized {
|
||||
|
8
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
@@ -30,7 +30,7 @@ func consumeEnum(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
p.v.Elem().SetInt(int64(v))
|
||||
out.n = n
|
||||
@@ -130,12 +130,12 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf
|
||||
if wtyp == protowire.BytesType {
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
rv := reflect.New(s.Type().Elem()).Elem()
|
||||
rv.SetInt(int64(v))
|
||||
@@ -150,7 +150,7 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
rv := reflect.New(s.Type().Elem()).Elem()
|
||||
rv.SetInt(int64(v))
|
||||
|
29
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
29
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
@@ -423,6 +423,13 @@ func (c *messageConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
if v.CanAddr() {
|
||||
v = v.Addr() // T => *T
|
||||
} else {
|
||||
v = reflect.Zero(reflect.PtrTo(v.Type()))
|
||||
}
|
||||
}
|
||||
if m, ok := v.Interface().(pref.ProtoMessage); ok {
|
||||
return pref.ValueOfMessage(m.ProtoReflect())
|
||||
}
|
||||
@@ -437,6 +444,16 @@ func (c *messageConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
} else {
|
||||
rv = reflect.ValueOf(m.Interface())
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
if rv.Type() != reflect.PtrTo(c.goType) {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), reflect.PtrTo(c.goType)))
|
||||
}
|
||||
if !rv.IsNil() {
|
||||
rv = rv.Elem() // *T => T
|
||||
} else {
|
||||
rv = reflect.Zero(rv.Type().Elem())
|
||||
}
|
||||
}
|
||||
if rv.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), c.goType))
|
||||
}
|
||||
@@ -451,6 +468,9 @@ func (c *messageConverter) IsValidPB(v pref.Value) bool {
|
||||
} else {
|
||||
rv = reflect.ValueOf(m.Interface())
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
return rv.Type() == reflect.PtrTo(c.goType)
|
||||
}
|
||||
return rv.Type() == c.goType
|
||||
}
|
||||
|
||||
@@ -459,9 +479,18 @@ func (c *messageConverter) IsValidGo(v reflect.Value) bool {
|
||||
}
|
||||
|
||||
func (c *messageConverter) New() pref.Value {
|
||||
if c.isNonPointer() {
|
||||
return c.PBValueOf(reflect.New(c.goType).Elem())
|
||||
}
|
||||
return c.PBValueOf(reflect.New(c.goType.Elem()))
|
||||
}
|
||||
|
||||
func (c *messageConverter) Zero() pref.Value {
|
||||
return c.PBValueOf(reflect.Zero(c.goType))
|
||||
}
|
||||
|
||||
// isNonPointer reports whether the type is a non-pointer type.
|
||||
// This never occurs for generated message types.
|
||||
func (c *messageConverter) isNonPointer() bool {
|
||||
return c.goType.Kind() != reflect.Ptr
|
||||
}
|
||||
|
16
vendor/google.golang.org/protobuf/internal/impl/decode.go
generated
vendored
16
vendor/google.golang.org/protobuf/internal/impl/decode.go
generated
vendored
@@ -17,6 +17,8 @@ import (
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
var errDecode = errors.New("cannot parse invalid wire-format data")
|
||||
|
||||
type unmarshalOptions struct {
|
||||
flags protoiface.UnmarshalInputFlags
|
||||
resolver interface {
|
||||
@@ -100,13 +102,13 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
var n int
|
||||
tag, n = protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
b = b[n:]
|
||||
}
|
||||
var num protowire.Number
|
||||
if n := tag >> 3; n < uint64(protowire.MinValidNumber) || n > uint64(protowire.MaxValidNumber) {
|
||||
return out, errors.New("invalid field number")
|
||||
return out, errDecode
|
||||
} else {
|
||||
num = protowire.Number(n)
|
||||
}
|
||||
@@ -114,7 +116,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
|
||||
if wtyp == protowire.EndGroupType {
|
||||
if num != groupTag {
|
||||
return out, errors.New("mismatching end group marker")
|
||||
return out, errDecode
|
||||
}
|
||||
groupTag = 0
|
||||
break
|
||||
@@ -170,10 +172,10 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
}
|
||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if !opts.DiscardUnknown() && mi.unknownOffset.IsValid() {
|
||||
u := p.Apply(mi.unknownOffset).Bytes()
|
||||
u := mi.mutableUnknownBytes(p)
|
||||
*u = protowire.AppendTag(*u, num, wtyp)
|
||||
*u = append(*u, b[:n]...)
|
||||
}
|
||||
@@ -181,7 +183,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
b = b[n:]
|
||||
}
|
||||
if groupTag != 0 {
|
||||
return out, errors.New("missing end group marker")
|
||||
return out, errDecode
|
||||
}
|
||||
if mi.numRequiredFields > 0 && bits.OnesCount64(requiredMask) != int(mi.numRequiredFields) {
|
||||
initialized = false
|
||||
@@ -221,7 +223,7 @@ func (mi *MessageInfo) unmarshalExtension(b []byte, num protowire.Number, wtyp p
|
||||
return out, nil
|
||||
}
|
||||
case ValidationInvalid:
|
||||
return out, errors.New("invalid wire format")
|
||||
return out, errDecode
|
||||
case ValidationUnknown:
|
||||
}
|
||||
}
|
||||
|
10
vendor/google.golang.org/protobuf/internal/impl/encode.go
generated
vendored
10
vendor/google.golang.org/protobuf/internal/impl/encode.go
generated
vendored
@@ -79,8 +79,9 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int
|
||||
size += f.funcs.size(fptr, f, opts)
|
||||
}
|
||||
if mi.unknownOffset.IsValid() {
|
||||
u := *p.Apply(mi.unknownOffset).Bytes()
|
||||
size += len(u)
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
size += len(*u)
|
||||
}
|
||||
}
|
||||
if mi.sizecacheOffset.IsValid() {
|
||||
if size > math.MaxInt32 {
|
||||
@@ -141,8 +142,9 @@ func (mi *MessageInfo) marshalAppendPointer(b []byte, p pointer, opts marshalOpt
|
||||
}
|
||||
}
|
||||
if mi.unknownOffset.IsValid() && !mi.isMessageSet {
|
||||
u := *p.Apply(mi.unknownOffset).Bytes()
|
||||
b = append(b, u...)
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
b = append(b, (*u)...)
|
||||
}
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
@@ -30,7 +30,7 @@ func (Export) LegacyMessageTypeOf(m piface.MessageV1, name pref.FullName) pref.M
|
||||
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
||||
return mv.ProtoReflect().Type()
|
||||
}
|
||||
return legacyLoadMessageInfo(reflect.TypeOf(m), name)
|
||||
return legacyLoadMessageType(reflect.TypeOf(m), name)
|
||||
}
|
||||
|
||||
// UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input.
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
@@ -154,7 +154,8 @@ func (x placeholderExtension) Number() pref.FieldNumber { retu
|
||||
func (x placeholderExtension) Cardinality() pref.Cardinality { return 0 }
|
||||
func (x placeholderExtension) Kind() pref.Kind { return 0 }
|
||||
func (x placeholderExtension) HasJSONName() bool { return false }
|
||||
func (x placeholderExtension) JSONName() string { return "" }
|
||||
func (x placeholderExtension) JSONName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) TextName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) HasPresence() bool { return false }
|
||||
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
||||
func (x placeholderExtension) IsExtension() bool { return true }
|
||||
|
122
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
122
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
@@ -24,14 +24,24 @@ import (
|
||||
// legacyWrapMessage wraps v as a protoreflect.Message,
|
||||
// where v must be a *struct kind and not implement the v2 API already.
|
||||
func legacyWrapMessage(v reflect.Value) pref.Message {
|
||||
typ := v.Type()
|
||||
if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct {
|
||||
t := v.Type()
|
||||
if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
|
||||
return aberrantMessage{v: v}
|
||||
}
|
||||
mt := legacyLoadMessageInfo(typ, "")
|
||||
mt := legacyLoadMessageInfo(t, "")
|
||||
return mt.MessageOf(v.Interface())
|
||||
}
|
||||
|
||||
// legacyLoadMessageType dynamically loads a protoreflect.Type for t,
|
||||
// where t must be not implement the v2 API already.
|
||||
// The provided name is used if it cannot be determined from the message.
|
||||
func legacyLoadMessageType(t reflect.Type, name pref.FullName) protoreflect.MessageType {
|
||||
if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
|
||||
return aberrantMessageType{t}
|
||||
}
|
||||
return legacyLoadMessageInfo(t, name)
|
||||
}
|
||||
|
||||
var legacyMessageTypeCache sync.Map // map[reflect.Type]*MessageInfo
|
||||
|
||||
// legacyLoadMessageInfo dynamically loads a *MessageInfo for t,
|
||||
@@ -49,8 +59,9 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||
GoReflectType: t,
|
||||
}
|
||||
|
||||
var hasMarshal, hasUnmarshal bool
|
||||
v := reflect.Zero(t).Interface()
|
||||
if _, ok := v.(legacyMarshaler); ok {
|
||||
if _, hasMarshal = v.(legacyMarshaler); hasMarshal {
|
||||
mi.methods.Marshal = legacyMarshal
|
||||
|
||||
// We have no way to tell whether the type's Marshal method
|
||||
@@ -59,10 +70,10 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||
// calling Marshal methods when present.
|
||||
mi.methods.Flags |= piface.SupportMarshalDeterministic
|
||||
}
|
||||
if _, ok := v.(legacyUnmarshaler); ok {
|
||||
if _, hasUnmarshal = v.(legacyUnmarshaler); hasUnmarshal {
|
||||
mi.methods.Unmarshal = legacyUnmarshal
|
||||
}
|
||||
if _, ok := v.(legacyMerger); ok {
|
||||
if _, hasMerge := v.(legacyMerger); hasMerge || (hasMarshal && hasUnmarshal) {
|
||||
mi.methods.Merge = legacyMerge
|
||||
}
|
||||
|
||||
@@ -75,7 +86,7 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||
var legacyMessageDescCache sync.Map // map[reflect.Type]protoreflect.MessageDescriptor
|
||||
|
||||
// LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type,
|
||||
// which must be a *struct kind and not implement the v2 API already.
|
||||
// which should be a *struct kind and must not implement the v2 API already.
|
||||
//
|
||||
// This is exported for testing purposes.
|
||||
func LegacyLoadMessageDesc(t reflect.Type) pref.MessageDescriptor {
|
||||
@@ -114,17 +125,19 @@ func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescr
|
||||
// If the Go type has no fields, then this might be a proto3 empty message
|
||||
// from before the size cache was added. If there are any fields, check to
|
||||
// see that at least one of them looks like something we generated.
|
||||
if nfield := t.Elem().NumField(); nfield > 0 {
|
||||
hasProtoField := false
|
||||
for i := 0; i < nfield; i++ {
|
||||
f := t.Elem().Field(i)
|
||||
if f.Tag.Get("protobuf") != "" || f.Tag.Get("protobuf_oneof") != "" || strings.HasPrefix(f.Name, "XXX_") {
|
||||
hasProtoField = true
|
||||
break
|
||||
if t.Elem().Kind() == reflect.Struct {
|
||||
if nfield := t.Elem().NumField(); nfield > 0 {
|
||||
hasProtoField := false
|
||||
for i := 0; i < nfield; i++ {
|
||||
f := t.Elem().Field(i)
|
||||
if f.Tag.Get("protobuf") != "" || f.Tag.Get("protobuf_oneof") != "" || strings.HasPrefix(f.Name, "XXX_") {
|
||||
hasProtoField = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasProtoField {
|
||||
return aberrantLoadMessageDesc(t, name)
|
||||
}
|
||||
}
|
||||
if !hasProtoField {
|
||||
return aberrantLoadMessageDesc(t, name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,7 +383,7 @@ type legacyMerger interface {
|
||||
Merge(protoiface.MessageV1)
|
||||
}
|
||||
|
||||
var legacyProtoMethods = &piface.Methods{
|
||||
var aberrantProtoMethods = &piface.Methods{
|
||||
Marshal: legacyMarshal,
|
||||
Unmarshal: legacyUnmarshal,
|
||||
Merge: legacyMerge,
|
||||
@@ -401,18 +414,40 @@ func legacyUnmarshal(in piface.UnmarshalInput) (piface.UnmarshalOutput, error) {
|
||||
v := in.Message.(unwrapper).protoUnwrap()
|
||||
unmarshaler, ok := v.(legacyUnmarshaler)
|
||||
if !ok {
|
||||
return piface.UnmarshalOutput{}, errors.New("%T does not implement Marshal", v)
|
||||
return piface.UnmarshalOutput{}, errors.New("%T does not implement Unmarshal", v)
|
||||
}
|
||||
return piface.UnmarshalOutput{}, unmarshaler.Unmarshal(in.Buf)
|
||||
}
|
||||
|
||||
func legacyMerge(in piface.MergeInput) piface.MergeOutput {
|
||||
// Check whether this supports the legacy merger.
|
||||
dstv := in.Destination.(unwrapper).protoUnwrap()
|
||||
merger, ok := dstv.(legacyMerger)
|
||||
if ok {
|
||||
merger.Merge(Export{}.ProtoMessageV1Of(in.Source))
|
||||
return piface.MergeOutput{Flags: piface.MergeComplete}
|
||||
}
|
||||
|
||||
// If legacy merger is unavailable, implement merge in terms of
|
||||
// a marshal and unmarshal operation.
|
||||
srcv := in.Source.(unwrapper).protoUnwrap()
|
||||
marshaler, ok := srcv.(legacyMarshaler)
|
||||
if !ok {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
merger.Merge(Export{}.ProtoMessageV1Of(in.Source))
|
||||
dstv = in.Destination.(unwrapper).protoUnwrap()
|
||||
unmarshaler, ok := dstv.(legacyUnmarshaler)
|
||||
if !ok {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
b, err := marshaler.Marshal()
|
||||
if err != nil {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
err = unmarshaler.Unmarshal(b)
|
||||
if err != nil {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
return piface.MergeOutput{Flags: piface.MergeComplete}
|
||||
}
|
||||
|
||||
@@ -422,6 +457,9 @@ type aberrantMessageType struct {
|
||||
}
|
||||
|
||||
func (mt aberrantMessageType) New() pref.Message {
|
||||
if mt.t.Kind() == reflect.Ptr {
|
||||
return aberrantMessage{reflect.New(mt.t.Elem())}
|
||||
}
|
||||
return aberrantMessage{reflect.Zero(mt.t)}
|
||||
}
|
||||
func (mt aberrantMessageType) Zero() pref.Message {
|
||||
@@ -443,6 +481,17 @@ type aberrantMessage struct {
|
||||
v reflect.Value
|
||||
}
|
||||
|
||||
// Reset implements the v1 proto.Message.Reset method.
|
||||
func (m aberrantMessage) Reset() {
|
||||
if mr, ok := m.v.Interface().(interface{ Reset() }); ok {
|
||||
mr.Reset()
|
||||
return
|
||||
}
|
||||
if m.v.Kind() == reflect.Ptr && !m.v.IsNil() {
|
||||
m.v.Elem().Set(reflect.Zero(m.v.Type().Elem()))
|
||||
}
|
||||
}
|
||||
|
||||
func (m aberrantMessage) ProtoReflect() pref.Message {
|
||||
return m
|
||||
}
|
||||
@@ -454,33 +503,40 @@ func (m aberrantMessage) Type() pref.MessageType {
|
||||
return aberrantMessageType{m.v.Type()}
|
||||
}
|
||||
func (m aberrantMessage) New() pref.Message {
|
||||
if m.v.Type().Kind() == reflect.Ptr {
|
||||
return aberrantMessage{reflect.New(m.v.Type().Elem())}
|
||||
}
|
||||
return aberrantMessage{reflect.Zero(m.v.Type())}
|
||||
}
|
||||
func (m aberrantMessage) Interface() pref.ProtoMessage {
|
||||
return m
|
||||
}
|
||||
func (m aberrantMessage) Range(f func(pref.FieldDescriptor, pref.Value) bool) {
|
||||
return
|
||||
}
|
||||
func (m aberrantMessage) Has(pref.FieldDescriptor) bool {
|
||||
panic("invalid field descriptor")
|
||||
return false
|
||||
}
|
||||
func (m aberrantMessage) Clear(pref.FieldDescriptor) {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.Clear on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) Get(pref.FieldDescriptor) pref.Value {
|
||||
panic("invalid field descriptor")
|
||||
func (m aberrantMessage) Get(fd pref.FieldDescriptor) pref.Value {
|
||||
if fd.Default().IsValid() {
|
||||
return fd.Default()
|
||||
}
|
||||
panic("invalid Message.Get on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) Set(pref.FieldDescriptor, pref.Value) {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.Set on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) Mutable(pref.FieldDescriptor) pref.Value {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.Mutable on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) NewField(pref.FieldDescriptor) pref.Value {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.NewField on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) WhichOneof(pref.OneofDescriptor) pref.FieldDescriptor {
|
||||
panic("invalid oneof descriptor")
|
||||
panic("invalid Message.WhichOneof descriptor on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) GetUnknown() pref.RawFields {
|
||||
return nil
|
||||
@@ -489,13 +545,13 @@ func (m aberrantMessage) SetUnknown(pref.RawFields) {
|
||||
// SetUnknown discards its input on messages which don't support unknown field storage.
|
||||
}
|
||||
func (m aberrantMessage) IsValid() bool {
|
||||
// An invalid message is a read-only, empty message. Since we don't know anything
|
||||
// about the alleged contents of this message, we can't say with confidence that
|
||||
// it is invalid in this sense. Therefore, report it as valid.
|
||||
return true
|
||||
if m.v.Kind() == reflect.Ptr {
|
||||
return !m.v.IsNil()
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (m aberrantMessage) ProtoMethods() *piface.Methods {
|
||||
return legacyProtoMethods
|
||||
return aberrantProtoMethods
|
||||
}
|
||||
func (m aberrantMessage) protoUnwrap() interface{} {
|
||||
return m.v.Interface()
|
||||
|
6
vendor/google.golang.org/protobuf/internal/impl/merge.go
generated
vendored
6
vendor/google.golang.org/protobuf/internal/impl/merge.go
generated
vendored
@@ -77,9 +77,9 @@ func (mi *MessageInfo) mergePointer(dst, src pointer, opts mergeOptions) {
|
||||
}
|
||||
}
|
||||
if mi.unknownOffset.IsValid() {
|
||||
du := dst.Apply(mi.unknownOffset).Bytes()
|
||||
su := src.Apply(mi.unknownOffset).Bytes()
|
||||
if len(*su) > 0 {
|
||||
su := mi.getUnknownBytes(src)
|
||||
if su != nil && len(*su) > 0 {
|
||||
du := mi.mutableUnknownBytes(dst)
|
||||
*du = append(*du, *su...)
|
||||
}
|
||||
}
|
||||
|
69
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
69
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
@@ -15,6 +15,7 @@ import (
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// MessageInfo provides protobuf related functionality for a given Go type
|
||||
@@ -109,22 +110,29 @@ func (mi *MessageInfo) getPointer(m pref.Message) (p pointer, ok bool) {
|
||||
type (
|
||||
SizeCache = int32
|
||||
WeakFields = map[int32]protoreflect.ProtoMessage
|
||||
UnknownFields = []byte
|
||||
UnknownFields = unknownFieldsA // TODO: switch to unknownFieldsB
|
||||
unknownFieldsA = []byte
|
||||
unknownFieldsB = *[]byte
|
||||
ExtensionFields = map[int32]ExtensionField
|
||||
)
|
||||
|
||||
var (
|
||||
sizecacheType = reflect.TypeOf(SizeCache(0))
|
||||
weakFieldsType = reflect.TypeOf(WeakFields(nil))
|
||||
unknownFieldsType = reflect.TypeOf(UnknownFields(nil))
|
||||
unknownFieldsAType = reflect.TypeOf(unknownFieldsA(nil))
|
||||
unknownFieldsBType = reflect.TypeOf(unknownFieldsB(nil))
|
||||
extensionFieldsType = reflect.TypeOf(ExtensionFields(nil))
|
||||
)
|
||||
|
||||
type structInfo struct {
|
||||
sizecacheOffset offset
|
||||
sizecacheType reflect.Type
|
||||
weakOffset offset
|
||||
weakType reflect.Type
|
||||
unknownOffset offset
|
||||
unknownType reflect.Type
|
||||
extensionOffset offset
|
||||
extensionType reflect.Type
|
||||
|
||||
fieldsByNumber map[pref.FieldNumber]reflect.StructField
|
||||
oneofsByName map[pref.Name]reflect.StructField
|
||||
@@ -151,18 +159,22 @@ fieldLoop:
|
||||
case genid.SizeCache_goname, genid.SizeCacheA_goname:
|
||||
if f.Type == sizecacheType {
|
||||
si.sizecacheOffset = offsetOf(f, mi.Exporter)
|
||||
si.sizecacheType = f.Type
|
||||
}
|
||||
case genid.WeakFields_goname, genid.WeakFieldsA_goname:
|
||||
if f.Type == weakFieldsType {
|
||||
si.weakOffset = offsetOf(f, mi.Exporter)
|
||||
si.weakType = f.Type
|
||||
}
|
||||
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
|
||||
if f.Type == unknownFieldsType {
|
||||
if f.Type == unknownFieldsAType || f.Type == unknownFieldsBType {
|
||||
si.unknownOffset = offsetOf(f, mi.Exporter)
|
||||
si.unknownType = f.Type
|
||||
}
|
||||
case genid.ExtensionFields_goname, genid.ExtensionFieldsA_goname, genid.ExtensionFieldsB_goname:
|
||||
if f.Type == extensionFieldsType {
|
||||
si.extensionOffset = offsetOf(f, mi.Exporter)
|
||||
si.extensionType = f.Type
|
||||
}
|
||||
default:
|
||||
for _, s := range strings.Split(f.Tag.Get("protobuf"), ",") {
|
||||
@@ -212,4 +224,53 @@ func (mi *MessageInfo) New() protoreflect.Message {
|
||||
func (mi *MessageInfo) Zero() protoreflect.Message {
|
||||
return mi.MessageOf(reflect.Zero(mi.GoReflectType).Interface())
|
||||
}
|
||||
func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor { return mi.Desc }
|
||||
func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor {
|
||||
return mi.Desc
|
||||
}
|
||||
func (mi *MessageInfo) Enum(i int) protoreflect.EnumType {
|
||||
mi.init()
|
||||
fd := mi.Desc.Fields().Get(i)
|
||||
return Export{}.EnumTypeOf(mi.fieldTypes[fd.Number()])
|
||||
}
|
||||
func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
|
||||
mi.init()
|
||||
fd := mi.Desc.Fields().Get(i)
|
||||
switch {
|
||||
case fd.IsWeak():
|
||||
mt, _ := preg.GlobalTypes.FindMessageByName(fd.Message().FullName())
|
||||
return mt
|
||||
case fd.IsMap():
|
||||
return mapEntryType{fd.Message(), mi.fieldTypes[fd.Number()]}
|
||||
default:
|
||||
return Export{}.MessageTypeOf(mi.fieldTypes[fd.Number()])
|
||||
}
|
||||
}
|
||||
|
||||
type mapEntryType struct {
|
||||
desc protoreflect.MessageDescriptor
|
||||
valType interface{} // zero value of enum or message type
|
||||
}
|
||||
|
||||
func (mt mapEntryType) New() protoreflect.Message {
|
||||
return nil
|
||||
}
|
||||
func (mt mapEntryType) Zero() protoreflect.Message {
|
||||
return nil
|
||||
}
|
||||
func (mt mapEntryType) Descriptor() protoreflect.MessageDescriptor {
|
||||
return mt.desc
|
||||
}
|
||||
func (mt mapEntryType) Enum(i int) protoreflect.EnumType {
|
||||
fd := mt.desc.Fields().Get(i)
|
||||
if fd.Enum() == nil {
|
||||
return nil
|
||||
}
|
||||
return Export{}.EnumTypeOf(mt.valType)
|
||||
}
|
||||
func (mt mapEntryType) Message(i int) protoreflect.MessageType {
|
||||
fd := mt.desc.Fields().Get(i)
|
||||
if fd.Message() == nil {
|
||||
return nil
|
||||
}
|
||||
return Export{}.MessageTypeOf(mt.valType)
|
||||
}
|
||||
|
125
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
125
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/internal/detrand"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
@@ -16,6 +17,11 @@ type reflectMessageInfo struct {
|
||||
fields map[pref.FieldNumber]*fieldInfo
|
||||
oneofs map[pref.Name]*oneofInfo
|
||||
|
||||
// fieldTypes contains the zero value of an enum or message field.
|
||||
// For lists, it contains the element type.
|
||||
// For maps, it contains the entry value type.
|
||||
fieldTypes map[pref.FieldNumber]interface{}
|
||||
|
||||
// denseFields is a subset of fields where:
|
||||
// 0 < fieldDesc.Number() < len(denseFields)
|
||||
// It provides faster access to the fieldInfo, but may be incomplete.
|
||||
@@ -36,6 +42,7 @@ func (mi *MessageInfo) makeReflectFuncs(t reflect.Type, si structInfo) {
|
||||
mi.makeKnownFieldsFunc(si)
|
||||
mi.makeUnknownFieldsFunc(t, si)
|
||||
mi.makeExtensionFieldsFunc(t, si)
|
||||
mi.makeFieldTypes(si)
|
||||
}
|
||||
|
||||
// makeKnownFieldsFunc generates functions for operations that can be performed
|
||||
@@ -51,17 +58,23 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||
for i := 0; i < fds.Len(); i++ {
|
||||
fd := fds.Get(i)
|
||||
fs := si.fieldsByNumber[fd.Number()]
|
||||
isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
|
||||
if isOneof {
|
||||
fs = si.oneofsByName[fd.ContainingOneof().Name()]
|
||||
}
|
||||
var fi fieldInfo
|
||||
switch {
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||
case fs.Type == nil:
|
||||
fi = fieldInfoForMissing(fd) // never occurs for officially generated message types
|
||||
case isOneof:
|
||||
fi = fieldInfoForOneof(fd, fs, mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||
case fd.IsMap():
|
||||
fi = fieldInfoForMap(fd, fs, mi.Exporter)
|
||||
case fd.IsList():
|
||||
fi = fieldInfoForList(fd, fs, mi.Exporter)
|
||||
case fd.IsWeak():
|
||||
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
||||
case fd.Kind() == pref.MessageKind || fd.Kind() == pref.GroupKind:
|
||||
case fd.Message() != nil:
|
||||
fi = fieldInfoForMessage(fd, fs, mi.Exporter)
|
||||
default:
|
||||
fi = fieldInfoForScalar(fd, fs, mi.Exporter)
|
||||
@@ -92,27 +105,53 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// Introduce instability to iteration order, but keep it deterministic.
|
||||
if len(mi.rangeInfos) > 1 && detrand.Bool() {
|
||||
i := detrand.Intn(len(mi.rangeInfos) - 1)
|
||||
mi.rangeInfos[i], mi.rangeInfos[i+1] = mi.rangeInfos[i+1], mi.rangeInfos[i]
|
||||
}
|
||||
}
|
||||
|
||||
func (mi *MessageInfo) makeUnknownFieldsFunc(t reflect.Type, si structInfo) {
|
||||
mi.getUnknown = func(pointer) pref.RawFields { return nil }
|
||||
mi.setUnknown = func(pointer, pref.RawFields) { return }
|
||||
if si.unknownOffset.IsValid() {
|
||||
switch {
|
||||
case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsAType:
|
||||
// Handle as []byte.
|
||||
mi.getUnknown = func(p pointer) pref.RawFields {
|
||||
if p.IsNil() {
|
||||
return nil
|
||||
}
|
||||
rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType)
|
||||
return pref.RawFields(*rv.Interface().(*[]byte))
|
||||
return *p.Apply(mi.unknownOffset).Bytes()
|
||||
}
|
||||
mi.setUnknown = func(p pointer, b pref.RawFields) {
|
||||
if p.IsNil() {
|
||||
panic("invalid SetUnknown on nil Message")
|
||||
}
|
||||
rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType)
|
||||
*rv.Interface().(*[]byte) = []byte(b)
|
||||
*p.Apply(mi.unknownOffset).Bytes() = b
|
||||
}
|
||||
} else {
|
||||
case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsBType:
|
||||
// Handle as *[]byte.
|
||||
mi.getUnknown = func(p pointer) pref.RawFields {
|
||||
if p.IsNil() {
|
||||
return nil
|
||||
}
|
||||
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||
if *bp == nil {
|
||||
return nil
|
||||
}
|
||||
return **bp
|
||||
}
|
||||
mi.setUnknown = func(p pointer, b pref.RawFields) {
|
||||
if p.IsNil() {
|
||||
panic("invalid SetUnknown on nil Message")
|
||||
}
|
||||
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||
if *bp == nil {
|
||||
*bp = new([]byte)
|
||||
}
|
||||
**bp = b
|
||||
}
|
||||
default:
|
||||
mi.getUnknown = func(pointer) pref.RawFields {
|
||||
return nil
|
||||
}
|
||||
@@ -139,6 +178,58 @@ func (mi *MessageInfo) makeExtensionFieldsFunc(t reflect.Type, si structInfo) {
|
||||
}
|
||||
}
|
||||
}
|
||||
func (mi *MessageInfo) makeFieldTypes(si structInfo) {
|
||||
md := mi.Desc
|
||||
fds := md.Fields()
|
||||
for i := 0; i < fds.Len(); i++ {
|
||||
var ft reflect.Type
|
||||
fd := fds.Get(i)
|
||||
fs := si.fieldsByNumber[fd.Number()]
|
||||
isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
|
||||
if isOneof {
|
||||
fs = si.oneofsByName[fd.ContainingOneof().Name()]
|
||||
}
|
||||
var isMessage bool
|
||||
switch {
|
||||
case fs.Type == nil:
|
||||
continue // never occurs for officially generated message types
|
||||
case isOneof:
|
||||
if fd.Enum() != nil || fd.Message() != nil {
|
||||
ft = si.oneofWrappersByNumber[fd.Number()].Field(0).Type
|
||||
}
|
||||
case fd.IsMap():
|
||||
if fd.MapValue().Enum() != nil || fd.MapValue().Message() != nil {
|
||||
ft = fs.Type.Elem()
|
||||
}
|
||||
isMessage = fd.MapValue().Message() != nil
|
||||
case fd.IsList():
|
||||
if fd.Enum() != nil || fd.Message() != nil {
|
||||
ft = fs.Type.Elem()
|
||||
}
|
||||
isMessage = fd.Message() != nil
|
||||
case fd.Enum() != nil:
|
||||
ft = fs.Type
|
||||
if fd.HasPresence() && ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
}
|
||||
case fd.Message() != nil:
|
||||
ft = fs.Type
|
||||
if fd.IsWeak() {
|
||||
ft = nil
|
||||
}
|
||||
isMessage = true
|
||||
}
|
||||
if isMessage && ft != nil && ft.Kind() != reflect.Ptr {
|
||||
ft = reflect.PtrTo(ft) // never occurs for officially generated message types
|
||||
}
|
||||
if ft != nil {
|
||||
if mi.fieldTypes == nil {
|
||||
mi.fieldTypes = make(map[pref.FieldNumber]interface{})
|
||||
}
|
||||
mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type extensionMap map[int32]ExtensionField
|
||||
|
||||
@@ -306,7 +397,6 @@ var (
|
||||
// pointer to a named Go struct. If the provided type has a ProtoReflect method,
|
||||
// it must be implemented by calling this method.
|
||||
func (mi *MessageInfo) MessageOf(m interface{}) pref.Message {
|
||||
// TODO: Switch the input to be an opaque Pointer.
|
||||
if reflect.TypeOf(m) != mi.GoReflectType {
|
||||
panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType))
|
||||
}
|
||||
@@ -320,6 +410,17 @@ func (mi *MessageInfo) MessageOf(m interface{}) pref.Message {
|
||||
func (m *messageReflectWrapper) pointer() pointer { return m.p }
|
||||
func (m *messageReflectWrapper) messageInfo() *MessageInfo { return m.mi }
|
||||
|
||||
// Reset implements the v1 proto.Message.Reset method.
|
||||
func (m *messageIfaceWrapper) Reset() {
|
||||
if mr, ok := m.protoUnwrap().(interface{ Reset() }); ok {
|
||||
mr.Reset()
|
||||
return
|
||||
}
|
||||
rv := reflect.ValueOf(m.protoUnwrap())
|
||||
if rv.Kind() == reflect.Ptr && !rv.IsNil() {
|
||||
rv.Elem().Set(reflect.Zero(rv.Type().Elem()))
|
||||
}
|
||||
}
|
||||
func (m *messageIfaceWrapper) ProtoReflect() pref.Message {
|
||||
return (*messageReflectWrapper)(m)
|
||||
}
|
||||
|
85
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
85
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
@@ -28,6 +28,39 @@ type fieldInfo struct {
|
||||
newField func() pref.Value
|
||||
}
|
||||
|
||||
func fieldInfoForMissing(fd pref.FieldDescriptor) fieldInfo {
|
||||
// This never occurs for generated message types.
|
||||
// It implies that a hand-crafted type has missing Go fields
|
||||
// for specific protobuf message fields.
|
||||
return fieldInfo{
|
||||
fieldDesc: fd,
|
||||
has: func(p pointer) bool {
|
||||
return false
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
get: func(p pointer) pref.Value {
|
||||
return fd.Default()
|
||||
},
|
||||
set: func(p pointer, v pref.Value) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
mutable: func(p pointer) pref.Value {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
newMessage: func() pref.Message {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
newField: func() pref.Value {
|
||||
if v := fd.Default(); v.IsValid() {
|
||||
return v
|
||||
}
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo {
|
||||
ft := fs.Type
|
||||
if ft.Kind() != reflect.Interface {
|
||||
@@ -97,7 +130,7 @@ func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x export
|
||||
rv.Set(reflect.New(ot))
|
||||
}
|
||||
rv = rv.Elem().Elem().Field(0)
|
||||
if rv.IsNil() {
|
||||
if rv.Kind() == reflect.Ptr && rv.IsNil() {
|
||||
rv.Set(conv.GoValueOf(pref.ValueOfMessage(conv.New().Message())))
|
||||
}
|
||||
return conv.PBValueOf(rv)
|
||||
@@ -225,7 +258,10 @@ func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x expor
|
||||
isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8
|
||||
if nullable {
|
||||
if ft.Kind() != reflect.Ptr && ft.Kind() != reflect.Slice {
|
||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want pointer", fd.FullName(), ft))
|
||||
// This never occurs for generated message types.
|
||||
// Despite the protobuf type system specifying presence,
|
||||
// the Go field type cannot represent it.
|
||||
nullable = false
|
||||
}
|
||||
if ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
@@ -388,6 +424,9 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo
|
||||
return false
|
||||
}
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if fs.Type.Kind() != reflect.Ptr {
|
||||
return !isZero(rv)
|
||||
}
|
||||
return !rv.IsNil()
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
@@ -404,13 +443,13 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo
|
||||
set: func(p pointer, v pref.Value) {
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
rv.Set(conv.GoValueOf(v))
|
||||
if rv.IsNil() {
|
||||
if fs.Type.Kind() == reflect.Ptr && rv.IsNil() {
|
||||
panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName()))
|
||||
}
|
||||
},
|
||||
mutable: func(p pointer) pref.Value {
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() {
|
||||
if fs.Type.Kind() == reflect.Ptr && rv.IsNil() {
|
||||
rv.Set(conv.GoValueOf(conv.New()))
|
||||
}
|
||||
return conv.PBValueOf(rv)
|
||||
@@ -464,3 +503,41 @@ func makeOneofInfo(od pref.OneofDescriptor, si structInfo, x exporter) *oneofInf
|
||||
}
|
||||
return oi
|
||||
}
|
||||
|
||||
// isZero is identical to reflect.Value.IsZero.
|
||||
// TODO: Remove this when Go1.13 is the minimally supported Go version.
|
||||
func isZero(v reflect.Value) bool {
|
||||
switch v.Kind() {
|
||||
case reflect.Bool:
|
||||
return !v.Bool()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return v.Int() == 0
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
return v.Uint() == 0
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return math.Float64bits(v.Float()) == 0
|
||||
case reflect.Complex64, reflect.Complex128:
|
||||
c := v.Complex()
|
||||
return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
|
||||
case reflect.Array:
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
if !isZero(v.Index(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
|
||||
return v.IsNil()
|
||||
case reflect.String:
|
||||
return v.Len() == 0
|
||||
case reflect.Struct:
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
if !isZero(v.Field(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
default:
|
||||
panic(&reflect.ValueError{"reflect.Value.IsZero", v.Kind()})
|
||||
}
|
||||
}
|
||||
|
1
vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
generated
vendored
@@ -121,6 +121,7 @@ func (p pointer) String() *string { return p.v.Interface().(*string) }
|
||||
func (p pointer) StringPtr() **string { return p.v.Interface().(**string) }
|
||||
func (p pointer) StringSlice() *[]string { return p.v.Interface().(*[]string) }
|
||||
func (p pointer) Bytes() *[]byte { return p.v.Interface().(*[]byte) }
|
||||
func (p pointer) BytesPtr() **[]byte { return p.v.Interface().(**[]byte) }
|
||||
func (p pointer) BytesSlice() *[][]byte { return p.v.Interface().(*[][]byte) }
|
||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.v.Interface().(*WeakFields)) }
|
||||
func (p pointer) Extensions() *map[int32]ExtensionField {
|
||||
|
1
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go
generated
vendored
@@ -109,6 +109,7 @@ func (p pointer) String() *string { return (*string)(p.p)
|
||||
func (p pointer) StringPtr() **string { return (**string)(p.p) }
|
||||
func (p pointer) StringSlice() *[]string { return (*[]string)(p.p) }
|
||||
func (p pointer) Bytes() *[]byte { return (*[]byte)(p.p) }
|
||||
func (p pointer) BytesPtr() **[]byte { return (**[]byte)(p.p) }
|
||||
func (p pointer) BytesSlice() *[][]byte { return (*[][]byte)(p.p) }
|
||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.p) }
|
||||
func (p pointer) Extensions() *map[int32]ExtensionField { return (*map[int32]ExtensionField)(p.p) }
|
||||
|
43
vendor/google.golang.org/protobuf/internal/mapsort/mapsort.go
generated
vendored
43
vendor/google.golang.org/protobuf/internal/mapsort/mapsort.go
generated
vendored
@@ -1,43 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package mapsort provides sorted access to maps.
|
||||
package mapsort
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// Range iterates over every map entry in sorted key order,
|
||||
// calling f for each key and value encountered.
|
||||
func Range(mapv protoreflect.Map, keyKind protoreflect.Kind, f func(protoreflect.MapKey, protoreflect.Value) bool) {
|
||||
var keys []protoreflect.MapKey
|
||||
mapv.Range(func(key protoreflect.MapKey, _ protoreflect.Value) bool {
|
||||
keys = append(keys, key)
|
||||
return true
|
||||
})
|
||||
sort.Slice(keys, func(i, j int) bool {
|
||||
switch keyKind {
|
||||
case protoreflect.BoolKind:
|
||||
return !keys[i].Bool() && keys[j].Bool()
|
||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind,
|
||||
protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
||||
return keys[i].Int() < keys[j].Int()
|
||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind,
|
||||
protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
||||
return keys[i].Uint() < keys[j].Uint()
|
||||
case protoreflect.StringKind:
|
||||
return keys[i].String() < keys[j].String()
|
||||
default:
|
||||
panic("invalid kind: " + keyKind.String())
|
||||
}
|
||||
})
|
||||
for _, key := range keys {
|
||||
if !f(key, mapv.Get(key)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
89
vendor/google.golang.org/protobuf/internal/order/order.go
generated
vendored
Normal file
89
vendor/google.golang.org/protobuf/internal/order/order.go
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package order
|
||||
|
||||
import (
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// FieldOrder specifies the ordering to visit message fields.
|
||||
// It is a function that reports whether x is ordered before y.
|
||||
type FieldOrder func(x, y pref.FieldDescriptor) bool
|
||||
|
||||
var (
|
||||
// AnyFieldOrder specifies no specific field ordering.
|
||||
AnyFieldOrder FieldOrder = nil
|
||||
|
||||
// LegacyFieldOrder sorts fields in the same ordering as emitted by
|
||||
// wire serialization in the github.com/golang/protobuf implementation.
|
||||
LegacyFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
||||
ox, oy := x.ContainingOneof(), y.ContainingOneof()
|
||||
inOneof := func(od pref.OneofDescriptor) bool {
|
||||
return od != nil && !od.IsSynthetic()
|
||||
}
|
||||
|
||||
// Extension fields sort before non-extension fields.
|
||||
if x.IsExtension() != y.IsExtension() {
|
||||
return x.IsExtension() && !y.IsExtension()
|
||||
}
|
||||
// Fields not within a oneof sort before those within a oneof.
|
||||
if inOneof(ox) != inOneof(oy) {
|
||||
return !inOneof(ox) && inOneof(oy)
|
||||
}
|
||||
// Fields in disjoint oneof sets are sorted by declaration index.
|
||||
if ox != nil && oy != nil && ox != oy {
|
||||
return ox.Index() < oy.Index()
|
||||
}
|
||||
// Fields sorted by field number.
|
||||
return x.Number() < y.Number()
|
||||
}
|
||||
|
||||
// NumberFieldOrder sorts fields by their field number.
|
||||
NumberFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
||||
return x.Number() < y.Number()
|
||||
}
|
||||
|
||||
// IndexNameFieldOrder sorts non-extension fields before extension fields.
|
||||
// Non-extensions are sorted according to their declaration index.
|
||||
// Extensions are sorted according to their full name.
|
||||
IndexNameFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
||||
// Non-extension fields sort before extension fields.
|
||||
if x.IsExtension() != y.IsExtension() {
|
||||
return !x.IsExtension() && y.IsExtension()
|
||||
}
|
||||
// Extensions sorted by fullname.
|
||||
if x.IsExtension() && y.IsExtension() {
|
||||
return x.FullName() < y.FullName()
|
||||
}
|
||||
// Non-extensions sorted by declaration index.
|
||||
return x.Index() < y.Index()
|
||||
}
|
||||
)
|
||||
|
||||
// KeyOrder specifies the ordering to visit map entries.
|
||||
// It is a function that reports whether x is ordered before y.
|
||||
type KeyOrder func(x, y pref.MapKey) bool
|
||||
|
||||
var (
|
||||
// AnyKeyOrder specifies no specific key ordering.
|
||||
AnyKeyOrder KeyOrder = nil
|
||||
|
||||
// GenericKeyOrder sorts false before true, numeric keys in ascending order,
|
||||
// and strings in lexicographical ordering according to UTF-8 codepoints.
|
||||
GenericKeyOrder KeyOrder = func(x, y pref.MapKey) bool {
|
||||
switch x.Interface().(type) {
|
||||
case bool:
|
||||
return !x.Bool() && y.Bool()
|
||||
case int32, int64:
|
||||
return x.Int() < y.Int()
|
||||
case uint32, uint64:
|
||||
return x.Uint() < y.Uint()
|
||||
case string:
|
||||
return x.String() < y.String()
|
||||
default:
|
||||
panic("invalid map key type")
|
||||
}
|
||||
}
|
||||
)
|
115
vendor/google.golang.org/protobuf/internal/order/range.go
generated
vendored
Normal file
115
vendor/google.golang.org/protobuf/internal/order/range.go
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package order provides ordered access to messages and maps.
|
||||
package order
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
type messageField struct {
|
||||
fd pref.FieldDescriptor
|
||||
v pref.Value
|
||||
}
|
||||
|
||||
var messageFieldPool = sync.Pool{
|
||||
New: func() interface{} { return new([]messageField) },
|
||||
}
|
||||
|
||||
type (
|
||||
// FieldRnger is an interface for visiting all fields in a message.
|
||||
// The protoreflect.Message type implements this interface.
|
||||
FieldRanger interface{ Range(VisitField) }
|
||||
// VisitField is called everytime a message field is visited.
|
||||
VisitField = func(pref.FieldDescriptor, pref.Value) bool
|
||||
)
|
||||
|
||||
// RangeFields iterates over the fields of fs according to the specified order.
|
||||
func RangeFields(fs FieldRanger, less FieldOrder, fn VisitField) {
|
||||
if less == nil {
|
||||
fs.Range(fn)
|
||||
return
|
||||
}
|
||||
|
||||
// Obtain a pre-allocated scratch buffer.
|
||||
p := messageFieldPool.Get().(*[]messageField)
|
||||
fields := (*p)[:0]
|
||||
defer func() {
|
||||
if cap(fields) < 1024 {
|
||||
*p = fields
|
||||
messageFieldPool.Put(p)
|
||||
}
|
||||
}()
|
||||
|
||||
// Collect all fields in the message and sort them.
|
||||
fs.Range(func(fd pref.FieldDescriptor, v pref.Value) bool {
|
||||
fields = append(fields, messageField{fd, v})
|
||||
return true
|
||||
})
|
||||
sort.Slice(fields, func(i, j int) bool {
|
||||
return less(fields[i].fd, fields[j].fd)
|
||||
})
|
||||
|
||||
// Visit the fields in the specified ordering.
|
||||
for _, f := range fields {
|
||||
if !fn(f.fd, f.v) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type mapEntry struct {
|
||||
k pref.MapKey
|
||||
v pref.Value
|
||||
}
|
||||
|
||||
var mapEntryPool = sync.Pool{
|
||||
New: func() interface{} { return new([]mapEntry) },
|
||||
}
|
||||
|
||||
type (
|
||||
// EntryRanger is an interface for visiting all fields in a message.
|
||||
// The protoreflect.Map type implements this interface.
|
||||
EntryRanger interface{ Range(VisitEntry) }
|
||||
// VisitEntry is called everytime a map entry is visited.
|
||||
VisitEntry = func(pref.MapKey, pref.Value) bool
|
||||
)
|
||||
|
||||
// RangeEntries iterates over the entries of es according to the specified order.
|
||||
func RangeEntries(es EntryRanger, less KeyOrder, fn VisitEntry) {
|
||||
if less == nil {
|
||||
es.Range(fn)
|
||||
return
|
||||
}
|
||||
|
||||
// Obtain a pre-allocated scratch buffer.
|
||||
p := mapEntryPool.Get().(*[]mapEntry)
|
||||
entries := (*p)[:0]
|
||||
defer func() {
|
||||
if cap(entries) < 1024 {
|
||||
*p = entries
|
||||
mapEntryPool.Put(p)
|
||||
}
|
||||
}()
|
||||
|
||||
// Collect all entries in the map and sort them.
|
||||
es.Range(func(k pref.MapKey, v pref.Value) bool {
|
||||
entries = append(entries, mapEntry{k, v})
|
||||
return true
|
||||
})
|
||||
sort.Slice(entries, func(i, j int) bool {
|
||||
return less(entries[i].k, entries[j].k)
|
||||
})
|
||||
|
||||
// Visit the entries in the specified ordering.
|
||||
for _, e := range entries {
|
||||
if !fn(e.k, e.v) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
2
vendor/google.golang.org/protobuf/internal/version/version.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/version/version.go
generated
vendored
@@ -52,7 +52,7 @@ import (
|
||||
// 10. Send out the CL for review and submit it.
|
||||
const (
|
||||
Major = 1
|
||||
Minor = 25
|
||||
Minor = 26
|
||||
Patch = 0
|
||||
PreRelease = ""
|
||||
)
|
||||
|
18
vendor/google.golang.org/protobuf/proto/decode.go
generated
vendored
18
vendor/google.golang.org/protobuf/proto/decode.go
generated
vendored
@@ -45,12 +45,14 @@ type UnmarshalOptions struct {
|
||||
}
|
||||
|
||||
// Unmarshal parses the wire-format message in b and places the result in m.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func Unmarshal(b []byte, m Message) error {
|
||||
_, err := UnmarshalOptions{}.unmarshal(b, m.ProtoReflect())
|
||||
return err
|
||||
}
|
||||
|
||||
// Unmarshal parses the wire-format message in b and places the result in m.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func (o UnmarshalOptions) Unmarshal(b []byte, m Message) error {
|
||||
_, err := o.unmarshal(b, m.ProtoReflect())
|
||||
return err
|
||||
@@ -116,10 +118,10 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
|
||||
// Parse the tag (field number and wire type).
|
||||
num, wtyp, tagLen := protowire.ConsumeTag(b)
|
||||
if tagLen < 0 {
|
||||
return protowire.ParseError(tagLen)
|
||||
return errDecode
|
||||
}
|
||||
if num > protowire.MaxValidNumber {
|
||||
return errors.New("invalid field number")
|
||||
return errDecode
|
||||
}
|
||||
|
||||
// Find the field descriptor for this field number.
|
||||
@@ -159,7 +161,7 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
|
||||
}
|
||||
valLen = protowire.ConsumeFieldValue(num, wtyp, b[tagLen:])
|
||||
if valLen < 0 {
|
||||
return protowire.ParseError(valLen)
|
||||
return errDecode
|
||||
}
|
||||
if !o.DiscardUnknown {
|
||||
m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...))
|
||||
@@ -194,7 +196,7 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||
}
|
||||
b, n = protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
var (
|
||||
keyField = fd.MapKey()
|
||||
@@ -213,10 +215,10 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||
for len(b) > 0 {
|
||||
num, wtyp, n := protowire.ConsumeTag(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
if num > protowire.MaxValidNumber {
|
||||
return 0, errors.New("invalid field number")
|
||||
return 0, errDecode
|
||||
}
|
||||
b = b[n:]
|
||||
err = errUnknown
|
||||
@@ -246,7 +248,7 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||
if err == errUnknown {
|
||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
} else if err != nil {
|
||||
return 0, err
|
||||
@@ -272,3 +274,5 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
|
||||
// to the unknown field set of a message. It is never returned from an exported
|
||||
// function.
|
||||
var errUnknown = errors.New("BUG: internal error (unknown)")
|
||||
|
||||
var errDecode = errors.New("cannot parse invalid wire-format data")
|
||||
|
128
vendor/google.golang.org/protobuf/proto/decode_gen.go
generated
vendored
128
vendor/google.golang.org/protobuf/proto/decode_gen.go
generated
vendored
@@ -27,7 +27,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfBool(protowire.DecodeBool(v)), n, nil
|
||||
case protoreflect.EnumKind:
|
||||
@@ -36,7 +36,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
|
||||
case protoreflect.Int32Kind:
|
||||
@@ -45,7 +45,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfInt32(int32(v)), n, nil
|
||||
case protoreflect.Sint32Kind:
|
||||
@@ -54,7 +54,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))), n, nil
|
||||
case protoreflect.Uint32Kind:
|
||||
@@ -63,7 +63,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfUint32(uint32(v)), n, nil
|
||||
case protoreflect.Int64Kind:
|
||||
@@ -72,7 +72,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfInt64(int64(v)), n, nil
|
||||
case protoreflect.Sint64Kind:
|
||||
@@ -81,7 +81,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)), n, nil
|
||||
case protoreflect.Uint64Kind:
|
||||
@@ -90,7 +90,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfUint64(v), n, nil
|
||||
case protoreflect.Sfixed32Kind:
|
||||
@@ -99,7 +99,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfInt32(int32(v)), n, nil
|
||||
case protoreflect.Fixed32Kind:
|
||||
@@ -108,7 +108,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfUint32(uint32(v)), n, nil
|
||||
case protoreflect.FloatKind:
|
||||
@@ -117,7 +117,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
|
||||
case protoreflect.Sfixed64Kind:
|
||||
@@ -126,7 +126,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfInt64(int64(v)), n, nil
|
||||
case protoreflect.Fixed64Kind:
|
||||
@@ -135,7 +135,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfUint64(v), n, nil
|
||||
case protoreflect.DoubleKind:
|
||||
@@ -144,7 +144,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
|
||||
case protoreflect.StringKind:
|
||||
@@ -153,7 +153,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
|
||||
return protoreflect.Value{}, 0, errors.InvalidUTF8(string(fd.FullName()))
|
||||
@@ -165,7 +165,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), n, nil
|
||||
case protoreflect.MessageKind:
|
||||
@@ -174,7 +174,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfBytes(v), n, nil
|
||||
case protoreflect.GroupKind:
|
||||
@@ -183,7 +183,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
|
||||
}
|
||||
v, n := protowire.ConsumeGroup(fd.Number(), b)
|
||||
if n < 0 {
|
||||
return val, 0, protowire.ParseError(n)
|
||||
return val, 0, errDecode
|
||||
}
|
||||
return protoreflect.ValueOfBytes(v), n, nil
|
||||
default:
|
||||
@@ -197,12 +197,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
|
||||
@@ -214,7 +214,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
|
||||
return n, nil
|
||||
@@ -222,12 +222,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
|
||||
@@ -239,7 +239,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
|
||||
return n, nil
|
||||
@@ -247,12 +247,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||
@@ -264,7 +264,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||
return n, nil
|
||||
@@ -272,12 +272,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
|
||||
@@ -289,7 +289,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
|
||||
return n, nil
|
||||
@@ -297,12 +297,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||
@@ -314,7 +314,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||
return n, nil
|
||||
@@ -322,12 +322,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||
@@ -339,7 +339,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||
return n, nil
|
||||
@@ -347,12 +347,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
|
||||
@@ -364,7 +364,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
|
||||
return n, nil
|
||||
@@ -372,12 +372,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeVarint(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfUint64(v))
|
||||
@@ -389,7 +389,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfUint64(v))
|
||||
return n, nil
|
||||
@@ -397,12 +397,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeFixed32(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||
@@ -414,7 +414,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfInt32(int32(v)))
|
||||
return n, nil
|
||||
@@ -422,12 +422,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeFixed32(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||
@@ -439,7 +439,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfUint32(uint32(v)))
|
||||
return n, nil
|
||||
@@ -447,12 +447,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeFixed32(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
|
||||
@@ -464,7 +464,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed32(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
|
||||
return n, nil
|
||||
@@ -472,12 +472,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeFixed64(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||
@@ -489,7 +489,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfInt64(int64(v)))
|
||||
return n, nil
|
||||
@@ -497,12 +497,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeFixed64(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfUint64(v))
|
||||
@@ -514,7 +514,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfUint64(v))
|
||||
return n, nil
|
||||
@@ -522,12 +522,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
if wtyp == protowire.BytesType {
|
||||
buf, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
v, n := protowire.ConsumeFixed64(buf)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
buf = buf[n:]
|
||||
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
|
||||
@@ -539,7 +539,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeFixed64(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
|
||||
return n, nil
|
||||
@@ -549,7 +549,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
|
||||
return 0, errors.InvalidUTF8(string(fd.FullName()))
|
||||
@@ -562,7 +562,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
|
||||
return n, nil
|
||||
@@ -572,7 +572,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
if err := o.unmarshalMessage(v, m.Message()); err != nil {
|
||||
@@ -586,7 +586,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
|
||||
}
|
||||
v, n := protowire.ConsumeGroup(fd.Number(), b)
|
||||
if n < 0 {
|
||||
return 0, protowire.ParseError(n)
|
||||
return 0, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
if err := o.unmarshalMessage(v, m.Message()); err != nil {
|
||||
|
55
vendor/google.golang.org/protobuf/proto/encode.go
generated
vendored
55
vendor/google.golang.org/protobuf/proto/encode.go
generated
vendored
@@ -5,12 +5,9 @@
|
||||
package proto
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/fieldsort"
|
||||
"google.golang.org/protobuf/internal/mapsort"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/runtime/protoiface"
|
||||
@@ -211,14 +208,15 @@ func (o MarshalOptions) marshalMessageSlow(b []byte, m protoreflect.Message) ([]
|
||||
if messageset.IsMessageSet(m.Descriptor()) {
|
||||
return o.marshalMessageSet(b, m)
|
||||
}
|
||||
// There are many choices for what order we visit fields in. The default one here
|
||||
// is chosen for reasonable efficiency and simplicity given the protoreflect API.
|
||||
// It is not deterministic, since Message.Range does not return fields in any
|
||||
// defined order.
|
||||
//
|
||||
// When using deterministic serialization, we sort the known fields.
|
||||
fieldOrder := order.AnyFieldOrder
|
||||
if o.Deterministic {
|
||||
// TODO: This should use a more natural ordering like NumberFieldOrder,
|
||||
// but doing so breaks golden tests that make invalid assumption about
|
||||
// output stability of this implementation.
|
||||
fieldOrder = order.LegacyFieldOrder
|
||||
}
|
||||
var err error
|
||||
o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||
order.RangeFields(m, fieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||
b, err = o.marshalField(b, fd, v)
|
||||
return err == nil
|
||||
})
|
||||
@@ -229,27 +227,6 @@ func (o MarshalOptions) marshalMessageSlow(b []byte, m protoreflect.Message) ([]
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// rangeFields visits fields in a defined order when deterministic serialization is enabled.
|
||||
func (o MarshalOptions) rangeFields(m protoreflect.Message, f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
if !o.Deterministic {
|
||||
m.Range(f)
|
||||
return
|
||||
}
|
||||
var fds []protoreflect.FieldDescriptor
|
||||
m.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool {
|
||||
fds = append(fds, fd)
|
||||
return true
|
||||
})
|
||||
sort.Slice(fds, func(a, b int) bool {
|
||||
return fieldsort.Less(fds[a], fds[b])
|
||||
})
|
||||
for _, fd := range fds {
|
||||
if !f(fd, m.Get(fd)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o MarshalOptions) marshalField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) {
|
||||
switch {
|
||||
case fd.IsList():
|
||||
@@ -292,8 +269,12 @@ func (o MarshalOptions) marshalList(b []byte, fd protoreflect.FieldDescriptor, l
|
||||
func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) ([]byte, error) {
|
||||
keyf := fd.MapKey()
|
||||
valf := fd.MapValue()
|
||||
keyOrder := order.AnyKeyOrder
|
||||
if o.Deterministic {
|
||||
keyOrder = order.GenericKeyOrder
|
||||
}
|
||||
var err error
|
||||
o.rangeMap(mapv, keyf.Kind(), func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
||||
order.RangeEntries(mapv, keyOrder, func(key protoreflect.MapKey, value protoreflect.Value) bool {
|
||||
b = protowire.AppendTag(b, fd.Number(), protowire.BytesType)
|
||||
var pos int
|
||||
b, pos = appendSpeculativeLength(b)
|
||||
@@ -312,14 +293,6 @@ func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, ma
|
||||
return b, err
|
||||
}
|
||||
|
||||
func (o MarshalOptions) rangeMap(mapv protoreflect.Map, kind protoreflect.Kind, f func(protoreflect.MapKey, protoreflect.Value) bool) {
|
||||
if !o.Deterministic {
|
||||
mapv.Range(f)
|
||||
return
|
||||
}
|
||||
mapsort.Range(mapv, kind, f)
|
||||
}
|
||||
|
||||
// When encoding length-prefixed fields, we speculatively set aside some number of bytes
|
||||
// for the length, encode the data, and then encode the length (shifting the data if necessary
|
||||
// to make room).
|
||||
|
25
vendor/google.golang.org/protobuf/proto/equal.go
generated
vendored
25
vendor/google.golang.org/protobuf/proto/equal.go
generated
vendored
@@ -111,18 +111,31 @@ func equalList(fd pref.FieldDescriptor, x, y pref.List) bool {
|
||||
|
||||
// equalValue compares two singular values.
|
||||
func equalValue(fd pref.FieldDescriptor, x, y pref.Value) bool {
|
||||
switch {
|
||||
case fd.Message() != nil:
|
||||
return equalMessage(x.Message(), y.Message())
|
||||
case fd.Kind() == pref.BytesKind:
|
||||
return bytes.Equal(x.Bytes(), y.Bytes())
|
||||
case fd.Kind() == pref.FloatKind, fd.Kind() == pref.DoubleKind:
|
||||
switch fd.Kind() {
|
||||
case pref.BoolKind:
|
||||
return x.Bool() == y.Bool()
|
||||
case pref.EnumKind:
|
||||
return x.Enum() == y.Enum()
|
||||
case pref.Int32Kind, pref.Sint32Kind,
|
||||
pref.Int64Kind, pref.Sint64Kind,
|
||||
pref.Sfixed32Kind, pref.Sfixed64Kind:
|
||||
return x.Int() == y.Int()
|
||||
case pref.Uint32Kind, pref.Uint64Kind,
|
||||
pref.Fixed32Kind, pref.Fixed64Kind:
|
||||
return x.Uint() == y.Uint()
|
||||
case pref.FloatKind, pref.DoubleKind:
|
||||
fx := x.Float()
|
||||
fy := y.Float()
|
||||
if math.IsNaN(fx) || math.IsNaN(fy) {
|
||||
return math.IsNaN(fx) && math.IsNaN(fy)
|
||||
}
|
||||
return fx == fy
|
||||
case pref.StringKind:
|
||||
return x.String() == y.String()
|
||||
case pref.BytesKind:
|
||||
return bytes.Equal(x.Bytes(), y.Bytes())
|
||||
case pref.MessageKind, pref.GroupKind:
|
||||
return equalMessage(x.Message(), y.Message())
|
||||
default:
|
||||
return x.Interface() == y.Interface()
|
||||
}
|
||||
|
7
vendor/google.golang.org/protobuf/proto/messageset.go
generated
vendored
7
vendor/google.golang.org/protobuf/proto/messageset.go
generated
vendored
@@ -9,6 +9,7 @@ import (
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
@@ -28,8 +29,12 @@ func (o MarshalOptions) marshalMessageSet(b []byte, m protoreflect.Message) ([]b
|
||||
if !flags.ProtoLegacy {
|
||||
return b, errors.New("no support for message_set_wire_format")
|
||||
}
|
||||
fieldOrder := order.AnyFieldOrder
|
||||
if o.Deterministic {
|
||||
fieldOrder = order.NumberFieldOrder
|
||||
}
|
||||
var err error
|
||||
o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||
order.RangeFields(m, fieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||
b, err = o.marshalMessageSetField(b, fd, v)
|
||||
return err == nil
|
||||
})
|
||||
|
9
vendor/google.golang.org/protobuf/proto/proto.go
generated
vendored
9
vendor/google.golang.org/protobuf/proto/proto.go
generated
vendored
@@ -32,3 +32,12 @@ var Error error
|
||||
func init() {
|
||||
Error = errors.Error
|
||||
}
|
||||
|
||||
// MessageName returns the full name of m.
|
||||
// If m is nil, it returns an empty string.
|
||||
func MessageName(m Message) protoreflect.FullName {
|
||||
if m == nil {
|
||||
return ""
|
||||
}
|
||||
return m.ProtoReflect().Descriptor().FullName()
|
||||
}
|
||||
|
1
vendor/google.golang.org/protobuf/reflect/protodesc/desc.go
generated
vendored
1
vendor/google.golang.org/protobuf/reflect/protodesc/desc.go
generated
vendored
@@ -144,6 +144,7 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
||||
}
|
||||
|
||||
// Handle source locations.
|
||||
f.L2.Locations.File = f
|
||||
for _, loc := range fd.GetSourceCodeInfo().GetLocation() {
|
||||
var l protoreflect.SourceLocation
|
||||
// TODO: Validate that the path points to an actual declaration?
|
||||
|
4
vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go
generated
vendored
4
vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go
generated
vendored
@@ -135,7 +135,7 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc
|
||||
f.L1.Kind = protoreflect.Kind(fd.GetType())
|
||||
}
|
||||
if fd.JsonName != nil {
|
||||
f.L1.JSONName.Init(fd.GetJsonName())
|
||||
f.L1.StringName.InitJSON(fd.GetJsonName())
|
||||
}
|
||||
}
|
||||
return fs, nil
|
||||
@@ -175,7 +175,7 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript
|
||||
x.L1.Kind = protoreflect.Kind(xd.GetType())
|
||||
}
|
||||
if xd.JsonName != nil {
|
||||
x.L2.JSONName.Init(xd.GetJsonName())
|
||||
x.L2.StringName.InitJSON(xd.GetJsonName())
|
||||
}
|
||||
}
|
||||
return xs, nil
|
||||
|
3
vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go
generated
vendored
3
vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go
generated
vendored
@@ -239,6 +239,9 @@ func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb.
|
||||
return errors.New("extension field %q has an invalid cardinality: %d", x.FullName(), x.Cardinality())
|
||||
}
|
||||
if xd.JsonName != nil {
|
||||
// A bug in older versions of protoc would always populate the
|
||||
// "json_name" option for extensions when it is meaningless.
|
||||
// When it did so, it would always use the camel-cased field name.
|
||||
if xd.GetJsonName() != strs.JSONCamelCase(string(x.Name())) {
|
||||
return errors.New("extension field %q may not have an explicitly set JSON name: %q", x.FullName(), xd.GetJsonName())
|
||||
}
|
||||
|
14
vendor/google.golang.org/protobuf/reflect/protodesc/proto.go
generated
vendored
14
vendor/google.golang.org/protobuf/reflect/protodesc/proto.go
generated
vendored
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"google.golang.org/protobuf/internal/encoding/defval"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
||||
@@ -20,9 +21,11 @@ import (
|
||||
func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto {
|
||||
p := &descriptorpb.FileDescriptorProto{
|
||||
Name: proto.String(file.Path()),
|
||||
Package: proto.String(string(file.Package())),
|
||||
Options: proto.Clone(file.Options()).(*descriptorpb.FileOptions),
|
||||
}
|
||||
if file.Package() != "" {
|
||||
p.Package = proto.String(string(file.Package()))
|
||||
}
|
||||
for i, imports := 0, file.Imports(); i < imports.Len(); i++ {
|
||||
imp := imports.Get(i)
|
||||
p.Dependency = append(p.Dependency, imp.Path())
|
||||
@@ -138,7 +141,14 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
|
||||
p.TypeName = fullNameOf(field.Message())
|
||||
}
|
||||
if field.HasJSONName() {
|
||||
p.JsonName = proto.String(field.JSONName())
|
||||
// A bug in older versions of protoc would always populate the
|
||||
// "json_name" option for extensions when it is meaningless.
|
||||
// When it did so, it would always use the camel-cased field name.
|
||||
if field.IsExtension() {
|
||||
p.JsonName = proto.String(strs.JSONCamelCase(string(field.Name())))
|
||||
} else {
|
||||
p.JsonName = proto.String(field.JSONName())
|
||||
}
|
||||
}
|
||||
if field.Syntax() == protoreflect.Proto3 && field.HasOptionalKeyword() {
|
||||
p.Proto3Optional = proto.Bool(true)
|
||||
|
84
vendor/google.golang.org/protobuf/reflect/protoreflect/source.go
generated
vendored
84
vendor/google.golang.org/protobuf/reflect/protoreflect/source.go
generated
vendored
@@ -4,6 +4,10 @@
|
||||
|
||||
package protoreflect
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// SourceLocations is a list of source locations.
|
||||
type SourceLocations interface {
|
||||
// Len reports the number of source locations in the proto file.
|
||||
@@ -11,9 +15,20 @@ type SourceLocations interface {
|
||||
// Get returns the ith SourceLocation. It panics if out of bounds.
|
||||
Get(int) SourceLocation
|
||||
|
||||
doNotImplement
|
||||
// ByPath returns the SourceLocation for the given path,
|
||||
// returning the first location if multiple exist for the same path.
|
||||
// If multiple locations exist for the same path,
|
||||
// then SourceLocation.Next index can be used to identify the
|
||||
// index of the next SourceLocation.
|
||||
// If no location exists for this path, it returns the zero value.
|
||||
ByPath(path SourcePath) SourceLocation
|
||||
|
||||
// TODO: Add ByPath and ByDescriptor helper methods.
|
||||
// ByDescriptor returns the SourceLocation for the given descriptor,
|
||||
// returning the first location if multiple exist for the same path.
|
||||
// If no location exists for this descriptor, it returns the zero value.
|
||||
ByDescriptor(desc Descriptor) SourceLocation
|
||||
|
||||
doNotImplement
|
||||
}
|
||||
|
||||
// SourceLocation describes a source location and
|
||||
@@ -39,6 +54,10 @@ type SourceLocation struct {
|
||||
LeadingComments string
|
||||
// TrailingComments is the trailing attached comment for the declaration.
|
||||
TrailingComments string
|
||||
|
||||
// Next is an index into SourceLocations for the next source location that
|
||||
// has the same Path. It is zero if there is no next location.
|
||||
Next int
|
||||
}
|
||||
|
||||
// SourcePath identifies part of a file descriptor for a source location.
|
||||
@@ -48,5 +67,62 @@ type SourceLocation struct {
|
||||
// See google.protobuf.SourceCodeInfo.Location.path.
|
||||
type SourcePath []int32
|
||||
|
||||
// TODO: Add SourcePath.String method to pretty-print the path. For example:
|
||||
// ".message_type[6].nested_type[15].field[3]"
|
||||
// Equal reports whether p1 equals p2.
|
||||
func (p1 SourcePath) Equal(p2 SourcePath) bool {
|
||||
if len(p1) != len(p2) {
|
||||
return false
|
||||
}
|
||||
for i := range p1 {
|
||||
if p1[i] != p2[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// String formats the path in a humanly readable manner.
|
||||
// The output is guaranteed to be deterministic,
|
||||
// making it suitable for use as a key into a Go map.
|
||||
// It is not guaranteed to be stable as the exact output could change
|
||||
// in a future version of this module.
|
||||
//
|
||||
// Example output:
|
||||
// .message_type[6].nested_type[15].field[3]
|
||||
func (p SourcePath) String() string {
|
||||
b := p.appendFileDescriptorProto(nil)
|
||||
for _, i := range p {
|
||||
b = append(b, '.')
|
||||
b = strconv.AppendInt(b, int64(i), 10)
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
type appendFunc func(*SourcePath, []byte) []byte
|
||||
|
||||
func (p *SourcePath) appendSingularField(b []byte, name string, f appendFunc) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
b = append(b, '.')
|
||||
b = append(b, name...)
|
||||
*p = (*p)[1:]
|
||||
if f != nil {
|
||||
b = f(p, b)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendRepeatedField(b []byte, name string, f appendFunc) []byte {
|
||||
b = p.appendSingularField(b, name, nil)
|
||||
if len(*p) == 0 || (*p)[0] < 0 {
|
||||
return b
|
||||
}
|
||||
b = append(b, '[')
|
||||
b = strconv.AppendUint(b, uint64((*p)[0]), 10)
|
||||
b = append(b, ']')
|
||||
*p = (*p)[1:]
|
||||
if f != nil {
|
||||
b = f(p, b)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
461
vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go
generated
vendored
Normal file
461
vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go
generated
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package protoreflect
|
||||
|
||||
func (p *SourcePath) appendFileDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "package", nil)
|
||||
case 3:
|
||||
b = p.appendRepeatedField(b, "dependency", nil)
|
||||
case 10:
|
||||
b = p.appendRepeatedField(b, "public_dependency", nil)
|
||||
case 11:
|
||||
b = p.appendRepeatedField(b, "weak_dependency", nil)
|
||||
case 4:
|
||||
b = p.appendRepeatedField(b, "message_type", (*SourcePath).appendDescriptorProto)
|
||||
case 5:
|
||||
b = p.appendRepeatedField(b, "enum_type", (*SourcePath).appendEnumDescriptorProto)
|
||||
case 6:
|
||||
b = p.appendRepeatedField(b, "service", (*SourcePath).appendServiceDescriptorProto)
|
||||
case 7:
|
||||
b = p.appendRepeatedField(b, "extension", (*SourcePath).appendFieldDescriptorProto)
|
||||
case 8:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendFileOptions)
|
||||
case 9:
|
||||
b = p.appendSingularField(b, "source_code_info", (*SourcePath).appendSourceCodeInfo)
|
||||
case 12:
|
||||
b = p.appendSingularField(b, "syntax", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 2:
|
||||
b = p.appendRepeatedField(b, "field", (*SourcePath).appendFieldDescriptorProto)
|
||||
case 6:
|
||||
b = p.appendRepeatedField(b, "extension", (*SourcePath).appendFieldDescriptorProto)
|
||||
case 3:
|
||||
b = p.appendRepeatedField(b, "nested_type", (*SourcePath).appendDescriptorProto)
|
||||
case 4:
|
||||
b = p.appendRepeatedField(b, "enum_type", (*SourcePath).appendEnumDescriptorProto)
|
||||
case 5:
|
||||
b = p.appendRepeatedField(b, "extension_range", (*SourcePath).appendDescriptorProto_ExtensionRange)
|
||||
case 8:
|
||||
b = p.appendRepeatedField(b, "oneof_decl", (*SourcePath).appendOneofDescriptorProto)
|
||||
case 7:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendMessageOptions)
|
||||
case 9:
|
||||
b = p.appendRepeatedField(b, "reserved_range", (*SourcePath).appendDescriptorProto_ReservedRange)
|
||||
case 10:
|
||||
b = p.appendRepeatedField(b, "reserved_name", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendEnumDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 2:
|
||||
b = p.appendRepeatedField(b, "value", (*SourcePath).appendEnumValueDescriptorProto)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendEnumOptions)
|
||||
case 4:
|
||||
b = p.appendRepeatedField(b, "reserved_range", (*SourcePath).appendEnumDescriptorProto_EnumReservedRange)
|
||||
case 5:
|
||||
b = p.appendRepeatedField(b, "reserved_name", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendServiceDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 2:
|
||||
b = p.appendRepeatedField(b, "method", (*SourcePath).appendMethodDescriptorProto)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendServiceOptions)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendFieldDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "number", nil)
|
||||
case 4:
|
||||
b = p.appendSingularField(b, "label", nil)
|
||||
case 5:
|
||||
b = p.appendSingularField(b, "type", nil)
|
||||
case 6:
|
||||
b = p.appendSingularField(b, "type_name", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "extendee", nil)
|
||||
case 7:
|
||||
b = p.appendSingularField(b, "default_value", nil)
|
||||
case 9:
|
||||
b = p.appendSingularField(b, "oneof_index", nil)
|
||||
case 10:
|
||||
b = p.appendSingularField(b, "json_name", nil)
|
||||
case 8:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendFieldOptions)
|
||||
case 17:
|
||||
b = p.appendSingularField(b, "proto3_optional", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendFileOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "java_package", nil)
|
||||
case 8:
|
||||
b = p.appendSingularField(b, "java_outer_classname", nil)
|
||||
case 10:
|
||||
b = p.appendSingularField(b, "java_multiple_files", nil)
|
||||
case 20:
|
||||
b = p.appendSingularField(b, "java_generate_equals_and_hash", nil)
|
||||
case 27:
|
||||
b = p.appendSingularField(b, "java_string_check_utf8", nil)
|
||||
case 9:
|
||||
b = p.appendSingularField(b, "optimize_for", nil)
|
||||
case 11:
|
||||
b = p.appendSingularField(b, "go_package", nil)
|
||||
case 16:
|
||||
b = p.appendSingularField(b, "cc_generic_services", nil)
|
||||
case 17:
|
||||
b = p.appendSingularField(b, "java_generic_services", nil)
|
||||
case 18:
|
||||
b = p.appendSingularField(b, "py_generic_services", nil)
|
||||
case 42:
|
||||
b = p.appendSingularField(b, "php_generic_services", nil)
|
||||
case 23:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 31:
|
||||
b = p.appendSingularField(b, "cc_enable_arenas", nil)
|
||||
case 36:
|
||||
b = p.appendSingularField(b, "objc_class_prefix", nil)
|
||||
case 37:
|
||||
b = p.appendSingularField(b, "csharp_namespace", nil)
|
||||
case 39:
|
||||
b = p.appendSingularField(b, "swift_prefix", nil)
|
||||
case 40:
|
||||
b = p.appendSingularField(b, "php_class_prefix", nil)
|
||||
case 41:
|
||||
b = p.appendSingularField(b, "php_namespace", nil)
|
||||
case 44:
|
||||
b = p.appendSingularField(b, "php_metadata_namespace", nil)
|
||||
case 45:
|
||||
b = p.appendSingularField(b, "ruby_package", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendSourceCodeInfo(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendRepeatedField(b, "location", (*SourcePath).appendSourceCodeInfo_Location)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendDescriptorProto_ExtensionRange(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "start", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "end", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendExtensionRangeOptions)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendOneofDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendOneofOptions)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendMessageOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "message_set_wire_format", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "no_standard_descriptor_accessor", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 7:
|
||||
b = p.appendSingularField(b, "map_entry", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendDescriptorProto_ReservedRange(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "start", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "end", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendEnumValueDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "number", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendEnumValueOptions)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendEnumOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "allow_alias", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendEnumDescriptorProto_EnumReservedRange(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "start", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "end", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendMethodDescriptorProto(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "input_type", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "output_type", nil)
|
||||
case 4:
|
||||
b = p.appendSingularField(b, "options", (*SourcePath).appendMethodOptions)
|
||||
case 5:
|
||||
b = p.appendSingularField(b, "client_streaming", nil)
|
||||
case 6:
|
||||
b = p.appendSingularField(b, "server_streaming", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendServiceOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 33:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendFieldOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "ctype", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "packed", nil)
|
||||
case 6:
|
||||
b = p.appendSingularField(b, "jstype", nil)
|
||||
case 5:
|
||||
b = p.appendSingularField(b, "lazy", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 10:
|
||||
b = p.appendSingularField(b, "weak", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendUninterpretedOption(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 2:
|
||||
b = p.appendRepeatedField(b, "name", (*SourcePath).appendUninterpretedOption_NamePart)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "identifier_value", nil)
|
||||
case 4:
|
||||
b = p.appendSingularField(b, "positive_int_value", nil)
|
||||
case 5:
|
||||
b = p.appendSingularField(b, "negative_int_value", nil)
|
||||
case 6:
|
||||
b = p.appendSingularField(b, "double_value", nil)
|
||||
case 7:
|
||||
b = p.appendSingularField(b, "string_value", nil)
|
||||
case 8:
|
||||
b = p.appendSingularField(b, "aggregate_value", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendSourceCodeInfo_Location(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendRepeatedField(b, "path", nil)
|
||||
case 2:
|
||||
b = p.appendRepeatedField(b, "span", nil)
|
||||
case 3:
|
||||
b = p.appendSingularField(b, "leading_comments", nil)
|
||||
case 4:
|
||||
b = p.appendSingularField(b, "trailing_comments", nil)
|
||||
case 6:
|
||||
b = p.appendRepeatedField(b, "leading_detached_comments", nil)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendExtensionRangeOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendOneofOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendEnumValueOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendMethodOptions(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 33:
|
||||
b = p.appendSingularField(b, "deprecated", nil)
|
||||
case 34:
|
||||
b = p.appendSingularField(b, "idempotency_level", nil)
|
||||
case 999:
|
||||
b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (p *SourcePath) appendUninterpretedOption_NamePart(b []byte) []byte {
|
||||
if len(*p) == 0 {
|
||||
return b
|
||||
}
|
||||
switch (*p)[0] {
|
||||
case 1:
|
||||
b = p.appendSingularField(b, "name_part", nil)
|
||||
case 2:
|
||||
b = p.appendSingularField(b, "is_extension", nil)
|
||||
}
|
||||
return b
|
||||
}
|
34
vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
generated
vendored
34
vendor/google.golang.org/protobuf/reflect/protoreflect/type.go
generated
vendored
@@ -232,11 +232,15 @@ type MessageDescriptor interface {
|
||||
type isMessageDescriptor interface{ ProtoType(MessageDescriptor) }
|
||||
|
||||
// MessageType encapsulates a MessageDescriptor with a concrete Go implementation.
|
||||
// It is recommended that implementations of this interface also implement the
|
||||
// MessageFieldTypes interface.
|
||||
type MessageType interface {
|
||||
// New returns a newly allocated empty message.
|
||||
// It may return nil for synthetic messages representing a map entry.
|
||||
New() Message
|
||||
|
||||
// Zero returns an empty, read-only message.
|
||||
// It may return nil for synthetic messages representing a map entry.
|
||||
Zero() Message
|
||||
|
||||
// Descriptor returns the message descriptor.
|
||||
@@ -245,6 +249,26 @@ type MessageType interface {
|
||||
Descriptor() MessageDescriptor
|
||||
}
|
||||
|
||||
// MessageFieldTypes extends a MessageType by providing type information
|
||||
// regarding enums and messages referenced by the message fields.
|
||||
type MessageFieldTypes interface {
|
||||
MessageType
|
||||
|
||||
// Enum returns the EnumType for the ith field in Descriptor.Fields.
|
||||
// It returns nil if the ith field is not an enum kind.
|
||||
// It panics if out of bounds.
|
||||
//
|
||||
// Invariant: mt.Enum(i).Descriptor() == mt.Descriptor().Fields(i).Enum()
|
||||
Enum(i int) EnumType
|
||||
|
||||
// Message returns the MessageType for the ith field in Descriptor.Fields.
|
||||
// It returns nil if the ith field is not a message or group kind.
|
||||
// It panics if out of bounds.
|
||||
//
|
||||
// Invariant: mt.Message(i).Descriptor() == mt.Descriptor().Fields(i).Message()
|
||||
Message(i int) MessageType
|
||||
}
|
||||
|
||||
// MessageDescriptors is a list of message declarations.
|
||||
type MessageDescriptors interface {
|
||||
// Len reports the number of messages.
|
||||
@@ -279,8 +303,15 @@ type FieldDescriptor interface {
|
||||
|
||||
// JSONName reports the name used for JSON serialization.
|
||||
// It is usually the camel-cased form of the field name.
|
||||
// Extension fields are represented by the full name surrounded by brackets.
|
||||
JSONName() string
|
||||
|
||||
// TextName reports the name used for text serialization.
|
||||
// It is usually the name of the field, except that groups use the name
|
||||
// of the inlined message, and extension fields are represented by the
|
||||
// full name surrounded by brackets.
|
||||
TextName() string
|
||||
|
||||
// HasPresence reports whether the field distinguishes between unpopulated
|
||||
// and default values.
|
||||
HasPresence() bool
|
||||
@@ -371,6 +402,9 @@ type FieldDescriptors interface {
|
||||
// ByJSONName returns the FieldDescriptor for a field with s as the JSON name.
|
||||
// It returns nil if not found.
|
||||
ByJSONName(s string) FieldDescriptor
|
||||
// ByTextName returns the FieldDescriptor for a field with s as the text name.
|
||||
// It returns nil if not found.
|
||||
ByTextName(s string) FieldDescriptor
|
||||
// ByNumber returns the FieldDescriptor for a field numbered n.
|
||||
// It returns nil if not found.
|
||||
ByNumber(n FieldNumber) FieldDescriptor
|
||||
|
157
vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go
generated
vendored
157
vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go
generated
vendored
@@ -17,24 +17,49 @@ package protoregistry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// conflictPolicy configures the policy for handling registration conflicts.
|
||||
//
|
||||
// It can be over-written at compile time with a linker-initialized variable:
|
||||
// go build -ldflags "-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn"
|
||||
//
|
||||
// It can be over-written at program execution with an environment variable:
|
||||
// GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn ./main
|
||||
//
|
||||
// Neither of the above are covered by the compatibility promise and
|
||||
// may be removed in a future release of this module.
|
||||
var conflictPolicy = "panic" // "panic" | "warn" | "ignore"
|
||||
|
||||
// ignoreConflict reports whether to ignore a registration conflict
|
||||
// given the descriptor being registered and the error.
|
||||
// It is a variable so that the behavior is easily overridden in another file.
|
||||
var ignoreConflict = func(d protoreflect.Descriptor, err error) bool {
|
||||
log.Printf(""+
|
||||
"WARNING: %v\n"+
|
||||
"A future release will panic on registration conflicts. See:\n"+
|
||||
"https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict\n"+
|
||||
"\n", err)
|
||||
return true
|
||||
const env = "GOLANG_PROTOBUF_REGISTRATION_CONFLICT"
|
||||
const faq = "https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict"
|
||||
policy := conflictPolicy
|
||||
if v := os.Getenv(env); v != "" {
|
||||
policy = v
|
||||
}
|
||||
switch policy {
|
||||
case "panic":
|
||||
panic(fmt.Sprintf("%v\nSee %v\n", err, faq))
|
||||
case "warn":
|
||||
fmt.Fprintf(os.Stderr, "WARNING: %v\nSee %v\n\n", err, faq)
|
||||
return true
|
||||
case "ignore":
|
||||
return true
|
||||
default:
|
||||
panic("invalid " + env + " value: " + os.Getenv(env))
|
||||
}
|
||||
}
|
||||
|
||||
var globalMutex sync.RWMutex
|
||||
@@ -96,38 +121,7 @@ func (r *Files) RegisterFile(file protoreflect.FileDescriptor) error {
|
||||
}
|
||||
path := file.Path()
|
||||
if prev := r.filesByPath[path]; prev != nil {
|
||||
// TODO: Remove this after some soak-in period after moving these types.
|
||||
var prevPath string
|
||||
const prevModule = "google.golang.org/genproto"
|
||||
const prevVersion = "cb27e3aa (May 26th, 2020)"
|
||||
switch path {
|
||||
case "google/protobuf/field_mask.proto":
|
||||
prevPath = prevModule + "/protobuf/field_mask"
|
||||
case "google/protobuf/api.proto":
|
||||
prevPath = prevModule + "/protobuf/api"
|
||||
case "google/protobuf/type.proto":
|
||||
prevPath = prevModule + "/protobuf/ptype"
|
||||
case "google/protobuf/source_context.proto":
|
||||
prevPath = prevModule + "/protobuf/source_context"
|
||||
}
|
||||
if r == GlobalFiles && prevPath != "" {
|
||||
pkgName := strings.TrimSuffix(strings.TrimPrefix(path, "google/protobuf/"), ".proto")
|
||||
pkgName = strings.Replace(pkgName, "_", "", -1) + "pb"
|
||||
currPath := "google.golang.org/protobuf/types/known/" + pkgName
|
||||
panic(fmt.Sprintf(""+
|
||||
"duplicate registration of %q\n"+
|
||||
"\n"+
|
||||
"The generated definition for this file has moved:\n"+
|
||||
"\tfrom: %q\n"+
|
||||
"\tto: %q\n"+
|
||||
"A dependency on the %q module must\n"+
|
||||
"be at version %v or higher.\n"+
|
||||
"\n"+
|
||||
"Upgrade the dependency by running:\n"+
|
||||
"\tgo get -u %v\n",
|
||||
path, prevPath, currPath, prevModule, prevVersion, prevPath))
|
||||
}
|
||||
|
||||
r.checkGenProtoConflict(path)
|
||||
err := errors.New("file %q is already registered", file.Path())
|
||||
err = amendErrorWithCaller(err, prev, file)
|
||||
if r == GlobalFiles && ignoreConflict(file, err) {
|
||||
@@ -178,6 +172,47 @@ func (r *Files) RegisterFile(file protoreflect.FileDescriptor) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Several well-known types were hosted in the google.golang.org/genproto module
|
||||
// but were later moved to this module. To avoid a weak dependency on the
|
||||
// genproto module (and its relatively large set of transitive dependencies),
|
||||
// we rely on a registration conflict to determine whether the genproto version
|
||||
// is too old (i.e., does not contain aliases to the new type declarations).
|
||||
func (r *Files) checkGenProtoConflict(path string) {
|
||||
if r != GlobalFiles {
|
||||
return
|
||||
}
|
||||
var prevPath string
|
||||
const prevModule = "google.golang.org/genproto"
|
||||
const prevVersion = "cb27e3aa (May 26th, 2020)"
|
||||
switch path {
|
||||
case "google/protobuf/field_mask.proto":
|
||||
prevPath = prevModule + "/protobuf/field_mask"
|
||||
case "google/protobuf/api.proto":
|
||||
prevPath = prevModule + "/protobuf/api"
|
||||
case "google/protobuf/type.proto":
|
||||
prevPath = prevModule + "/protobuf/ptype"
|
||||
case "google/protobuf/source_context.proto":
|
||||
prevPath = prevModule + "/protobuf/source_context"
|
||||
default:
|
||||
return
|
||||
}
|
||||
pkgName := strings.TrimSuffix(strings.TrimPrefix(path, "google/protobuf/"), ".proto")
|
||||
pkgName = strings.Replace(pkgName, "_", "", -1) + "pb" // e.g., "field_mask" => "fieldmaskpb"
|
||||
currPath := "google.golang.org/protobuf/types/known/" + pkgName
|
||||
panic(fmt.Sprintf(""+
|
||||
"duplicate registration of %q\n"+
|
||||
"\n"+
|
||||
"The generated definition for this file has moved:\n"+
|
||||
"\tfrom: %q\n"+
|
||||
"\tto: %q\n"+
|
||||
"A dependency on the %q module must\n"+
|
||||
"be at version %v or higher.\n"+
|
||||
"\n"+
|
||||
"Upgrade the dependency by running:\n"+
|
||||
"\tgo get -u %v\n",
|
||||
path, prevPath, currPath, prevModule, prevVersion, prevPath))
|
||||
}
|
||||
|
||||
// FindDescriptorByName looks up a descriptor by the full name.
|
||||
//
|
||||
// This returns (nil, NotFound) if not found.
|
||||
@@ -560,13 +595,25 @@ func (r *Types) FindEnumByName(enum protoreflect.FullName) (protoreflect.EnumTyp
|
||||
return nil, NotFound
|
||||
}
|
||||
|
||||
// FindMessageByName looks up a message by its full name.
|
||||
// E.g., "google.protobuf.Any"
|
||||
// FindMessageByName looks up a message by its full name,
|
||||
// e.g. "google.protobuf.Any".
|
||||
//
|
||||
// This return (nil, NotFound) if not found.
|
||||
// This returns (nil, NotFound) if not found.
|
||||
func (r *Types) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) {
|
||||
// The full name by itself is a valid URL.
|
||||
return r.FindMessageByURL(string(message))
|
||||
if r == nil {
|
||||
return nil, NotFound
|
||||
}
|
||||
if r == GlobalTypes {
|
||||
globalMutex.RLock()
|
||||
defer globalMutex.RUnlock()
|
||||
}
|
||||
if v := r.typesByName[message]; v != nil {
|
||||
if mt, _ := v.(protoreflect.MessageType); mt != nil {
|
||||
return mt, nil
|
||||
}
|
||||
return nil, errors.New("found wrong type: got %v, want message", typeName(v))
|
||||
}
|
||||
return nil, NotFound
|
||||
}
|
||||
|
||||
// FindMessageByURL looks up a message by a URL identifier.
|
||||
@@ -574,6 +621,8 @@ func (r *Types) FindMessageByName(message protoreflect.FullName) (protoreflect.M
|
||||
//
|
||||
// This returns (nil, NotFound) if not found.
|
||||
func (r *Types) FindMessageByURL(url string) (protoreflect.MessageType, error) {
|
||||
// This function is similar to FindMessageByName but
|
||||
// truncates anything before and including '/' in the URL.
|
||||
if r == nil {
|
||||
return nil, NotFound
|
||||
}
|
||||
@@ -613,6 +662,26 @@ func (r *Types) FindExtensionByName(field protoreflect.FullName) (protoreflect.E
|
||||
if xt, _ := v.(protoreflect.ExtensionType); xt != nil {
|
||||
return xt, nil
|
||||
}
|
||||
|
||||
// MessageSet extensions are special in that the name of the extension
|
||||
// is the name of the message type used to extend the MessageSet.
|
||||
// This naming scheme is used by text and JSON serialization.
|
||||
//
|
||||
// This feature is protected by the ProtoLegacy flag since MessageSets
|
||||
// are a proto1 feature that is long deprecated.
|
||||
if flags.ProtoLegacy {
|
||||
if _, ok := v.(protoreflect.MessageType); ok {
|
||||
field := field.Append(messageset.ExtensionName)
|
||||
if v := r.typesByName[field]; v != nil {
|
||||
if xt, _ := v.(protoreflect.ExtensionType); xt != nil {
|
||||
if messageset.IsMessageSetExtension(xt.TypeDescriptor()) {
|
||||
return xt, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("found wrong type: got %v, want extension", typeName(v))
|
||||
}
|
||||
return nil, NotFound
|
||||
|
19
vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go
generated
vendored
19
vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go
generated
vendored
@@ -3557,16 +3557,15 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{
|
||||
0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x65, 0x67,
|
||||
0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x12,
|
||||
0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x6e,
|
||||
0x64, 0x42, 0x8f, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x3e, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63,
|
||||
0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x6f, 0x72, 0x3b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0xf8, 0x01, 0x01,
|
||||
0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e,
|
||||
0x64, 0x42, 0x7e, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x2d, 0x67, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x64,
|
||||
0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02,
|
||||
0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e,
|
||||
}
|
||||
|
||||
var (
|
||||
|
22
vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go
generated
vendored
22
vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go
generated
vendored
@@ -166,10 +166,13 @@ import (
|
||||
// Example 4: Pack and unpack a message in Go
|
||||
//
|
||||
// foo := &pb.Foo{...}
|
||||
// any, err := ptypes.MarshalAny(foo)
|
||||
// any, err := anypb.New(foo)
|
||||
// if err != nil {
|
||||
// ...
|
||||
// }
|
||||
// ...
|
||||
// foo := &pb.Foo{}
|
||||
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
||||
// if err := any.UnmarshalTo(foo); err != nil {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
@@ -420,14 +423,15 @@ var file_google_protobuf_any_proto_rawDesc = []byte{
|
||||
0x41, 0x6e, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x42, 0x6f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x42, 0x76, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x08, 0x41, 0x6e, 0x79,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x61, 0x6e, 0x79, 0xa2, 0x02,
|
||||
0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e,
|
||||
0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f,
|
||||
0x61, 0x6e, 0x79, 0x70, 0x62, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f,
|
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65,
|
||||
0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
20
vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go
generated
vendored
20
vendor/google.golang.org/protobuf/types/known/durationpb/duration.pb.go
generated
vendored
@@ -303,16 +303,16 @@ var file_google_protobuf_duration_proto_rawDesc = []byte{
|
||||
0x66, 0x22, 0x3a, 0x0a, 0x08, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07,
|
||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42, 0x7c, 0x0a,
|
||||
0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x42, 0x0d, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c,
|
||||
0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42, 0x83, 0x01,
|
||||
0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0d, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67,
|
||||
0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x64,
|
||||
0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47,
|
||||
0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79,
|
||||
0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
29
vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go
generated
vendored
29
vendor/google.golang.org/protobuf/types/known/timestamppb/timestamp.pb.go
generated
vendored
@@ -134,7 +134,16 @@ import (
|
||||
// .setNanos((int) ((millis % 1000) * 1000000)).build();
|
||||
//
|
||||
//
|
||||
// Example 5: Compute Timestamp from current time in Python.
|
||||
// Example 5: Compute Timestamp from Java `Instant.now()`.
|
||||
//
|
||||
// Instant now = Instant.now();
|
||||
//
|
||||
// Timestamp timestamp =
|
||||
// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
||||
// .setNanos(now.getNano()).build();
|
||||
//
|
||||
//
|
||||
// Example 6: Compute Timestamp from current time in Python.
|
||||
//
|
||||
// timestamp = Timestamp()
|
||||
// timestamp.GetCurrentTime()
|
||||
@@ -306,15 +315,15 @@ var file_google_protobuf_timestamp_proto_rawDesc = []byte{
|
||||
0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||
0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x61, 0x6e,
|
||||
0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42,
|
||||
0x7e, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
|
||||
0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x74, 0x61, 0x6d, 0x70, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02,
|
||||
0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x85, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x0e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
|
||||
0x6d, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77,
|
||||
0x6e, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x70, 0x62, 0xf8, 0x01, 0x01,
|
||||
0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f,
|
||||
0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
19
vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go
generated
vendored
19
vendor/google.golang.org/protobuf/types/known/wrapperspb/wrappers.pb.go
generated
vendored
@@ -580,15 +580,16 @@ var file_google_protobuf_wrappers_proto_rawDesc = []byte{
|
||||
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x22, 0x22, 0x0a, 0x0a, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x7c, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42,
|
||||
0x0d, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
|
||||
0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
|
||||
0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
|
||||
0x70, 0x65, 0x73, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0xf8, 0x01, 0x01, 0xa2,
|
||||
0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77,
|
||||
0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x83, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x42, 0x0d, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50,
|
||||
0x01, 0x5a, 0x31, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67,
|
||||
0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79,
|
||||
0x70, 0x65, 0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65,
|
||||
0x72, 0x73, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e,
|
||||
0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||
0x57, 0x65, 0x6c, 0x6c, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
Reference in New Issue
Block a user