Bump google.golang.org/grpc from 1.61.1 to 1.62.1
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.61.1 to 1.62.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.61.1...v1.62.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
6
go.mod
6
go.mod
@@ -15,7 +15,7 @@ require (
|
|||||||
github.com/prometheus/client_model v0.6.0
|
github.com/prometheus/client_model v0.6.0
|
||||||
github.com/prometheus/common v0.46.0
|
github.com/prometheus/common v0.46.0
|
||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cobra v1.8.0
|
||||||
google.golang.org/grpc v1.61.1
|
google.golang.org/grpc v1.62.1
|
||||||
google.golang.org/protobuf v1.32.0
|
google.golang.org/protobuf v1.32.0
|
||||||
k8s.io/api v0.29.0
|
k8s.io/api v0.29.0
|
||||||
k8s.io/apimachinery v0.29.0
|
k8s.io/apimachinery v0.29.0
|
||||||
@@ -41,7 +41,7 @@ require (
|
|||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/gnostic-models v0.6.8 // indirect
|
github.com/google/gnostic-models v0.6.8 // indirect
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/uuid v1.4.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/imdario/mergo v0.3.13 // indirect
|
github.com/imdario/mergo v0.3.13 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
github.com/josharian/intern v1.0.0 // indirect
|
||||||
@@ -64,7 +64,7 @@ require (
|
|||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
golang.org/x/time v0.3.0 // indirect
|
golang.org/x/time v0.3.0 // indirect
|
||||||
google.golang.org/appengine v1.6.8 // indirect
|
google.golang.org/appengine v1.6.8 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
20
go.sum
20
go.sum
@@ -8,8 +8,8 @@ github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM
|
|||||||
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
|
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101 h1:7To3pQ+pZo0i3dsWEbinPNFs5gPSBOsJtx3wTT94VBY=
|
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ=
|
||||||
github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM=
|
||||||
github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY=
|
github.com/container-storage-interface/spec v1.9.0 h1:zKtX4STsq31Knz3gciCYCi1SXtO2HJDecIjDVboYavY=
|
||||||
github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0=
|
github.com/container-storage-interface/spec v1.9.0/go.mod h1:ZfDu+3ZRyeVqxZM0Ds19MVLkN2d1XJ5MAfi1L3VjlT0=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
@@ -19,8 +19,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
|
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
||||||
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
|
github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
|
||||||
github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE=
|
github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew=
|
||||||
github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls=
|
github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls=
|
||||||
github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||||
@@ -59,8 +59,8 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
|||||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
|
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
|
||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
@@ -196,10 +196,10 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
|
|||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
|
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
|
||||||
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
|
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
|
||||||
google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY=
|
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
|
||||||
google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
|
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
||||||
|
530
vendor/github.com/golang/protobuf/jsonpb/decode.go
generated
vendored
530
vendor/github.com/golang/protobuf/jsonpb/decode.go
generated
vendored
@@ -1,530 +0,0 @@
|
|||||||
// Copyright 2015 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 jsonpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"math"
|
|
||||||
"reflect"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
|
||||||
protoV2 "google.golang.org/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
)
|
|
||||||
|
|
||||||
const wrapJSONUnmarshalV2 = false
|
|
||||||
|
|
||||||
// UnmarshalNext unmarshals the next JSON object from d into m.
|
|
||||||
func UnmarshalNext(d *json.Decoder, m proto.Message) error {
|
|
||||||
return new(Unmarshaler).UnmarshalNext(d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal unmarshals a JSON object from r into m.
|
|
||||||
func Unmarshal(r io.Reader, m proto.Message) error {
|
|
||||||
return new(Unmarshaler).Unmarshal(r, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalString unmarshals a JSON object from s into m.
|
|
||||||
func UnmarshalString(s string, m proto.Message) error {
|
|
||||||
return new(Unmarshaler).Unmarshal(strings.NewReader(s), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshaler is a configurable object for converting from a JSON
|
|
||||||
// representation to a protocol buffer object.
|
|
||||||
type Unmarshaler struct {
|
|
||||||
// AllowUnknownFields specifies whether to allow messages to contain
|
|
||||||
// unknown JSON fields, as opposed to failing to unmarshal.
|
|
||||||
AllowUnknownFields bool
|
|
||||||
|
|
||||||
// AnyResolver is used to resolve the google.protobuf.Any well-known type.
|
|
||||||
// If unset, the global registry is used by default.
|
|
||||||
AnyResolver AnyResolver
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONPBUnmarshaler is implemented by protobuf messages that customize the way
|
|
||||||
// they are unmarshaled from JSON. Messages that implement this should also
|
|
||||||
// implement JSONPBMarshaler so that the custom format can be produced.
|
|
||||||
//
|
|
||||||
// The JSON unmarshaling must follow the JSON to proto specification:
|
|
||||||
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
|
||||||
//
|
|
||||||
// Deprecated: Custom types should implement protobuf reflection instead.
|
|
||||||
type JSONPBUnmarshaler interface {
|
|
||||||
UnmarshalJSONPB(*Unmarshaler, []byte) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal unmarshals a JSON object from r into m.
|
|
||||||
func (u *Unmarshaler) Unmarshal(r io.Reader, m proto.Message) error {
|
|
||||||
return u.UnmarshalNext(json.NewDecoder(r), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalNext unmarshals the next JSON object from d into m.
|
|
||||||
func (u *Unmarshaler) UnmarshalNext(d *json.Decoder, m proto.Message) error {
|
|
||||||
if m == nil {
|
|
||||||
return errors.New("invalid nil message")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the next JSON object from the stream.
|
|
||||||
raw := json.RawMessage{}
|
|
||||||
if err := d.Decode(&raw); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for custom unmarshalers first since they may not properly
|
|
||||||
// implement protobuf reflection that the logic below relies on.
|
|
||||||
if jsu, ok := m.(JSONPBUnmarshaler); ok {
|
|
||||||
return jsu.UnmarshalJSONPB(u, raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
mr := proto.MessageReflect(m)
|
|
||||||
|
|
||||||
// NOTE: For historical reasons, a top-level null is treated as a noop.
|
|
||||||
// This is incorrect, but kept for compatibility.
|
|
||||||
if string(raw) == "null" && mr.Descriptor().FullName() != "google.protobuf.Value" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if wrapJSONUnmarshalV2 {
|
|
||||||
// NOTE: If input message is non-empty, we need to preserve merge semantics
|
|
||||||
// of the old jsonpb implementation. These semantics are not supported by
|
|
||||||
// the protobuf JSON specification.
|
|
||||||
isEmpty := true
|
|
||||||
mr.Range(func(protoreflect.FieldDescriptor, protoreflect.Value) bool {
|
|
||||||
isEmpty = false // at least one iteration implies non-empty
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
if !isEmpty {
|
|
||||||
// Perform unmarshaling into a newly allocated, empty message.
|
|
||||||
mr = mr.New()
|
|
||||||
|
|
||||||
// Use a defer to copy all unmarshaled fields into the original message.
|
|
||||||
dst := proto.MessageReflect(m)
|
|
||||||
defer mr.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
|
||||||
dst.Set(fd, v)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal using the v2 JSON unmarshaler.
|
|
||||||
opts := protojson.UnmarshalOptions{
|
|
||||||
DiscardUnknown: u.AllowUnknownFields,
|
|
||||||
}
|
|
||||||
if u.AnyResolver != nil {
|
|
||||||
opts.Resolver = anyResolver{u.AnyResolver}
|
|
||||||
}
|
|
||||||
return opts.Unmarshal(raw, mr.Interface())
|
|
||||||
} else {
|
|
||||||
if err := u.unmarshalMessage(mr, raw); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return protoV2.CheckInitialized(mr.Interface())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *Unmarshaler) unmarshalMessage(m protoreflect.Message, in []byte) error {
|
|
||||||
md := m.Descriptor()
|
|
||||||
fds := md.Fields()
|
|
||||||
|
|
||||||
if jsu, ok := proto.MessageV1(m.Interface()).(JSONPBUnmarshaler); ok {
|
|
||||||
return jsu.UnmarshalJSONPB(u, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
if string(in) == "null" && md.FullName() != "google.protobuf.Value" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
switch wellKnownType(md.FullName()) {
|
|
||||||
case "Any":
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
rawTypeURL, ok := jsonObject["@type"]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("Any JSON doesn't have '@type'")
|
|
||||||
}
|
|
||||||
typeURL, err := unquoteString(string(rawTypeURL))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("can't unmarshal Any's '@type': %q", rawTypeURL)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfString(typeURL))
|
|
||||||
|
|
||||||
var m2 protoreflect.Message
|
|
||||||
if u.AnyResolver != nil {
|
|
||||||
mi, err := u.AnyResolver.Resolve(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = proto.MessageReflect(mi)
|
|
||||||
} else {
|
|
||||||
mt, err := protoregistry.GlobalTypes.FindMessageByURL(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
if err == protoregistry.NotFound {
|
|
||||||
return fmt.Errorf("could not resolve Any message type: %v", typeURL)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = mt.New()
|
|
||||||
}
|
|
||||||
|
|
||||||
if wellKnownType(m2.Descriptor().FullName()) != "" {
|
|
||||||
rawValue, ok := jsonObject["value"]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("Any JSON doesn't have 'value'")
|
|
||||||
}
|
|
||||||
if err := u.unmarshalMessage(m2, rawValue); err != nil {
|
|
||||||
return fmt.Errorf("can't unmarshal Any nested proto %v: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
delete(jsonObject, "@type")
|
|
||||||
rawJSON, err := json.Marshal(jsonObject)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("can't generate JSON for Any's nested proto to be unmarshaled: %v", err)
|
|
||||||
}
|
|
||||||
if err = u.unmarshalMessage(m2, rawJSON); err != nil {
|
|
||||||
return fmt.Errorf("can't unmarshal Any nested proto %v: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rawWire, err := protoV2.Marshal(m2.Interface())
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("can't marshal proto %v into Any.Value: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfBytes(rawWire))
|
|
||||||
return nil
|
|
||||||
case "BoolValue", "BytesValue", "StringValue",
|
|
||||||
"Int32Value", "UInt32Value", "FloatValue",
|
|
||||||
"Int64Value", "UInt64Value", "DoubleValue":
|
|
||||||
fd := fds.ByNumber(1)
|
|
||||||
v, err := u.unmarshalValue(m.NewField(fd), in, fd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Set(fd, v)
|
|
||||||
return nil
|
|
||||||
case "Duration":
|
|
||||||
v, err := unquoteString(string(in))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
d, err := time.ParseDuration(v)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("bad Duration: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
sec := d.Nanoseconds() / 1e9
|
|
||||||
nsec := d.Nanoseconds() % 1e9
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfInt64(int64(sec)))
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfInt32(int32(nsec)))
|
|
||||||
return nil
|
|
||||||
case "Timestamp":
|
|
||||||
v, err := unquoteString(string(in))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
t, err := time.Parse(time.RFC3339Nano, v)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("bad Timestamp: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
sec := t.Unix()
|
|
||||||
nsec := t.Nanosecond()
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfInt64(int64(sec)))
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfInt32(int32(nsec)))
|
|
||||||
return nil
|
|
||||||
case "Value":
|
|
||||||
switch {
|
|
||||||
case string(in) == "null":
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfEnum(0))
|
|
||||||
case string(in) == "true":
|
|
||||||
m.Set(fds.ByNumber(4), protoreflect.ValueOfBool(true))
|
|
||||||
case string(in) == "false":
|
|
||||||
m.Set(fds.ByNumber(4), protoreflect.ValueOfBool(false))
|
|
||||||
case hasPrefixAndSuffix('"', in, '"'):
|
|
||||||
s, err := unquoteString(string(in))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unrecognized type for Value %q", in)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(3), protoreflect.ValueOfString(s))
|
|
||||||
case hasPrefixAndSuffix('[', in, ']'):
|
|
||||||
v := m.Mutable(fds.ByNumber(6))
|
|
||||||
return u.unmarshalMessage(v.Message(), in)
|
|
||||||
case hasPrefixAndSuffix('{', in, '}'):
|
|
||||||
v := m.Mutable(fds.ByNumber(5))
|
|
||||||
return u.unmarshalMessage(v.Message(), in)
|
|
||||||
default:
|
|
||||||
f, err := strconv.ParseFloat(string(in), 0)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unrecognized type for Value %q", in)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfFloat64(f))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case "ListValue":
|
|
||||||
var jsonArray []json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonArray); err != nil {
|
|
||||||
return fmt.Errorf("bad ListValue: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
lv := m.Mutable(fds.ByNumber(1)).List()
|
|
||||||
for _, raw := range jsonArray {
|
|
||||||
ve := lv.NewElement()
|
|
||||||
if err := u.unmarshalMessage(ve.Message(), raw); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
lv.Append(ve)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case "Struct":
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return fmt.Errorf("bad StructValue: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
mv := m.Mutable(fds.ByNumber(1)).Map()
|
|
||||||
for key, raw := range jsonObject {
|
|
||||||
kv := protoreflect.ValueOf(key).MapKey()
|
|
||||||
vv := mv.NewValue()
|
|
||||||
if err := u.unmarshalMessage(vv.Message(), raw); err != nil {
|
|
||||||
return fmt.Errorf("bad value in StructValue for key %q: %v", key, err)
|
|
||||||
}
|
|
||||||
mv.Set(kv, vv)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle known fields.
|
|
||||||
for i := 0; i < fds.Len(); i++ {
|
|
||||||
fd := fds.Get(i)
|
|
||||||
if fd.IsWeak() && fd.Message().IsPlaceholder() {
|
|
||||||
continue // weak reference is not linked in
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for any raw JSON value associated with this field.
|
|
||||||
var raw json.RawMessage
|
|
||||||
name := string(fd.Name())
|
|
||||||
if fd.Kind() == protoreflect.GroupKind {
|
|
||||||
name = string(fd.Message().Name())
|
|
||||||
}
|
|
||||||
if v, ok := jsonObject[name]; ok {
|
|
||||||
delete(jsonObject, name)
|
|
||||||
raw = v
|
|
||||||
}
|
|
||||||
name = string(fd.JSONName())
|
|
||||||
if v, ok := jsonObject[name]; ok {
|
|
||||||
delete(jsonObject, name)
|
|
||||||
raw = v
|
|
||||||
}
|
|
||||||
|
|
||||||
field := m.NewField(fd)
|
|
||||||
// Unmarshal the field value.
|
|
||||||
if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd) && !isSingularJSONPBUnmarshaler(field, fd)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
v, err := u.unmarshalValue(field, raw, fd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Set(fd, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle extension fields.
|
|
||||||
for name, raw := range jsonObject {
|
|
||||||
if !strings.HasPrefix(name, "[") || !strings.HasSuffix(name, "]") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve the extension field by name.
|
|
||||||
xname := protoreflect.FullName(name[len("[") : len(name)-len("]")])
|
|
||||||
xt, _ := protoregistry.GlobalTypes.FindExtensionByName(xname)
|
|
||||||
if xt == nil && isMessageSet(md) {
|
|
||||||
xt, _ = protoregistry.GlobalTypes.FindExtensionByName(xname.Append("message_set_extension"))
|
|
||||||
}
|
|
||||||
if xt == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
delete(jsonObject, name)
|
|
||||||
fd := xt.TypeDescriptor()
|
|
||||||
if fd.ContainingMessage().FullName() != m.Descriptor().FullName() {
|
|
||||||
return fmt.Errorf("extension field %q does not extend message %q", xname, m.Descriptor().FullName())
|
|
||||||
}
|
|
||||||
|
|
||||||
field := m.NewField(fd)
|
|
||||||
// Unmarshal the field value.
|
|
||||||
if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd) && !isSingularJSONPBUnmarshaler(field, fd)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
v, err := u.unmarshalValue(field, raw, fd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Set(fd, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !u.AllowUnknownFields && len(jsonObject) > 0 {
|
|
||||||
for name := range jsonObject {
|
|
||||||
return fmt.Errorf("unknown field %q in %v", name, md.FullName())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func isSingularWellKnownValue(fd protoreflect.FieldDescriptor) bool {
|
|
||||||
if fd.Cardinality() == protoreflect.Repeated {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if md := fd.Message(); md != nil {
|
|
||||||
return md.FullName() == "google.protobuf.Value"
|
|
||||||
}
|
|
||||||
if ed := fd.Enum(); ed != nil {
|
|
||||||
return ed.FullName() == "google.protobuf.NullValue"
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func isSingularJSONPBUnmarshaler(v protoreflect.Value, fd protoreflect.FieldDescriptor) bool {
|
|
||||||
if fd.Message() != nil && fd.Cardinality() != protoreflect.Repeated {
|
|
||||||
_, ok := proto.MessageV1(v.Interface()).(JSONPBUnmarshaler)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *Unmarshaler) unmarshalValue(v protoreflect.Value, in []byte, fd protoreflect.FieldDescriptor) (protoreflect.Value, error) {
|
|
||||||
switch {
|
|
||||||
case fd.IsList():
|
|
||||||
var jsonArray []json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonArray); err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
lv := v.List()
|
|
||||||
for _, raw := range jsonArray {
|
|
||||||
ve, err := u.unmarshalSingularValue(lv.NewElement(), raw, fd)
|
|
||||||
if err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
lv.Append(ve)
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
case fd.IsMap():
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
kfd := fd.MapKey()
|
|
||||||
vfd := fd.MapValue()
|
|
||||||
mv := v.Map()
|
|
||||||
for key, raw := range jsonObject {
|
|
||||||
var kv protoreflect.MapKey
|
|
||||||
if kfd.Kind() == protoreflect.StringKind {
|
|
||||||
kv = protoreflect.ValueOf(key).MapKey()
|
|
||||||
} else {
|
|
||||||
v, err := u.unmarshalSingularValue(kfd.Default(), []byte(key), kfd)
|
|
||||||
if err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
kv = v.MapKey()
|
|
||||||
}
|
|
||||||
|
|
||||||
vv, err := u.unmarshalSingularValue(mv.NewValue(), raw, vfd)
|
|
||||||
if err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
mv.Set(kv, vv)
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
default:
|
|
||||||
return u.unmarshalSingularValue(v, in, fd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var nonFinite = map[string]float64{
|
|
||||||
`"NaN"`: math.NaN(),
|
|
||||||
`"Infinity"`: math.Inf(+1),
|
|
||||||
`"-Infinity"`: math.Inf(-1),
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *Unmarshaler) unmarshalSingularValue(v protoreflect.Value, in []byte, fd protoreflect.FieldDescriptor) (protoreflect.Value, error) {
|
|
||||||
switch fd.Kind() {
|
|
||||||
case protoreflect.BoolKind:
|
|
||||||
return unmarshalValue(in, new(bool))
|
|
||||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(int32))
|
|
||||||
case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(int64))
|
|
||||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(uint32))
|
|
||||||
case protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(uint64))
|
|
||||||
case protoreflect.FloatKind:
|
|
||||||
if f, ok := nonFinite[string(in)]; ok {
|
|
||||||
return protoreflect.ValueOfFloat32(float32(f)), nil
|
|
||||||
}
|
|
||||||
return unmarshalValue(trimQuote(in), new(float32))
|
|
||||||
case protoreflect.DoubleKind:
|
|
||||||
if f, ok := nonFinite[string(in)]; ok {
|
|
||||||
return protoreflect.ValueOfFloat64(float64(f)), nil
|
|
||||||
}
|
|
||||||
return unmarshalValue(trimQuote(in), new(float64))
|
|
||||||
case protoreflect.StringKind:
|
|
||||||
return unmarshalValue(in, new(string))
|
|
||||||
case protoreflect.BytesKind:
|
|
||||||
return unmarshalValue(in, new([]byte))
|
|
||||||
case protoreflect.EnumKind:
|
|
||||||
if hasPrefixAndSuffix('"', in, '"') {
|
|
||||||
vd := fd.Enum().Values().ByName(protoreflect.Name(trimQuote(in)))
|
|
||||||
if vd == nil {
|
|
||||||
return v, fmt.Errorf("unknown value %q for enum %s", in, fd.Enum().FullName())
|
|
||||||
}
|
|
||||||
return protoreflect.ValueOfEnum(vd.Number()), nil
|
|
||||||
}
|
|
||||||
return unmarshalValue(in, new(protoreflect.EnumNumber))
|
|
||||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
|
||||||
err := u.unmarshalMessage(v.Message(), in)
|
|
||||||
return v, err
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprintf("invalid kind %v", fd.Kind()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func unmarshalValue(in []byte, v interface{}) (protoreflect.Value, error) {
|
|
||||||
err := json.Unmarshal(in, v)
|
|
||||||
return protoreflect.ValueOf(reflect.ValueOf(v).Elem().Interface()), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func unquoteString(in string) (out string, err error) {
|
|
||||||
err = json.Unmarshal([]byte(in), &out)
|
|
||||||
return out, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func hasPrefixAndSuffix(prefix byte, in []byte, suffix byte) bool {
|
|
||||||
if len(in) >= 2 && in[0] == prefix && in[len(in)-1] == suffix {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// trimQuote is like unquoteString but simply strips surrounding quotes.
|
|
||||||
// This is incorrect, but is behavior done by the legacy implementation.
|
|
||||||
func trimQuote(in []byte) []byte {
|
|
||||||
if len(in) >= 2 && in[0] == '"' && in[len(in)-1] == '"' {
|
|
||||||
in = in[1 : len(in)-1]
|
|
||||||
}
|
|
||||||
return in
|
|
||||||
}
|
|
559
vendor/github.com/golang/protobuf/jsonpb/encode.go
generated
vendored
559
vendor/github.com/golang/protobuf/jsonpb/encode.go
generated
vendored
@@ -1,559 +0,0 @@
|
|||||||
// Copyright 2015 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 jsonpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"math"
|
|
||||||
"reflect"
|
|
||||||
"sort"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
|
||||||
protoV2 "google.golang.org/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
)
|
|
||||||
|
|
||||||
const wrapJSONMarshalV2 = false
|
|
||||||
|
|
||||||
// Marshaler is a configurable object for marshaling protocol buffer messages
|
|
||||||
// to the specified JSON representation.
|
|
||||||
type Marshaler struct {
|
|
||||||
// OrigName specifies whether to use the original protobuf name for fields.
|
|
||||||
OrigName bool
|
|
||||||
|
|
||||||
// EnumsAsInts specifies whether to render enum values as integers,
|
|
||||||
// as opposed to string values.
|
|
||||||
EnumsAsInts bool
|
|
||||||
|
|
||||||
// EmitDefaults specifies whether to render fields with zero values.
|
|
||||||
EmitDefaults bool
|
|
||||||
|
|
||||||
// Indent controls whether the output is compact or not.
|
|
||||||
// If empty, the output is compact JSON. Otherwise, every JSON object
|
|
||||||
// entry and JSON array value will be on its own line.
|
|
||||||
// Each line will be preceded by repeated copies of Indent, where the
|
|
||||||
// number of copies is the current indentation depth.
|
|
||||||
Indent string
|
|
||||||
|
|
||||||
// AnyResolver is used to resolve the google.protobuf.Any well-known type.
|
|
||||||
// If unset, the global registry is used by default.
|
|
||||||
AnyResolver AnyResolver
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONPBMarshaler is implemented by protobuf messages that customize the
|
|
||||||
// way they are marshaled to JSON. Messages that implement this should also
|
|
||||||
// implement JSONPBUnmarshaler so that the custom format can be parsed.
|
|
||||||
//
|
|
||||||
// The JSON marshaling must follow the proto to JSON specification:
|
|
||||||
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
|
||||||
//
|
|
||||||
// Deprecated: Custom types should implement protobuf reflection instead.
|
|
||||||
type JSONPBMarshaler interface {
|
|
||||||
MarshalJSONPB(*Marshaler) ([]byte, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Marshal serializes a protobuf message as JSON into w.
|
|
||||||
func (jm *Marshaler) Marshal(w io.Writer, m proto.Message) error {
|
|
||||||
b, err := jm.marshal(m)
|
|
||||||
if len(b) > 0 {
|
|
||||||
if _, err := w.Write(b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalToString serializes a protobuf message as JSON in string form.
|
|
||||||
func (jm *Marshaler) MarshalToString(m proto.Message) (string, error) {
|
|
||||||
b, err := jm.marshal(m)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return string(b), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (jm *Marshaler) marshal(m proto.Message) ([]byte, error) {
|
|
||||||
v := reflect.ValueOf(m)
|
|
||||||
if m == nil || (v.Kind() == reflect.Ptr && v.IsNil()) {
|
|
||||||
return nil, errors.New("Marshal called with nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for custom marshalers first since they may not properly
|
|
||||||
// implement protobuf reflection that the logic below relies on.
|
|
||||||
if jsm, ok := m.(JSONPBMarshaler); ok {
|
|
||||||
return jsm.MarshalJSONPB(jm)
|
|
||||||
}
|
|
||||||
|
|
||||||
if wrapJSONMarshalV2 {
|
|
||||||
opts := protojson.MarshalOptions{
|
|
||||||
UseProtoNames: jm.OrigName,
|
|
||||||
UseEnumNumbers: jm.EnumsAsInts,
|
|
||||||
EmitUnpopulated: jm.EmitDefaults,
|
|
||||||
Indent: jm.Indent,
|
|
||||||
}
|
|
||||||
if jm.AnyResolver != nil {
|
|
||||||
opts.Resolver = anyResolver{jm.AnyResolver}
|
|
||||||
}
|
|
||||||
return opts.Marshal(proto.MessageReflect(m).Interface())
|
|
||||||
} else {
|
|
||||||
// Check for unpopulated required fields first.
|
|
||||||
m2 := proto.MessageReflect(m)
|
|
||||||
if err := protoV2.CheckInitialized(m2.Interface()); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
w := jsonWriter{Marshaler: jm}
|
|
||||||
err := w.marshalMessage(m2, "", "")
|
|
||||||
return w.buf, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type jsonWriter struct {
|
|
||||||
*Marshaler
|
|
||||||
buf []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) write(s string) {
|
|
||||||
w.buf = append(w.buf, s...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalMessage(m protoreflect.Message, indent, typeURL string) error {
|
|
||||||
if jsm, ok := proto.MessageV1(m.Interface()).(JSONPBMarshaler); ok {
|
|
||||||
b, err := jsm.MarshalJSONPB(w.Marshaler)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if typeURL != "" {
|
|
||||||
// we are marshaling this object to an Any type
|
|
||||||
var js map[string]*json.RawMessage
|
|
||||||
if err = json.Unmarshal(b, &js); err != nil {
|
|
||||||
return fmt.Errorf("type %T produced invalid JSON: %v", m.Interface(), err)
|
|
||||||
}
|
|
||||||
turl, err := json.Marshal(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to marshal type URL %q to JSON: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
js["@type"] = (*json.RawMessage)(&turl)
|
|
||||||
if b, err = json.Marshal(js); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
md := m.Descriptor()
|
|
||||||
fds := md.Fields()
|
|
||||||
|
|
||||||
// Handle well-known types.
|
|
||||||
const secondInNanos = int64(time.Second / time.Nanosecond)
|
|
||||||
switch wellKnownType(md.FullName()) {
|
|
||||||
case "Any":
|
|
||||||
return w.marshalAny(m, indent)
|
|
||||||
case "BoolValue", "BytesValue", "StringValue",
|
|
||||||
"Int32Value", "UInt32Value", "FloatValue",
|
|
||||||
"Int64Value", "UInt64Value", "DoubleValue":
|
|
||||||
fd := fds.ByNumber(1)
|
|
||||||
return w.marshalValue(fd, m.Get(fd), indent)
|
|
||||||
case "Duration":
|
|
||||||
const maxSecondsInDuration = 315576000000
|
|
||||||
// "Generated output always contains 0, 3, 6, or 9 fractional digits,
|
|
||||||
// depending on required precision."
|
|
||||||
s := m.Get(fds.ByNumber(1)).Int()
|
|
||||||
ns := m.Get(fds.ByNumber(2)).Int()
|
|
||||||
if s < -maxSecondsInDuration || s > maxSecondsInDuration {
|
|
||||||
return fmt.Errorf("seconds out of range %v", s)
|
|
||||||
}
|
|
||||||
if ns <= -secondInNanos || ns >= secondInNanos {
|
|
||||||
return fmt.Errorf("ns out of range (%v, %v)", -secondInNanos, secondInNanos)
|
|
||||||
}
|
|
||||||
if (s > 0 && ns < 0) || (s < 0 && ns > 0) {
|
|
||||||
return errors.New("signs of seconds and nanos do not match")
|
|
||||||
}
|
|
||||||
var sign string
|
|
||||||
if s < 0 || ns < 0 {
|
|
||||||
sign, s, ns = "-", -1*s, -1*ns
|
|
||||||
}
|
|
||||||
x := fmt.Sprintf("%s%d.%09d", sign, s, ns)
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, ".000")
|
|
||||||
w.write(fmt.Sprintf(`"%vs"`, x))
|
|
||||||
return nil
|
|
||||||
case "Timestamp":
|
|
||||||
// "RFC 3339, where generated output will always be Z-normalized
|
|
||||||
// and uses 0, 3, 6 or 9 fractional digits."
|
|
||||||
s := m.Get(fds.ByNumber(1)).Int()
|
|
||||||
ns := m.Get(fds.ByNumber(2)).Int()
|
|
||||||
if ns < 0 || ns >= secondInNanos {
|
|
||||||
return fmt.Errorf("ns out of range [0, %v)", secondInNanos)
|
|
||||||
}
|
|
||||||
t := time.Unix(s, ns).UTC()
|
|
||||||
// time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits).
|
|
||||||
x := t.Format("2006-01-02T15:04:05.000000000")
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, ".000")
|
|
||||||
w.write(fmt.Sprintf(`"%vZ"`, x))
|
|
||||||
return nil
|
|
||||||
case "Value":
|
|
||||||
// JSON value; which is a null, number, string, bool, object, or array.
|
|
||||||
od := md.Oneofs().Get(0)
|
|
||||||
fd := m.WhichOneof(od)
|
|
||||||
if fd == nil {
|
|
||||||
return errors.New("nil Value")
|
|
||||||
}
|
|
||||||
return w.marshalValue(fd, m.Get(fd), indent)
|
|
||||||
case "Struct", "ListValue":
|
|
||||||
// JSON object or array.
|
|
||||||
fd := fds.ByNumber(1)
|
|
||||||
return w.marshalValue(fd, m.Get(fd), indent)
|
|
||||||
}
|
|
||||||
|
|
||||||
w.write("{")
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
firstField := true
|
|
||||||
if typeURL != "" {
|
|
||||||
if err := w.marshalTypeURL(indent, typeURL); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
firstField = false
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < fds.Len(); {
|
|
||||||
fd := fds.Get(i)
|
|
||||||
if od := fd.ContainingOneof(); od != nil {
|
|
||||||
fd = m.WhichOneof(od)
|
|
||||||
i += od.Fields().Len()
|
|
||||||
if fd == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
v := m.Get(fd)
|
|
||||||
|
|
||||||
if !m.Has(fd) {
|
|
||||||
if !w.EmitDefaults || fd.ContainingOneof() != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if fd.Cardinality() != protoreflect.Repeated && (fd.Message() != nil || fd.Syntax() == protoreflect.Proto2) {
|
|
||||||
v = protoreflect.Value{} // use "null" for singular messages or proto2 scalars
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !firstField {
|
|
||||||
w.writeComma()
|
|
||||||
}
|
|
||||||
if err := w.marshalField(fd, v, indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
firstField = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle proto2 extensions.
|
|
||||||
if md.ExtensionRanges().Len() > 0 {
|
|
||||||
// Collect a sorted list of all extension descriptor and values.
|
|
||||||
type ext struct {
|
|
||||||
desc protoreflect.FieldDescriptor
|
|
||||||
val protoreflect.Value
|
|
||||||
}
|
|
||||||
var exts []ext
|
|
||||||
m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
|
||||||
if fd.IsExtension() {
|
|
||||||
exts = append(exts, ext{fd, v})
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
sort.Slice(exts, func(i, j int) bool {
|
|
||||||
return exts[i].desc.Number() < exts[j].desc.Number()
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, ext := range exts {
|
|
||||||
if !firstField {
|
|
||||||
w.writeComma()
|
|
||||||
}
|
|
||||||
if err := w.marshalField(ext.desc, ext.val, indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
firstField = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
}
|
|
||||||
w.write("}")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) writeComma() {
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(",\n")
|
|
||||||
} else {
|
|
||||||
w.write(",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalAny(m protoreflect.Message, indent string) error {
|
|
||||||
// "If the Any contains a value that has a special JSON mapping,
|
|
||||||
// it will be converted as follows: {"@type": xxx, "value": yyy}.
|
|
||||||
// Otherwise, the value will be converted into a JSON object,
|
|
||||||
// and the "@type" field will be inserted to indicate the actual data type."
|
|
||||||
md := m.Descriptor()
|
|
||||||
typeURL := m.Get(md.Fields().ByNumber(1)).String()
|
|
||||||
rawVal := m.Get(md.Fields().ByNumber(2)).Bytes()
|
|
||||||
|
|
||||||
var m2 protoreflect.Message
|
|
||||||
if w.AnyResolver != nil {
|
|
||||||
mi, err := w.AnyResolver.Resolve(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = proto.MessageReflect(mi)
|
|
||||||
} else {
|
|
||||||
mt, err := protoregistry.GlobalTypes.FindMessageByURL(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = mt.New()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := protoV2.Unmarshal(rawVal, m2.Interface()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if wellKnownType(m2.Descriptor().FullName()) == "" {
|
|
||||||
return w.marshalMessage(m2, indent, typeURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
w.write("{")
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
}
|
|
||||||
if err := w.marshalTypeURL(indent, typeURL); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.writeComma()
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
w.write(`"value": `)
|
|
||||||
} else {
|
|
||||||
w.write(`"value":`)
|
|
||||||
}
|
|
||||||
if err := w.marshalMessage(m2, indent+w.Indent, ""); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
}
|
|
||||||
w.write("}")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalTypeURL(indent, typeURL string) error {
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write(`"@type":`)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(" ")
|
|
||||||
}
|
|
||||||
b, err := json.Marshal(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// marshalField writes field description and value to the Writer.
|
|
||||||
func (w *jsonWriter) marshalField(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error {
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write(`"`)
|
|
||||||
switch {
|
|
||||||
case fd.IsExtension():
|
|
||||||
// For message set, use the fname of the message as the extension name.
|
|
||||||
name := string(fd.FullName())
|
|
||||||
if isMessageSet(fd.ContainingMessage()) {
|
|
||||||
name = strings.TrimSuffix(name, ".message_set_extension")
|
|
||||||
}
|
|
||||||
|
|
||||||
w.write("[" + name + "]")
|
|
||||||
case w.OrigName:
|
|
||||||
name := string(fd.Name())
|
|
||||||
if fd.Kind() == protoreflect.GroupKind {
|
|
||||||
name = string(fd.Message().Name())
|
|
||||||
}
|
|
||||||
w.write(name)
|
|
||||||
default:
|
|
||||||
w.write(string(fd.JSONName()))
|
|
||||||
}
|
|
||||||
w.write(`":`)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(" ")
|
|
||||||
}
|
|
||||||
return w.marshalValue(fd, v, indent)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalValue(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error {
|
|
||||||
switch {
|
|
||||||
case fd.IsList():
|
|
||||||
w.write("[")
|
|
||||||
comma := ""
|
|
||||||
lv := v.List()
|
|
||||||
for i := 0; i < lv.Len(); i++ {
|
|
||||||
w.write(comma)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
if err := w.marshalSingularValue(fd, lv.Get(i), indent+w.Indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
comma = ","
|
|
||||||
}
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write("]")
|
|
||||||
return nil
|
|
||||||
case fd.IsMap():
|
|
||||||
kfd := fd.MapKey()
|
|
||||||
vfd := fd.MapValue()
|
|
||||||
mv := v.Map()
|
|
||||||
|
|
||||||
// Collect a sorted list of all map keys and values.
|
|
||||||
type entry struct{ key, val protoreflect.Value }
|
|
||||||
var entries []entry
|
|
||||||
mv.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool {
|
|
||||||
entries = append(entries, entry{k.Value(), v})
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
sort.Slice(entries, func(i, j int) bool {
|
|
||||||
switch kfd.Kind() {
|
|
||||||
case protoreflect.BoolKind:
|
|
||||||
return !entries[i].key.Bool() && entries[j].key.Bool()
|
|
||||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind, protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
|
||||||
return entries[i].key.Int() < entries[j].key.Int()
|
|
||||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind, protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
|
||||||
return entries[i].key.Uint() < entries[j].key.Uint()
|
|
||||||
case protoreflect.StringKind:
|
|
||||||
return entries[i].key.String() < entries[j].key.String()
|
|
||||||
default:
|
|
||||||
panic("invalid kind")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
w.write(`{`)
|
|
||||||
comma := ""
|
|
||||||
for _, entry := range entries {
|
|
||||||
w.write(comma)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
|
|
||||||
s := fmt.Sprint(entry.key.Interface())
|
|
||||||
b, err := json.Marshal(s)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
|
|
||||||
w.write(`:`)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(` `)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := w.marshalSingularValue(vfd, entry.val, indent+w.Indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
comma = ","
|
|
||||||
}
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write(`}`)
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return w.marshalSingularValue(fd, v, indent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalSingularValue(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error {
|
|
||||||
switch {
|
|
||||||
case !v.IsValid():
|
|
||||||
w.write("null")
|
|
||||||
return nil
|
|
||||||
case fd.Message() != nil:
|
|
||||||
return w.marshalMessage(v.Message(), indent+w.Indent, "")
|
|
||||||
case fd.Enum() != nil:
|
|
||||||
if fd.Enum().FullName() == "google.protobuf.NullValue" {
|
|
||||||
w.write("null")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
vd := fd.Enum().Values().ByNumber(v.Enum())
|
|
||||||
if vd == nil || w.EnumsAsInts {
|
|
||||||
w.write(strconv.Itoa(int(v.Enum())))
|
|
||||||
} else {
|
|
||||||
w.write(`"` + string(vd.Name()) + `"`)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
switch v.Interface().(type) {
|
|
||||||
case float32, float64:
|
|
||||||
switch {
|
|
||||||
case math.IsInf(v.Float(), +1):
|
|
||||||
w.write(`"Infinity"`)
|
|
||||||
return nil
|
|
||||||
case math.IsInf(v.Float(), -1):
|
|
||||||
w.write(`"-Infinity"`)
|
|
||||||
return nil
|
|
||||||
case math.IsNaN(v.Float()):
|
|
||||||
w.write(`"NaN"`)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
case int64, uint64:
|
|
||||||
w.write(fmt.Sprintf(`"%d"`, v.Interface()))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := json.Marshal(v.Interface())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
69
vendor/github.com/golang/protobuf/jsonpb/json.go
generated
vendored
69
vendor/github.com/golang/protobuf/jsonpb/json.go
generated
vendored
@@ -1,69 +0,0 @@
|
|||||||
// Copyright 2015 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 jsonpb provides functionality to marshal and unmarshal between a
|
|
||||||
// protocol buffer message and JSON. It follows the specification at
|
|
||||||
// https://developers.google.com/protocol-buffers/docs/proto3#json.
|
|
||||||
//
|
|
||||||
// Do not rely on the default behavior of the standard encoding/json package
|
|
||||||
// when called on generated message types as it does not operate correctly.
|
|
||||||
//
|
|
||||||
// Deprecated: Use the "google.golang.org/protobuf/encoding/protojson"
|
|
||||||
// package instead.
|
|
||||||
package jsonpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
"google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AnyResolver takes a type URL, present in an Any message,
|
|
||||||
// and resolves it into an instance of the associated message.
|
|
||||||
type AnyResolver interface {
|
|
||||||
Resolve(typeURL string) (proto.Message, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type anyResolver struct{ AnyResolver }
|
|
||||||
|
|
||||||
func (r anyResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) {
|
|
||||||
return r.FindMessageByURL(string(message))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r anyResolver) FindMessageByURL(url string) (protoreflect.MessageType, error) {
|
|
||||||
m, err := r.Resolve(url)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return protoimpl.X.MessageTypeOf(m), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r anyResolver) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error) {
|
|
||||||
return protoregistry.GlobalTypes.FindExtensionByName(field)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r anyResolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) {
|
|
||||||
return protoregistry.GlobalTypes.FindExtensionByNumber(message, field)
|
|
||||||
}
|
|
||||||
|
|
||||||
func wellKnownType(s protoreflect.FullName) string {
|
|
||||||
if s.Parent() == "google.protobuf" {
|
|
||||||
switch s.Name() {
|
|
||||||
case "Empty", "Any",
|
|
||||||
"BoolValue", "BytesValue", "StringValue",
|
|
||||||
"Int32Value", "UInt32Value", "FloatValue",
|
|
||||||
"Int64Value", "UInt64Value", "DoubleValue",
|
|
||||||
"Duration", "Timestamp",
|
|
||||||
"NullValue", "Struct", "Value", "ListValue":
|
|
||||||
return string(s.Name())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func isMessageSet(md protoreflect.MessageDescriptor) bool {
|
|
||||||
ms, ok := md.(interface{ IsMessageSet() bool })
|
|
||||||
return ok && ms.IsMessageSet()
|
|
||||||
}
|
|
20
vendor/github.com/google/uuid/CHANGELOG.md
generated
vendored
20
vendor/github.com/google/uuid/CHANGELOG.md
generated
vendored
@@ -1,5 +1,25 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.6.0](https://github.com/google/uuid/compare/v1.5.0...v1.6.0) (2024-01-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add Max UUID constant ([#149](https://github.com/google/uuid/issues/149)) ([c58770e](https://github.com/google/uuid/commit/c58770eb495f55fe2ced6284f93c5158a62e53e3))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix typo in version 7 uuid documentation ([#153](https://github.com/google/uuid/issues/153)) ([016b199](https://github.com/google/uuid/commit/016b199544692f745ffc8867b914129ecb47ef06))
|
||||||
|
* Monotonicity in UUIDv7 ([#150](https://github.com/google/uuid/issues/150)) ([a2b2b32](https://github.com/google/uuid/commit/a2b2b32373ff0b1a312b7fdf6d38a977099698a6))
|
||||||
|
|
||||||
|
## [1.5.0](https://github.com/google/uuid/compare/v1.4.0...v1.5.0) (2023-12-12)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Validate UUID without creating new UUID ([#141](https://github.com/google/uuid/issues/141)) ([9ee7366](https://github.com/google/uuid/commit/9ee7366e66c9ad96bab89139418a713dc584ae29))
|
||||||
|
|
||||||
## [1.4.0](https://github.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26)
|
## [1.4.0](https://github.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26)
|
||||||
|
|
||||||
|
|
||||||
|
6
vendor/github.com/google/uuid/hash.go
generated
vendored
6
vendor/github.com/google/uuid/hash.go
generated
vendored
@@ -17,6 +17,12 @@ var (
|
|||||||
NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"))
|
NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8"))
|
||||||
NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
|
NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
|
||||||
Nil UUID // empty UUID, all zeros
|
Nil UUID // empty UUID, all zeros
|
||||||
|
|
||||||
|
// The Max UUID is special form of UUID that is specified to have all 128 bits set to 1.
|
||||||
|
Max = UUID{
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewHash returns a new UUID derived from the hash of space concatenated with
|
// NewHash returns a new UUID derived from the hash of space concatenated with
|
||||||
|
15
vendor/github.com/google/uuid/time.go
generated
vendored
15
vendor/github.com/google/uuid/time.go
generated
vendored
@@ -108,12 +108,23 @@ func setClockSequence(seq int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in
|
// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in
|
||||||
// uuid. The time is only defined for version 1 and 2 UUIDs.
|
// uuid. The time is only defined for version 1, 2, 6 and 7 UUIDs.
|
||||||
func (uuid UUID) Time() Time {
|
func (uuid UUID) Time() Time {
|
||||||
|
var t Time
|
||||||
|
switch uuid.Version() {
|
||||||
|
case 6:
|
||||||
|
time := binary.BigEndian.Uint64(uuid[:8]) // Ignore uuid[6] version b0110
|
||||||
|
t = Time(time)
|
||||||
|
case 7:
|
||||||
|
time := binary.BigEndian.Uint64(uuid[:8])
|
||||||
|
t = Time((time>>16)*10000 + g1582ns100)
|
||||||
|
default: // forward compatible
|
||||||
time := int64(binary.BigEndian.Uint32(uuid[0:4]))
|
time := int64(binary.BigEndian.Uint32(uuid[0:4]))
|
||||||
time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
|
time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
|
||||||
time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
|
time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
|
||||||
return Time(time)
|
t = Time(time)
|
||||||
|
}
|
||||||
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClockSequence returns the clock sequence encoded in uuid.
|
// ClockSequence returns the clock sequence encoded in uuid.
|
||||||
|
53
vendor/github.com/google/uuid/uuid.go
generated
vendored
53
vendor/github.com/google/uuid/uuid.go
generated
vendored
@@ -186,6 +186,59 @@ func Must(uuid UUID, err error) UUID {
|
|||||||
return uuid
|
return uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate returns an error if s is not a properly formatted UUID in one of the following formats:
|
||||||
|
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||||
|
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||||
|
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
// {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
|
||||||
|
// It returns an error if the format is invalid, otherwise nil.
|
||||||
|
func Validate(s string) error {
|
||||||
|
switch len(s) {
|
||||||
|
// Standard UUID format
|
||||||
|
case 36:
|
||||||
|
|
||||||
|
// UUID with "urn:uuid:" prefix
|
||||||
|
case 36 + 9:
|
||||||
|
if !strings.EqualFold(s[:9], "urn:uuid:") {
|
||||||
|
return fmt.Errorf("invalid urn prefix: %q", s[:9])
|
||||||
|
}
|
||||||
|
s = s[9:]
|
||||||
|
|
||||||
|
// UUID enclosed in braces
|
||||||
|
case 36 + 2:
|
||||||
|
if s[0] != '{' || s[len(s)-1] != '}' {
|
||||||
|
return fmt.Errorf("invalid bracketed UUID format")
|
||||||
|
}
|
||||||
|
s = s[1 : len(s)-1]
|
||||||
|
|
||||||
|
// UUID without hyphens
|
||||||
|
case 32:
|
||||||
|
for i := 0; i < len(s); i += 2 {
|
||||||
|
_, ok := xtob(s[i], s[i+1])
|
||||||
|
if !ok {
|
||||||
|
return errors.New("invalid UUID format")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return invalidLengthError{len(s)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for standard UUID format
|
||||||
|
if len(s) == 36 {
|
||||||
|
if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
|
||||||
|
return errors.New("invalid UUID format")
|
||||||
|
}
|
||||||
|
for _, x := range []int{0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34} {
|
||||||
|
if _, ok := xtob(s[x], s[x+1]); !ok {
|
||||||
|
return errors.New("invalid UUID format")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||||
// , or "" if uuid is invalid.
|
// , or "" if uuid is invalid.
|
||||||
func (uuid UUID) String() string {
|
func (uuid UUID) String() string {
|
||||||
|
56
vendor/github.com/google/uuid/version6.go
generated
vendored
Normal file
56
vendor/github.com/google/uuid/version6.go
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
// Copyright 2023 Google Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package uuid
|
||||||
|
|
||||||
|
import "encoding/binary"
|
||||||
|
|
||||||
|
// UUID version 6 is a field-compatible version of UUIDv1, reordered for improved DB locality.
|
||||||
|
// It is expected that UUIDv6 will primarily be used in contexts where there are existing v1 UUIDs.
|
||||||
|
// Systems that do not involve legacy UUIDv1 SHOULD consider using UUIDv7 instead.
|
||||||
|
//
|
||||||
|
// see https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#uuidv6
|
||||||
|
//
|
||||||
|
// NewV6 returns a Version 6 UUID based on the current NodeID and clock
|
||||||
|
// sequence, and the current time. If the NodeID has not been set by SetNodeID
|
||||||
|
// or SetNodeInterface then it will be set automatically. If the NodeID cannot
|
||||||
|
// be set NewV6 set NodeID is random bits automatically . If clock sequence has not been set by
|
||||||
|
// SetClockSequence then it will be set automatically. If GetTime fails to
|
||||||
|
// return the current NewV6 returns Nil and an error.
|
||||||
|
func NewV6() (UUID, error) {
|
||||||
|
var uuid UUID
|
||||||
|
now, seq, err := GetTime()
|
||||||
|
if err != nil {
|
||||||
|
return uuid, err
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| time_high |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| time_mid | time_low_and_version |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|clk_seq_hi_res | clk_seq_low | node (0-1) |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| node (2-5) |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*/
|
||||||
|
|
||||||
|
binary.BigEndian.PutUint64(uuid[0:], uint64(now))
|
||||||
|
binary.BigEndian.PutUint16(uuid[8:], seq)
|
||||||
|
|
||||||
|
uuid[6] = 0x60 | (uuid[6] & 0x0F)
|
||||||
|
uuid[8] = 0x80 | (uuid[8] & 0x3F)
|
||||||
|
|
||||||
|
nodeMu.Lock()
|
||||||
|
if nodeID == zeroID {
|
||||||
|
setNodeInterface("")
|
||||||
|
}
|
||||||
|
copy(uuid[10:], nodeID[:])
|
||||||
|
nodeMu.Unlock()
|
||||||
|
|
||||||
|
return uuid, nil
|
||||||
|
}
|
104
vendor/github.com/google/uuid/version7.go
generated
vendored
Normal file
104
vendor/github.com/google/uuid/version7.go
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
// Copyright 2023 Google Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package uuid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UUID version 7 features a time-ordered value field derived from the widely
|
||||||
|
// implemented and well known Unix Epoch timestamp source,
|
||||||
|
// the number of milliseconds seconds since midnight 1 Jan 1970 UTC, leap seconds excluded.
|
||||||
|
// As well as improved entropy characteristics over versions 1 or 6.
|
||||||
|
//
|
||||||
|
// see https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03#name-uuid-version-7
|
||||||
|
//
|
||||||
|
// Implementations SHOULD utilize UUID version 7 over UUID version 1 and 6 if possible.
|
||||||
|
//
|
||||||
|
// NewV7 returns a Version 7 UUID based on the current time(Unix Epoch).
|
||||||
|
// Uses the randomness pool if it was enabled with EnableRandPool.
|
||||||
|
// On error, NewV7 returns Nil and an error
|
||||||
|
func NewV7() (UUID, error) {
|
||||||
|
uuid, err := NewRandom()
|
||||||
|
if err != nil {
|
||||||
|
return uuid, err
|
||||||
|
}
|
||||||
|
makeV7(uuid[:])
|
||||||
|
return uuid, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewV7FromReader returns a Version 7 UUID based on the current time(Unix Epoch).
|
||||||
|
// it use NewRandomFromReader fill random bits.
|
||||||
|
// On error, NewV7FromReader returns Nil and an error.
|
||||||
|
func NewV7FromReader(r io.Reader) (UUID, error) {
|
||||||
|
uuid, err := NewRandomFromReader(r)
|
||||||
|
if err != nil {
|
||||||
|
return uuid, err
|
||||||
|
}
|
||||||
|
|
||||||
|
makeV7(uuid[:])
|
||||||
|
return uuid, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// makeV7 fill 48 bits time (uuid[0] - uuid[5]), set version b0111 (uuid[6])
|
||||||
|
// uuid[8] already has the right version number (Variant is 10)
|
||||||
|
// see function NewV7 and NewV7FromReader
|
||||||
|
func makeV7(uuid []byte) {
|
||||||
|
/*
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| unix_ts_ms |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| unix_ts_ms | ver | rand_a (12 bit seq) |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|var| rand_b |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| rand_b |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
*/
|
||||||
|
_ = uuid[15] // bounds check
|
||||||
|
|
||||||
|
t, s := getV7Time()
|
||||||
|
|
||||||
|
uuid[0] = byte(t >> 40)
|
||||||
|
uuid[1] = byte(t >> 32)
|
||||||
|
uuid[2] = byte(t >> 24)
|
||||||
|
uuid[3] = byte(t >> 16)
|
||||||
|
uuid[4] = byte(t >> 8)
|
||||||
|
uuid[5] = byte(t)
|
||||||
|
|
||||||
|
uuid[6] = 0x70 | (0x0F & byte(s>>8))
|
||||||
|
uuid[7] = byte(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// lastV7time is the last time we returned stored as:
|
||||||
|
//
|
||||||
|
// 52 bits of time in milliseconds since epoch
|
||||||
|
// 12 bits of (fractional nanoseconds) >> 8
|
||||||
|
var lastV7time int64
|
||||||
|
|
||||||
|
const nanoPerMilli = 1000000
|
||||||
|
|
||||||
|
// getV7Time returns the time in milliseconds and nanoseconds / 256.
|
||||||
|
// The returned (milli << 12 + seq) is guarenteed to be greater than
|
||||||
|
// (milli << 12 + seq) returned by any previous call to getV7Time.
|
||||||
|
func getV7Time() (milli, seq int64) {
|
||||||
|
timeMu.Lock()
|
||||||
|
defer timeMu.Unlock()
|
||||||
|
|
||||||
|
nano := timeNow().UnixNano()
|
||||||
|
milli = nano / nanoPerMilli
|
||||||
|
// Sequence number is between 0 and 3906 (nanoPerMilli>>8)
|
||||||
|
seq = (nano - milli*nanoPerMilli) >> 8
|
||||||
|
now := milli<<12 + seq
|
||||||
|
if now <= lastV7time {
|
||||||
|
now = lastV7time + 1
|
||||||
|
milli = now >> 12
|
||||||
|
seq = now & 0xfff
|
||||||
|
}
|
||||||
|
lastV7time = now
|
||||||
|
return milli, seq
|
||||||
|
}
|
4
vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go
generated
vendored
4
vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go
generated
vendored
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.31.0
|
// protoc-gen-go v1.32.0
|
||||||
// protoc v4.22.0
|
// protoc v4.25.2
|
||||||
// source: grpc/binlog/v1/binarylog.proto
|
// source: grpc/binlog/v1/binarylog.proto
|
||||||
|
|
||||||
package grpc_binarylog_v1
|
package grpc_binarylog_v1
|
||||||
|
2
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
2
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
@@ -1772,6 +1772,8 @@ func parseTarget(target string) (resolver.Target, error) {
|
|||||||
return resolver.Target{URL: *u}, nil
|
return resolver.Target{URL: *u}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// encodeAuthority escapes the authority string based on valid chars defined in
|
||||||
|
// https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.
|
||||||
func encodeAuthority(authority string) string {
|
func encodeAuthority(authority string) string {
|
||||||
const upperhex = "0123456789ABCDEF"
|
const upperhex = "0123456789ABCDEF"
|
||||||
|
|
||||||
|
24
vendor/google.golang.org/grpc/encoding/proto/proto.go
generated
vendored
24
vendor/google.golang.org/grpc/encoding/proto/proto.go
generated
vendored
@@ -23,8 +23,9 @@ package proto
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/grpc/encoding"
|
"google.golang.org/grpc/encoding"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
"google.golang.org/protobuf/protoadapt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name registered for the proto compressor.
|
// Name is the name registered for the proto compressor.
|
||||||
@@ -38,21 +39,34 @@ func init() {
|
|||||||
type codec struct{}
|
type codec struct{}
|
||||||
|
|
||||||
func (codec) Marshal(v any) ([]byte, error) {
|
func (codec) Marshal(v any) ([]byte, error) {
|
||||||
vv, ok := v.(proto.Message)
|
vv := messageV2Of(v)
|
||||||
if !ok {
|
if vv == nil {
|
||||||
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
|
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return proto.Marshal(vv)
|
return proto.Marshal(vv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (codec) Unmarshal(data []byte, v any) error {
|
func (codec) Unmarshal(data []byte, v any) error {
|
||||||
vv, ok := v.(proto.Message)
|
vv := messageV2Of(v)
|
||||||
if !ok {
|
if vv == nil {
|
||||||
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
|
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return proto.Unmarshal(data, vv)
|
return proto.Unmarshal(data, vv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func messageV2Of(v any) proto.Message {
|
||||||
|
switch v := v.(type) {
|
||||||
|
case protoadapt.MessageV1:
|
||||||
|
return protoadapt.MessageV2Of(v)
|
||||||
|
case protoadapt.MessageV2:
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (codec) Name() string {
|
func (codec) Name() string {
|
||||||
return Name
|
return Name
|
||||||
}
|
}
|
||||||
|
9
vendor/google.golang.org/grpc/internal/binarylog/method_logger.go
generated
vendored
9
vendor/google.golang.org/grpc/internal/binarylog/method_logger.go
generated
vendored
@@ -25,11 +25,12 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/golang/protobuf/ptypes"
|
|
||||||
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
"google.golang.org/protobuf/types/known/durationpb"
|
||||||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type callIDGenerator struct {
|
type callIDGenerator struct {
|
||||||
@@ -88,7 +89,7 @@ func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger {
|
|||||||
// in TruncatingMethodLogger as possible.
|
// in TruncatingMethodLogger as possible.
|
||||||
func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry {
|
func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry {
|
||||||
m := c.toProto()
|
m := c.toProto()
|
||||||
timestamp, _ := ptypes.TimestampProto(time.Now())
|
timestamp := timestamppb.Now()
|
||||||
m.Timestamp = timestamp
|
m.Timestamp = timestamp
|
||||||
m.CallId = ml.callID
|
m.CallId = ml.callID
|
||||||
m.SequenceIdWithinCall = ml.idWithinCallGen.next()
|
m.SequenceIdWithinCall = ml.idWithinCallGen.next()
|
||||||
@@ -178,7 +179,7 @@ func (c *ClientHeader) toProto() *binlogpb.GrpcLogEntry {
|
|||||||
Authority: c.Authority,
|
Authority: c.Authority,
|
||||||
}
|
}
|
||||||
if c.Timeout > 0 {
|
if c.Timeout > 0 {
|
||||||
clientHeader.Timeout = ptypes.DurationProto(c.Timeout)
|
clientHeader.Timeout = durationpb.New(c.Timeout)
|
||||||
}
|
}
|
||||||
ret := &binlogpb.GrpcLogEntry{
|
ret := &binlogpb.GrpcLogEntry{
|
||||||
Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER,
|
Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER,
|
||||||
|
2
vendor/google.golang.org/grpc/internal/binarylog/sink.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/binarylog/sink.go
generated
vendored
@@ -25,8 +25,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
5
vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go
generated
vendored
5
vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go
generated
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
//go:build !go1.21
|
||||||
|
|
||||||
|
// TODO: when this file is deleted (after Go 1.20 support is dropped), delete
|
||||||
|
// all of grpcrand and call the rand package directly.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2018 gRPC authors.
|
* Copyright 2018 gRPC authors.
|
||||||
|
73
vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go
generated
vendored
Normal file
73
vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
//go:build go1.21
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 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 grpcrand implements math/rand functions in a concurrent-safe way
|
||||||
|
// with a global random source, independent of math/rand's global source.
|
||||||
|
package grpcrand
|
||||||
|
|
||||||
|
import "math/rand"
|
||||||
|
|
||||||
|
// This implementation will be used for Go version 1.21 or newer.
|
||||||
|
// For older versions, the original implementation with mutex will be used.
|
||||||
|
|
||||||
|
// Int implements rand.Int on the grpcrand global source.
|
||||||
|
func Int() int {
|
||||||
|
return rand.Int()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Int63n implements rand.Int63n on the grpcrand global source.
|
||||||
|
func Int63n(n int64) int64 {
|
||||||
|
return rand.Int63n(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intn implements rand.Intn on the grpcrand global source.
|
||||||
|
func Intn(n int) int {
|
||||||
|
return rand.Intn(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Int31n implements rand.Int31n on the grpcrand global source.
|
||||||
|
func Int31n(n int32) int32 {
|
||||||
|
return rand.Int31n(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64 implements rand.Float64 on the grpcrand global source.
|
||||||
|
func Float64() float64 {
|
||||||
|
return rand.Float64()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uint64 implements rand.Uint64 on the grpcrand global source.
|
||||||
|
func Uint64() uint64 {
|
||||||
|
return rand.Uint64()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uint32 implements rand.Uint32 on the grpcrand global source.
|
||||||
|
func Uint32() uint32 {
|
||||||
|
return rand.Uint32()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpFloat64 implements rand.ExpFloat64 on the grpcrand global source.
|
||||||
|
func ExpFloat64() float64 {
|
||||||
|
return rand.ExpFloat64()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shuffle implements rand.Shuffle on the grpcrand global source.
|
||||||
|
var Shuffle = func(n int, f func(int, int)) {
|
||||||
|
rand.Shuffle(n, f)
|
||||||
|
}
|
7
vendor/google.golang.org/grpc/internal/pretty/pretty.go
generated
vendored
7
vendor/google.golang.org/grpc/internal/pretty/pretty.go
generated
vendored
@@ -24,7 +24,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/golang/protobuf/jsonpb"
|
|
||||||
protov1 "github.com/golang/protobuf/proto"
|
protov1 "github.com/golang/protobuf/proto"
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
"google.golang.org/protobuf/encoding/protojson"
|
||||||
protov2 "google.golang.org/protobuf/proto"
|
protov2 "google.golang.org/protobuf/proto"
|
||||||
@@ -38,15 +37,15 @@ const jsonIndent = " "
|
|||||||
func ToJSON(e any) string {
|
func ToJSON(e any) string {
|
||||||
switch ee := e.(type) {
|
switch ee := e.(type) {
|
||||||
case protov1.Message:
|
case protov1.Message:
|
||||||
mm := jsonpb.Marshaler{Indent: jsonIndent}
|
mm := protojson.MarshalOptions{Indent: jsonIndent}
|
||||||
ret, err := mm.MarshalToString(ee)
|
ret, err := mm.Marshal(protov1.MessageV2(ee))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// This may fail for proto.Anys, e.g. for xDS v2, LDS, the v2
|
// This may fail for proto.Anys, e.g. for xDS v2, LDS, the v2
|
||||||
// messages are not imported, and this will fail because the message
|
// messages are not imported, and this will fail because the message
|
||||||
// is not found.
|
// is not found.
|
||||||
return fmt.Sprintf("%+v", ee)
|
return fmt.Sprintf("%+v", ee)
|
||||||
}
|
}
|
||||||
return ret
|
return string(ret)
|
||||||
case protov2.Message:
|
case protov2.Message:
|
||||||
mm := protojson.MarshalOptions{
|
mm := protojson.MarshalOptions{
|
||||||
Multiline: true,
|
Multiline: true,
|
||||||
|
15
vendor/google.golang.org/grpc/internal/status/status.go
generated
vendored
15
vendor/google.golang.org/grpc/internal/status/status.go
generated
vendored
@@ -31,10 +31,11 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/golang/protobuf/ptypes"
|
|
||||||
spb "google.golang.org/genproto/googleapis/rpc/status"
|
spb "google.golang.org/genproto/googleapis/rpc/status"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
"google.golang.org/protobuf/protoadapt"
|
||||||
|
"google.golang.org/protobuf/types/known/anypb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Status represents an RPC status code, message, and details. It is immutable
|
// Status represents an RPC status code, message, and details. It is immutable
|
||||||
@@ -130,14 +131,14 @@ func (s *Status) Err() error {
|
|||||||
|
|
||||||
// WithDetails returns a new status with the provided details messages appended to the status.
|
// WithDetails returns a new status with the provided details messages appended to the status.
|
||||||
// If any errors are encountered, it returns nil and the first error encountered.
|
// If any errors are encountered, it returns nil and the first error encountered.
|
||||||
func (s *Status) WithDetails(details ...proto.Message) (*Status, error) {
|
func (s *Status) WithDetails(details ...protoadapt.MessageV1) (*Status, error) {
|
||||||
if s.Code() == codes.OK {
|
if s.Code() == codes.OK {
|
||||||
return nil, errors.New("no error details for status with code OK")
|
return nil, errors.New("no error details for status with code OK")
|
||||||
}
|
}
|
||||||
// s.Code() != OK implies that s.Proto() != nil.
|
// s.Code() != OK implies that s.Proto() != nil.
|
||||||
p := s.Proto()
|
p := s.Proto()
|
||||||
for _, detail := range details {
|
for _, detail := range details {
|
||||||
any, err := ptypes.MarshalAny(detail)
|
any, err := anypb.New(protoadapt.MessageV2Of(detail))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -154,12 +155,12 @@ func (s *Status) Details() []any {
|
|||||||
}
|
}
|
||||||
details := make([]any, 0, len(s.s.Details))
|
details := make([]any, 0, len(s.s.Details))
|
||||||
for _, any := range s.s.Details {
|
for _, any := range s.s.Details {
|
||||||
detail := &ptypes.DynamicAny{}
|
detail, err := any.UnmarshalNew()
|
||||||
if err := ptypes.UnmarshalAny(any, detail); err != nil {
|
if err != nil {
|
||||||
details = append(details, err)
|
details = append(details, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
details = append(details, detail.Message)
|
details = append(details, detail)
|
||||||
}
|
}
|
||||||
return details
|
return details
|
||||||
}
|
}
|
||||||
|
2
vendor/google.golang.org/grpc/internal/transport/handler_server.go
generated
vendored
2
vendor/google.golang.org/grpc/internal/transport/handler_server.go
generated
vendored
@@ -35,7 +35,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
@@ -45,6 +44,7 @@ import (
|
|||||||
"google.golang.org/grpc/peer"
|
"google.golang.org/grpc/peer"
|
||||||
"google.golang.org/grpc/stats"
|
"google.golang.org/grpc/stats"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewServerHandlerTransport returns a ServerTransport handling gRPC from
|
// NewServerHandlerTransport returns a ServerTransport handling gRPC from
|
||||||
|
6
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
6
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
@@ -32,13 +32,13 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"golang.org/x/net/http2/hpack"
|
"golang.org/x/net/http2/hpack"
|
||||||
"google.golang.org/grpc/internal/grpclog"
|
"google.golang.org/grpc/internal/grpclog"
|
||||||
"google.golang.org/grpc/internal/grpcutil"
|
"google.golang.org/grpc/internal/grpcutil"
|
||||||
"google.golang.org/grpc/internal/pretty"
|
"google.golang.org/grpc/internal/pretty"
|
||||||
"google.golang.org/grpc/internal/syscall"
|
"google.golang.org/grpc/internal/syscall"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
@@ -652,10 +652,6 @@ func (t *http2Server) HandleStreams(ctx context.Context, handle func(*Stream)) {
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err == io.EOF || err == io.ErrUnexpectedEOF {
|
|
||||||
t.Close(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t.Close(err)
|
t.Close(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
9
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
9
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
@@ -28,6 +28,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@@ -362,8 +363,12 @@ func (s *Stream) SendCompress() string {
|
|||||||
|
|
||||||
// ClientAdvertisedCompressors returns the compressor names advertised by the
|
// ClientAdvertisedCompressors returns the compressor names advertised by the
|
||||||
// client via grpc-accept-encoding header.
|
// client via grpc-accept-encoding header.
|
||||||
func (s *Stream) ClientAdvertisedCompressors() string {
|
func (s *Stream) ClientAdvertisedCompressors() []string {
|
||||||
return s.clientAdvertisedCompressors
|
values := strings.Split(s.clientAdvertisedCompressors, ",")
|
||||||
|
for i, v := range values {
|
||||||
|
values[i] = strings.TrimSpace(v)
|
||||||
|
}
|
||||||
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done returns a channel which is closed when it receives the final status
|
// Done returns a channel which is closed when it receives the final status
|
||||||
|
4
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go
generated
vendored
4
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go
generated
vendored
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.31.0
|
// protoc-gen-go v1.32.0
|
||||||
// protoc v4.22.0
|
// protoc v4.25.2
|
||||||
// source: grpc/reflection/v1/reflection.proto
|
// source: grpc/reflection/v1/reflection.proto
|
||||||
|
|
||||||
package grpc_reflection_v1
|
package grpc_reflection_v1
|
||||||
|
2
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go
generated
vendored
2
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go
generated
vendored
@@ -22,7 +22,7 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.3.0
|
// - protoc-gen-go-grpc v1.3.0
|
||||||
// - protoc v4.22.0
|
// - protoc v4.25.2
|
||||||
// source: grpc/reflection/v1/reflection.proto
|
// source: grpc/reflection/v1/reflection.proto
|
||||||
|
|
||||||
package grpc_reflection_v1
|
package grpc_reflection_v1
|
||||||
|
4
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go
generated
vendored
4
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go
generated
vendored
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.31.0
|
// protoc-gen-go v1.32.0
|
||||||
// protoc v4.22.0
|
// protoc v4.25.2
|
||||||
// grpc/reflection/v1alpha/reflection.proto is a deprecated file.
|
// grpc/reflection/v1alpha/reflection.proto is a deprecated file.
|
||||||
|
|
||||||
package grpc_reflection_v1alpha
|
package grpc_reflection_v1alpha
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.3.0
|
// - protoc-gen-go-grpc v1.3.0
|
||||||
// - protoc v4.22.0
|
// - protoc v4.25.2
|
||||||
// grpc/reflection/v1alpha/reflection.proto is a deprecated file.
|
// grpc/reflection/v1alpha/reflection.proto is a deprecated file.
|
||||||
|
|
||||||
package grpc_reflection_v1alpha
|
package grpc_reflection_v1alpha
|
||||||
|
3
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
3
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
@@ -168,6 +168,9 @@ type BuildOptions struct {
|
|||||||
// field. In most cases though, it is not appropriate, and this field may
|
// field. In most cases though, it is not appropriate, and this field may
|
||||||
// be ignored.
|
// be ignored.
|
||||||
Dialer func(context.Context, string) (net.Conn, error)
|
Dialer func(context.Context, string) (net.Conn, error)
|
||||||
|
// Authority is the effective authority of the clientconn for which the
|
||||||
|
// resolver is built.
|
||||||
|
Authority string
|
||||||
}
|
}
|
||||||
|
|
||||||
// An Endpoint is one network endpoint, or server, which may have multiple
|
// An Endpoint is one network endpoint, or server, which may have multiple
|
||||||
|
1
vendor/google.golang.org/grpc/resolver_wrapper.go
generated
vendored
1
vendor/google.golang.org/grpc/resolver_wrapper.go
generated
vendored
@@ -75,6 +75,7 @@ func (ccr *ccResolverWrapper) start() error {
|
|||||||
DialCreds: ccr.cc.dopts.copts.TransportCredentials,
|
DialCreds: ccr.cc.dopts.copts.TransportCredentials,
|
||||||
CredsBundle: ccr.cc.dopts.copts.CredsBundle,
|
CredsBundle: ccr.cc.dopts.copts.CredsBundle,
|
||||||
Dialer: ccr.cc.dopts.copts.Dialer,
|
Dialer: ccr.cc.dopts.copts.Dialer,
|
||||||
|
Authority: ccr.cc.authority,
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
ccr.resolver, err = ccr.cc.resolverBuilder.Build(ccr.cc.parsedTarget, ccr, opts)
|
ccr.resolver, err = ccr.cc.resolverBuilder.Build(ccr.cc.parsedTarget, ccr, opts)
|
||||||
|
69
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
69
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
@@ -189,6 +189,20 @@ type EmptyCallOption struct{}
|
|||||||
func (EmptyCallOption) before(*callInfo) error { return nil }
|
func (EmptyCallOption) before(*callInfo) error { return nil }
|
||||||
func (EmptyCallOption) after(*callInfo, *csAttempt) {}
|
func (EmptyCallOption) after(*callInfo, *csAttempt) {}
|
||||||
|
|
||||||
|
// StaticMethod returns a CallOption which specifies that a call is being made
|
||||||
|
// to a method that is static, which means the method is known at compile time
|
||||||
|
// and doesn't change at runtime. This can be used as a signal to stats plugins
|
||||||
|
// that this method is safe to include as a key to a measurement.
|
||||||
|
func StaticMethod() CallOption {
|
||||||
|
return StaticMethodCallOption{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StaticMethodCallOption is a CallOption that specifies that a call comes
|
||||||
|
// from a static method.
|
||||||
|
type StaticMethodCallOption struct {
|
||||||
|
EmptyCallOption
|
||||||
|
}
|
||||||
|
|
||||||
// Header returns a CallOptions that retrieves the header metadata
|
// Header returns a CallOptions that retrieves the header metadata
|
||||||
// for a unary RPC.
|
// for a unary RPC.
|
||||||
func Header(md *metadata.MD) CallOption {
|
func Header(md *metadata.MD) CallOption {
|
||||||
@@ -730,17 +744,19 @@ type payloadInfo struct {
|
|||||||
uncompressedBytes []byte
|
uncompressedBytes []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func recvAndDecompress(p *parser, s *transport.Stream, dc Decompressor, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) ([]byte, error) {
|
// recvAndDecompress reads a message from the stream, decompressing it if necessary.
|
||||||
pf, buf, err := p.recvMsg(maxReceiveMessageSize)
|
//
|
||||||
|
// Cancelling the returned cancel function releases the buffer back to the pool. So the caller should cancel as soon as
|
||||||
|
// the buffer is no longer needed.
|
||||||
|
func recvAndDecompress(p *parser, s *transport.Stream, dc Decompressor, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor,
|
||||||
|
) (uncompressedBuf []byte, cancel func(), err error) {
|
||||||
|
pf, compressedBuf, err := p.recvMsg(maxReceiveMessageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
|
||||||
if payInfo != nil {
|
|
||||||
payInfo.compressedLength = len(buf)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if st := checkRecvPayload(pf, s.RecvCompress(), compressor != nil || dc != nil); st != nil {
|
if st := checkRecvPayload(pf, s.RecvCompress(), compressor != nil || dc != nil); st != nil {
|
||||||
return nil, st.Err()
|
return nil, nil, st.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
var size int
|
var size int
|
||||||
@@ -748,21 +764,35 @@ func recvAndDecompress(p *parser, s *transport.Stream, dc Decompressor, maxRecei
|
|||||||
// To match legacy behavior, if the decompressor is set by WithDecompressor or RPCDecompressor,
|
// To match legacy behavior, if the decompressor is set by WithDecompressor or RPCDecompressor,
|
||||||
// use this decompressor as the default.
|
// use this decompressor as the default.
|
||||||
if dc != nil {
|
if dc != nil {
|
||||||
buf, err = dc.Do(bytes.NewReader(buf))
|
uncompressedBuf, err = dc.Do(bytes.NewReader(compressedBuf))
|
||||||
size = len(buf)
|
size = len(uncompressedBuf)
|
||||||
} else {
|
} else {
|
||||||
buf, size, err = decompress(compressor, buf, maxReceiveMessageSize)
|
uncompressedBuf, size, err = decompress(compressor, compressedBuf, maxReceiveMessageSize)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err)
|
return nil, nil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err)
|
||||||
}
|
}
|
||||||
if size > maxReceiveMessageSize {
|
if size > maxReceiveMessageSize {
|
||||||
// TODO: Revisit the error code. Currently keep it consistent with java
|
// TODO: Revisit the error code. Currently keep it consistent with java
|
||||||
// implementation.
|
// implementation.
|
||||||
return nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max (%d vs. %d)", size, maxReceiveMessageSize)
|
return nil, nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max (%d vs. %d)", size, maxReceiveMessageSize)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uncompressedBuf = compressedBuf
|
||||||
|
}
|
||||||
|
|
||||||
|
if payInfo != nil {
|
||||||
|
payInfo.compressedLength = len(compressedBuf)
|
||||||
|
payInfo.uncompressedBytes = uncompressedBuf
|
||||||
|
|
||||||
|
cancel = func() {}
|
||||||
|
} else {
|
||||||
|
cancel = func() {
|
||||||
|
p.recvBufferPool.Put(&compressedBuf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf, nil
|
|
||||||
|
return uncompressedBuf, cancel, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using compressor, decompress d, returning data and size.
|
// Using compressor, decompress d, returning data and size.
|
||||||
@@ -782,6 +812,9 @@ func decompress(compressor encoding.Compressor, d []byte, maxReceiveMessageSize
|
|||||||
// size is used as an estimate to size the buffer, but we
|
// size is used as an estimate to size the buffer, but we
|
||||||
// will read more data if available.
|
// will read more data if available.
|
||||||
// +MinRead so ReadFrom will not reallocate if size is correct.
|
// +MinRead so ReadFrom will not reallocate if size is correct.
|
||||||
|
//
|
||||||
|
// TODO: If we ensure that the buffer size is the same as the DecompressedSize,
|
||||||
|
// we can also utilize the recv buffer pool here.
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, size+bytes.MinRead))
|
buf := bytes.NewBuffer(make([]byte, 0, size+bytes.MinRead))
|
||||||
bytesRead, err := buf.ReadFrom(io.LimitReader(dcReader, int64(maxReceiveMessageSize)+1))
|
bytesRead, err := buf.ReadFrom(io.LimitReader(dcReader, int64(maxReceiveMessageSize)+1))
|
||||||
return buf.Bytes(), int(bytesRead), err
|
return buf.Bytes(), int(bytesRead), err
|
||||||
@@ -797,18 +830,15 @@ func decompress(compressor encoding.Compressor, d []byte, maxReceiveMessageSize
|
|||||||
// dc takes precedence over compressor.
|
// dc takes precedence over compressor.
|
||||||
// TODO(dfawley): wrap the old compressor/decompressor using the new API?
|
// TODO(dfawley): wrap the old compressor/decompressor using the new API?
|
||||||
func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m any, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) error {
|
func recv(p *parser, c baseCodec, s *transport.Stream, dc Decompressor, m any, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor) error {
|
||||||
buf, err := recvAndDecompress(p, s, dc, maxReceiveMessageSize, payInfo, compressor)
|
buf, cancel, err := recvAndDecompress(p, s, dc, maxReceiveMessageSize, payInfo, compressor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
if err := c.Unmarshal(buf, m); err != nil {
|
if err := c.Unmarshal(buf, m); err != nil {
|
||||||
return status.Errorf(codes.Internal, "grpc: failed to unmarshal the received message: %v", err)
|
return status.Errorf(codes.Internal, "grpc: failed to unmarshal the received message: %v", err)
|
||||||
}
|
}
|
||||||
if payInfo != nil {
|
|
||||||
payInfo.uncompressedBytes = buf
|
|
||||||
} else {
|
|
||||||
p.recvBufferPool.Put(&buf)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,6 +988,7 @@ const (
|
|||||||
SupportPackageIsVersion5 = true
|
SupportPackageIsVersion5 = true
|
||||||
SupportPackageIsVersion6 = true
|
SupportPackageIsVersion6 = true
|
||||||
SupportPackageIsVersion7 = true
|
SupportPackageIsVersion7 = true
|
||||||
|
SupportPackageIsVersion8 = true
|
||||||
)
|
)
|
||||||
|
|
||||||
const grpcUA = "grpc-go/" + Version
|
const grpcUA = "grpc-go/" + Version
|
||||||
|
21
vendor/google.golang.org/grpc/server.go
generated
vendored
21
vendor/google.golang.org/grpc/server.go
generated
vendored
@@ -33,8 +33,6 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/trace"
|
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
"google.golang.org/grpc/encoding"
|
"google.golang.org/grpc/encoding"
|
||||||
@@ -131,7 +129,7 @@ type Server struct {
|
|||||||
drain bool
|
drain bool
|
||||||
cv *sync.Cond // signaled when connections close for GracefulStop
|
cv *sync.Cond // signaled when connections close for GracefulStop
|
||||||
services map[string]*serviceInfo // service name -> service info
|
services map[string]*serviceInfo // service name -> service info
|
||||||
events trace.EventLog
|
events traceEventLog
|
||||||
|
|
||||||
quit *grpcsync.Event
|
quit *grpcsync.Event
|
||||||
done *grpcsync.Event
|
done *grpcsync.Event
|
||||||
@@ -670,7 +668,7 @@ func NewServer(opt ...ServerOption) *Server {
|
|||||||
s.cv = sync.NewCond(&s.mu)
|
s.cv = sync.NewCond(&s.mu)
|
||||||
if EnableTracing {
|
if EnableTracing {
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
s.events = trace.NewEventLog("grpc.Server", fmt.Sprintf("%s:%d", file, line))
|
s.events = newTraceEventLog("grpc.Server", fmt.Sprintf("%s:%d", file, line))
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.opts.numServerWorkers > 0 {
|
if s.opts.numServerWorkers > 0 {
|
||||||
@@ -1344,7 +1342,8 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
|
|||||||
if len(shs) != 0 || len(binlogs) != 0 {
|
if len(shs) != 0 || len(binlogs) != 0 {
|
||||||
payInfo = &payloadInfo{}
|
payInfo = &payloadInfo{}
|
||||||
}
|
}
|
||||||
d, err := recvAndDecompress(&parser{r: stream, recvBufferPool: s.opts.recvBufferPool}, stream, dc, s.opts.maxReceiveMessageSize, payInfo, decomp)
|
|
||||||
|
d, cancel, err := recvAndDecompress(&parser{r: stream, recvBufferPool: s.opts.recvBufferPool}, stream, dc, s.opts.maxReceiveMessageSize, payInfo, decomp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if e := t.WriteStatus(stream, status.Convert(err)); e != nil {
|
if e := t.WriteStatus(stream, status.Convert(err)); e != nil {
|
||||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
channelz.Warningf(logger, s.channelzID, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
||||||
@@ -1355,6 +1354,8 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
|
|||||||
t.IncrMsgRecv()
|
t.IncrMsgRecv()
|
||||||
}
|
}
|
||||||
df := func(v any) error {
|
df := func(v any) error {
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil {
|
if err := s.getCodec(stream.ContentSubtype()).Unmarshal(d, v); err != nil {
|
||||||
return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err)
|
return status.Errorf(codes.Internal, "grpc: error unmarshalling request: %v", err)
|
||||||
}
|
}
|
||||||
@@ -1734,8 +1735,8 @@ func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Str
|
|||||||
ctx = contextWithServer(ctx, s)
|
ctx = contextWithServer(ctx, s)
|
||||||
var ti *traceInfo
|
var ti *traceInfo
|
||||||
if EnableTracing {
|
if EnableTracing {
|
||||||
tr := trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
|
tr := newTrace("grpc.Recv."+methodFamily(stream.Method()), stream.Method())
|
||||||
ctx = trace.NewContext(ctx, tr)
|
ctx = newTraceContext(ctx, tr)
|
||||||
ti = &traceInfo{
|
ti = &traceInfo{
|
||||||
tr: tr,
|
tr: tr,
|
||||||
firstLine: firstLine{
|
firstLine: firstLine{
|
||||||
@@ -2119,7 +2120,7 @@ func ClientSupportedCompressors(ctx context.Context) ([]string, error) {
|
|||||||
return nil, fmt.Errorf("failed to fetch the stream from the given context %v", ctx)
|
return nil, fmt.Errorf("failed to fetch the stream from the given context %v", ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Split(stream.ClientAdvertisedCompressors(), ","), nil
|
return stream.ClientAdvertisedCompressors(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTrailer sets the trailer metadata that will be sent when an RPC returns.
|
// SetTrailer sets the trailer metadata that will be sent when an RPC returns.
|
||||||
@@ -2159,7 +2160,7 @@ func (c *channelzServer) ChannelzMetric() *channelz.ServerInternalMetric {
|
|||||||
|
|
||||||
// validateSendCompressor returns an error when given compressor name cannot be
|
// validateSendCompressor returns an error when given compressor name cannot be
|
||||||
// handled by the server or the client based on the advertised compressors.
|
// handled by the server or the client based on the advertised compressors.
|
||||||
func validateSendCompressor(name, clientCompressors string) error {
|
func validateSendCompressor(name string, clientCompressors []string) error {
|
||||||
if name == encoding.Identity {
|
if name == encoding.Identity {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -2168,7 +2169,7 @@ func validateSendCompressor(name, clientCompressors string) error {
|
|||||||
return fmt.Errorf("compressor not registered %q", name)
|
return fmt.Errorf("compressor not registered %q", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range strings.Split(clientCompressors, ",") {
|
for _, c := range clientCompressors {
|
||||||
if c == name {
|
if c == name {
|
||||||
return nil // found match
|
return nil // found match
|
||||||
}
|
}
|
||||||
|
5
vendor/google.golang.org/grpc/stream.go
generated
vendored
5
vendor/google.golang.org/grpc/stream.go
generated
vendored
@@ -27,7 +27,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/trace"
|
|
||||||
"google.golang.org/grpc/balancer"
|
"google.golang.org/grpc/balancer"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/encoding"
|
"google.golang.org/grpc/encoding"
|
||||||
@@ -431,7 +430,7 @@ func (cs *clientStream) newAttemptLocked(isTransparent bool) (*csAttempt, error)
|
|||||||
var trInfo *traceInfo
|
var trInfo *traceInfo
|
||||||
if EnableTracing {
|
if EnableTracing {
|
||||||
trInfo = &traceInfo{
|
trInfo = &traceInfo{
|
||||||
tr: trace.New("grpc.Sent."+methodFamily(method), method),
|
tr: newTrace("grpc.Sent."+methodFamily(method), method),
|
||||||
firstLine: firstLine{
|
firstLine: firstLine{
|
||||||
client: true,
|
client: true,
|
||||||
},
|
},
|
||||||
@@ -440,7 +439,7 @@ func (cs *clientStream) newAttemptLocked(isTransparent bool) (*csAttempt, error)
|
|||||||
trInfo.firstLine.deadline = time.Until(deadline)
|
trInfo.firstLine.deadline = time.Until(deadline)
|
||||||
}
|
}
|
||||||
trInfo.tr.LazyLog(&trInfo.firstLine, false)
|
trInfo.tr.LazyLog(&trInfo.firstLine, false)
|
||||||
ctx = trace.NewContext(ctx, trInfo.tr)
|
ctx = newTraceContext(ctx, trInfo.tr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cs.cc.parsedTarget.URL.Scheme == internal.GRPCResolverSchemeExtraMetadata {
|
if cs.cc.parsedTarget.URL.Scheme == internal.GRPCResolverSchemeExtraMetadata {
|
||||||
|
26
vendor/google.golang.org/grpc/trace.go
generated
vendored
26
vendor/google.golang.org/grpc/trace.go
generated
vendored
@@ -26,8 +26,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/trace"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package.
|
// EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package.
|
||||||
@@ -44,9 +42,31 @@ func methodFamily(m string) string {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// traceEventLog mirrors golang.org/x/net/trace.EventLog.
|
||||||
|
//
|
||||||
|
// It exists in order to avoid importing x/net/trace on grpcnotrace builds.
|
||||||
|
type traceEventLog interface {
|
||||||
|
Printf(format string, a ...any)
|
||||||
|
Errorf(format string, a ...any)
|
||||||
|
Finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
// traceLog mirrors golang.org/x/net/trace.Trace.
|
||||||
|
//
|
||||||
|
// It exists in order to avoid importing x/net/trace on grpcnotrace builds.
|
||||||
|
type traceLog interface {
|
||||||
|
LazyLog(x fmt.Stringer, sensitive bool)
|
||||||
|
LazyPrintf(format string, a ...any)
|
||||||
|
SetError()
|
||||||
|
SetRecycler(f func(any))
|
||||||
|
SetTraceInfo(traceID, spanID uint64)
|
||||||
|
SetMaxEvents(m int)
|
||||||
|
Finish()
|
||||||
|
}
|
||||||
|
|
||||||
// traceInfo contains tracing information for an RPC.
|
// traceInfo contains tracing information for an RPC.
|
||||||
type traceInfo struct {
|
type traceInfo struct {
|
||||||
tr trace.Trace
|
tr traceLog
|
||||||
firstLine firstLine
|
firstLine firstLine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
vendor/google.golang.org/grpc/trace_notrace.go
generated
vendored
Normal file
52
vendor/google.golang.org/grpc/trace_notrace.go
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
//go:build grpcnotrace
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 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 grpc
|
||||||
|
|
||||||
|
// grpcnotrace can be used to avoid importing golang.org/x/net/trace, which in
|
||||||
|
// turn enables binaries using gRPC-Go for dead code elimination, which can
|
||||||
|
// yield 10-15% improvements in binary size when tracing is not needed.
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type notrace struct{}
|
||||||
|
|
||||||
|
func (notrace) LazyLog(x fmt.Stringer, sensitive bool) {}
|
||||||
|
func (notrace) LazyPrintf(format string, a ...any) {}
|
||||||
|
func (notrace) SetError() {}
|
||||||
|
func (notrace) SetRecycler(f func(any)) {}
|
||||||
|
func (notrace) SetTraceInfo(traceID, spanID uint64) {}
|
||||||
|
func (notrace) SetMaxEvents(m int) {}
|
||||||
|
func (notrace) Finish() {}
|
||||||
|
|
||||||
|
func newTrace(family, title string) traceLog {
|
||||||
|
return notrace{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTraceContext(ctx context.Context, tr traceLog) context.Context {
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTraceEventLog(family, title string) traceEventLog {
|
||||||
|
return nil
|
||||||
|
}
|
39
vendor/google.golang.org/grpc/trace_withtrace.go
generated
vendored
Normal file
39
vendor/google.golang.org/grpc/trace_withtrace.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
//go:build !grpcnotrace
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 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 grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
t "golang.org/x/net/trace"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newTrace(family, title string) traceLog {
|
||||||
|
return t.New(family, title)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTraceContext(ctx context.Context, tr traceLog) context.Context {
|
||||||
|
return t.NewContext(ctx, tr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newTraceEventLog(family, title string) traceEventLog {
|
||||||
|
return t.NewEventLog(family, title)
|
||||||
|
}
|
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
|
package grpc
|
||||||
|
|
||||||
// Version is the current grpc version.
|
// Version is the current grpc version.
|
||||||
const Version = "1.61.1"
|
const Version = "1.62.1"
|
||||||
|
2
vendor/google.golang.org/grpc/vet.sh
generated
vendored
2
vendor/google.golang.org/grpc/vet.sh
generated
vendored
@@ -41,7 +41,7 @@ if [[ "$1" = "-install" ]]; then
|
|||||||
popd
|
popd
|
||||||
if [[ -z "${VET_SKIP_PROTO}" ]]; then
|
if [[ -z "${VET_SKIP_PROTO}" ]]; then
|
||||||
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
|
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
|
||||||
PROTOBUF_VERSION=22.0 # a.k.a v4.22.0 in pb.go files.
|
PROTOBUF_VERSION=25.2 # a.k.a. v4.22.0 in pb.go files.
|
||||||
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
|
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
|
||||||
pushd /home/runner/go
|
pushd /home/runner/go
|
||||||
wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME}
|
wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME}
|
||||||
|
31
vendor/google.golang.org/protobuf/protoadapt/convert.go
generated
vendored
Normal file
31
vendor/google.golang.org/protobuf/protoadapt/convert.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2023 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 protoadapt bridges the original and new proto APIs.
|
||||||
|
package protoadapt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
"google.golang.org/protobuf/runtime/protoiface"
|
||||||
|
"google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MessageV1 is the original [github.com/golang/protobuf/proto.Message] type.
|
||||||
|
type MessageV1 = protoiface.MessageV1
|
||||||
|
|
||||||
|
// MessageV2 is the [google.golang.org/protobuf/proto.Message] type used by the
|
||||||
|
// current [google.golang.org/protobuf] module, adding support for reflection.
|
||||||
|
type MessageV2 = proto.Message
|
||||||
|
|
||||||
|
// MessageV1Of converts a v2 message to a v1 message.
|
||||||
|
// It returns nil if m is nil.
|
||||||
|
func MessageV1Of(m MessageV2) MessageV1 {
|
||||||
|
return protoimpl.X.ProtoMessageV1Of(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MessageV2Of converts a v1 message to a v2 message.
|
||||||
|
// It returns nil if m is nil.
|
||||||
|
func MessageV2Of(m MessageV1) MessageV2 {
|
||||||
|
return protoimpl.X.ProtoMessageV2Of(m)
|
||||||
|
}
|
8
vendor/modules.txt
vendored
8
vendor/modules.txt
vendored
@@ -54,7 +54,6 @@ github.com/golang/mock/mockgen/model
|
|||||||
# github.com/golang/protobuf v1.5.3
|
# github.com/golang/protobuf v1.5.3
|
||||||
## explicit; go 1.9
|
## explicit; go 1.9
|
||||||
github.com/golang/protobuf/descriptor
|
github.com/golang/protobuf/descriptor
|
||||||
github.com/golang/protobuf/jsonpb
|
|
||||||
github.com/golang/protobuf/proto
|
github.com/golang/protobuf/proto
|
||||||
github.com/golang/protobuf/protoc-gen-go/descriptor
|
github.com/golang/protobuf/protoc-gen-go/descriptor
|
||||||
github.com/golang/protobuf/ptypes
|
github.com/golang/protobuf/ptypes
|
||||||
@@ -80,7 +79,7 @@ github.com/google/go-cmp/cmp/internal/value
|
|||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/google/gofuzz
|
github.com/google/gofuzz
|
||||||
github.com/google/gofuzz/bytesource
|
github.com/google/gofuzz/bytesource
|
||||||
# github.com/google/uuid v1.4.0
|
# github.com/google/uuid v1.6.0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/google/uuid
|
github.com/google/uuid
|
||||||
# github.com/imdario/mergo v0.3.13
|
# github.com/imdario/mergo v0.3.13
|
||||||
@@ -228,10 +227,10 @@ google.golang.org/appengine/internal/log
|
|||||||
google.golang.org/appengine/internal/remote_api
|
google.golang.org/appengine/internal/remote_api
|
||||||
google.golang.org/appengine/internal/urlfetch
|
google.golang.org/appengine/internal/urlfetch
|
||||||
google.golang.org/appengine/urlfetch
|
google.golang.org/appengine/urlfetch
|
||||||
# google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17
|
# google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80
|
||||||
## explicit; go 1.19
|
## explicit; go 1.19
|
||||||
google.golang.org/genproto/googleapis/rpc/status
|
google.golang.org/genproto/googleapis/rpc/status
|
||||||
# google.golang.org/grpc v1.61.1
|
# google.golang.org/grpc v1.62.1
|
||||||
## explicit; go 1.19
|
## explicit; go 1.19
|
||||||
google.golang.org/grpc
|
google.golang.org/grpc
|
||||||
google.golang.org/grpc/attributes
|
google.golang.org/grpc/attributes
|
||||||
@@ -313,6 +312,7 @@ google.golang.org/protobuf/internal/set
|
|||||||
google.golang.org/protobuf/internal/strs
|
google.golang.org/protobuf/internal/strs
|
||||||
google.golang.org/protobuf/internal/version
|
google.golang.org/protobuf/internal/version
|
||||||
google.golang.org/protobuf/proto
|
google.golang.org/protobuf/proto
|
||||||
|
google.golang.org/protobuf/protoadapt
|
||||||
google.golang.org/protobuf/reflect/protodesc
|
google.golang.org/protobuf/reflect/protodesc
|
||||||
google.golang.org/protobuf/reflect/protoreflect
|
google.golang.org/protobuf/reflect/protoreflect
|
||||||
google.golang.org/protobuf/reflect/protoregistry
|
google.golang.org/protobuf/reflect/protoregistry
|
||||||
|
Reference in New Issue
Block a user