diff --git a/.github/workflows/post-merge.yaml b/.github/workflows/checks.yaml similarity index 71% rename from .github/workflows/post-merge.yaml rename to .github/workflows/checks.yaml index abd2f573c..1c9fd4f0b 100644 --- a/.github/workflows/post-merge.yaml +++ b/.github/workflows/checks.yaml @@ -1,9 +1,12 @@ -name: Post Merge +name: Checks on: push: branches: - master + pull_request: + branches: + - master jobs: go-build: @@ -41,6 +44,7 @@ jobs: deploy: name: Push Latest Release + if: github.ref == 'refs/heads/master' # only true for pushes to `master` runs-on: ubuntu-18.04 steps: - name: Check out code @@ -57,7 +61,7 @@ jobs: run: make deploy-ci e2e: - name: End-to-End Test + name: Istio End-to-End Test runs-on: ubuntu-18.04 steps: - name: Check out code @@ -86,3 +90,26 @@ jobs: - name: Cleanup run: kind delete cluster + + e2e-envoy-grpc: + name: Envoy gRPC End-to-End Test + runs-on: ubuntu-18.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Build docker image + run: make image tag-latest + + - name: Build testsrv docker image + run: make testsrv-image + working-directory: examples/grpc + + - name: Run test + run: make test-setup test + working-directory: examples/grpc + + - name: Run test log dump and cleanup + run: make test-teardown + if: ${{ always() }} + working-directory: examples/grpc diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml deleted file mode 100644 index 5cb68e85c..000000000 --- a/.github/workflows/pull-request.yaml +++ /dev/null @@ -1,68 +0,0 @@ -name: PR Check - -on: [pull_request] - -jobs: - go-build: - name: Go Build - runs-on: ubuntu-18.04 - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Build Golang - run: make build - timeout-minutes: 15 - - go-test: - name: Go Test - runs-on: ubuntu-18.04 - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Unit Test Golang - run: make test - timeout-minutes: 15 - - go-lint: - name: Go Lint - runs-on: ubuntu-18.04 - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Golang Style and Lint Check - run: make check - timeout-minutes: 15 - - e2e: - name: End-to-End Test - runs-on: ubuntu-18.04 - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Build docker image - run: make image tag-latest - - - name: Setup kind/istio - run: | - # install kind, kubectl, istio - make test-cluster - - # Install bats - sudo apt-get update -y - sudo apt-get install -y bats - - # Prepare quick_start.yaml - make update-istio-quickstart-version - - # Make docker image available to k8s - kind load docker-image openpolicyagent/opa:latest-istio - - - name: Run e2e tests - run: make test-e2e - - - name: Cleanup - run: kind delete cluster diff --git a/Makefile b/Makefile index 8b7cd944f..2ae23a8a8 100644 --- a/Makefile +++ b/Makefile @@ -129,6 +129,13 @@ check-vet: check-lint: ./build/check-lint.sh +generatepb: + protoc --proto_path=test/files \ + --descriptor_set_out=test/files/combined.pb \ + --include_imports \ + test/files/example/Example.proto \ + test/files/book/Book.proto + .PHONY: release release: docker run $(DOCKER_FLAGS) \ diff --git a/README.md b/README.md index 21362474f..da51e60a0 100644 --- a/README.md +++ b/README.md @@ -157,12 +157,14 @@ volumes: The OPA-Envoy plugin supports the following configuration fields: -| Field | Required | Description | -| --- | --- | --- | -| `plugins["envoy_ext_authz_grpc"].addr` | No | Set listening address of Envoy External Authorization gRPC server. This must match the value configured in the Envoy config. Default: `:9191`. | -| `plugins["envoy_ext_authz_grpc"].path` | No | Specifies the hierarchical policy decision path. The policy decision can either be a `boolean` or an `object`. If boolean, `true` indicates the request should be allowed and `false` indicates the request should be denied. If the policy decision is an object, it **must** contain the `allowed` key set to either `true` or `false` to indicate if the request is allowed or not respectively. It can optionally contain a `headers` field to send custom headers to the downstream client or upstream. An optional `body` field can be included in the policy decision to send a response body data to the downstream client. Also an optional `http_status` field can be included to send a HTTP response status code to the downstream client other than `403 (Forbidden)`. Default: `envoy/authz/allow`.| -| `plugins["envoy_ext_authz_grpc"].dry-run` | No | Configures the Envoy External Authorization gRPC server to unconditionally return an `ext_authz.CheckResponse.Status` of `google_rpc.Status{Code: google_rpc.OK}`. Default: `false`. | -| `plugins["envoy_ext_authz_grpc"].enable-reflection` | No | Enables gRPC server reflection on the Envoy External Authorization gRPC server. Default: `false`. | + +| Field | Required | Description | +| --------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `plugins["envoy_ext_authz_grpc"].addr` | No | Set listening address of Envoy External Authorization gRPC server. This must match the value configured in the Envoy config. Default: `:9191`. | +| `plugins["envoy_ext_authz_grpc"].path` | No | Specifies the hierarchical policy decision path. The policy decision can either be a `boolean` or an `object`. If boolean, `true` indicates the request should be allowed and `false` indicates the request should be denied. If the policy decision is an object, it **must** contain the `allowed` key set to either `true` or `false` to indicate if the request is allowed or not respectively. It can optionally contain a `headers` field to send custom headers to the downstream client or upstream. An optional `body` field can be included in the policy decision to send a response body data to the downstream client. Also an optional `http_status` field can be included to send a HTTP response status code to the downstream client other than `403 (Forbidden)`. Default: `envoy/authz/allow`. | +| `plugins["envoy_ext_authz_grpc"].dry-run` | No | Configures the Envoy External Authorization gRPC server to unconditionally return an `ext_authz.CheckResponse.Status` of `google_rpc.Status{Code: google_rpc.OK}`. Default: `false`. | +| `plugins["envoy_ext_authz_grpc"].enable-reflection` | No | Enables gRPC server reflection on the Envoy External Authorization gRPC server. Default: `false`. | +| `plugins["envoy_ext_authz_grpc"].proto-descriptor` | No | Set the path to a pb that enables the capability to decode the raw body to the parsed body. Default: turns this capability off. | If the configuration does not specify the `path` field, `envoy/authz/allow` will be considered as the default policy decision path. `data.envoy.authz.allow` will be the name of the policy decision to query in the default case. @@ -175,6 +177,14 @@ The `enable-reflection` parameter registers the Envoy External Authorization gRP server reflection, a command line tool such as [grpcurl](https://github.com/fullstorydev/grpcurl) can be used to invoke RPC methods on the gRPC server. See [gRPC Server Reflection Usage](#grpc-server-reflection-usage) section for more details. +Providing a file containing a protobuf descriptor set allows the plugin to decode gRPC message payloads. +So far, only unary methods using uncompressed protobuf-encoded payloads are supported. +The protoset can be generated using `protoc`, e.g. `protoc --descriptor_set_out=protoset.pb --include_imports`. + +Note that gRPC message payload decoding is only available [using the v3 API](#envoy-xds-v2-and-v2). +See [`examples/grpc`](examples/grpc) for an example setup using Envoy, a gRPC service, and opa-envoy-plugin examining the +request payloads. + An example of a rule that returns an object that not only indicates if a request is allowed or not but also provides optional response headers, body and HTTP status that can be sent to the downstream client or upstream can be seen below in the [Example Policy with Object Response](#example-policy-with-object-response) section. @@ -198,11 +208,11 @@ bundles: envoy/authz: service: controller plugins: - envoy_ext_authz_grpc: - addr: :9191 - path: envoy/authz/allow - dry-run: false - enable-reflection: false + envoy_ext_authz_grpc: + addr: :9191 + path: envoy/authz/allow + dry-run: false + enable-reflection: false ``` You can download the bundle and inspect it yourself: diff --git a/examples/grpc/Makefile b/examples/grpc/Makefile new file mode 100644 index 000000000..70672c610 --- /dev/null +++ b/examples/grpc/Makefile @@ -0,0 +1,29 @@ +SHELL:=bash +GRPCURL_IMAGE:=fullstorydev/grpcurl:v1.7.0 +GRPCURL=docker run --network=host -i --rm -v $$(pwd)/testsrv.pb:/testsrv.pb $(GRPCURL_IMAGE) \ + -d @ -plaintext -protoset /testsrv.pb 127.0.0.1:51051 + +all: testsrv.pb testsrv-image test-setup test test-teardown + +.PHONY: testsrv-image +testsrv-image: + docker build -t testsrv testsrv/ + +testsrv.pb: testsrv/test.proto + protoc --include_imports -o "$@" "$<" + +.PHONY: test-setup +test-setup: + docker-compose up -d + +.PHONY: test-teardown +test-teardown: + docker-compose logs + docker-compose down + +.PHONY: test +test: + $(GRPCURL) test.KitchenSink/Ping <<<"{}" + $(GRPCURL) test.KitchenSink/Exchange < message.json + if sed s/alice/arno/ message.json | $(GRPCURL) test.KitchenSink/Exchange; then \ + echo "expected 'Permission Denied'"; exit 1; fi diff --git a/examples/grpc/README.md b/examples/grpc/README.md new file mode 100644 index 000000000..09bf5402f --- /dev/null +++ b/examples/grpc/README.md @@ -0,0 +1,82 @@ +# Envoy and gRPC example + +The docker-compose.yaml file defines three services: +1. testsrv, a gRPC server used for testing, created by [fullstorydev](https://github.com/fullstorydev/grpcui/tree/master/testing/cmd/testsvr) +2. opa-envoy-plugin, equipped with the descriptor set for testsrv +3. Envoy, configured to use opa-envoy-plugin as ext_authz service, using the v3 API, + and including the request payloads _as bytes_: + ```yaml + - name: envoy.ext_authz + typed_config: + '@type': type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz + transport_api_version: V3 + failure_mode_allow: false + grpc_service: + envoy_grpc: + cluster_name: opa-envoy + with_request_body: + allow_partial_message: true + max_request_bytes: 1024 + pack_as_bytes: true + ``` + +After spinning them up with `docker-compose up`, they can be exercised +using a gRPC client. + +This is an example invocation using `grpcurl`: + +```interactive +$ grpcurl -plaintext -protoset testsrv.pb 127.0.0.1:51051 test.KitchenSink/Ping +{ + +} +$ grpcurl -plaintext -protoset testsrv.pb 127.0.0.1:51051 test.KitchenSink/Exchange +ERROR: + Code: PermissionDenied + Message: +$ grpcurl -d @ -plaintext -protoset testsrv.pb 127.0.0.1:51051 test.KitchenSink/Exchange < message.json +{ + "person": { + "id": "123", + "name": "alice", + "parent": { + "id": "122", + "name": "bob" + } + }, + "state": "AWAITING_INPUT", + "neededNumA": 1.23, + "neededNumB": 1.23, + "opaqueId": "asdf", + "wk": { + "now": "2020-12-02T09:48:42.118723Z", + "period": "30s", + "neat": { + "@type": "googleapis.com/google.protobuf.StringValue", + "value": "Hithere" + }, + "object": { + "foo": "bar" + }, + "value": "string", + "list": [ + "zero", + "one", + "infinity" + ], + "bytes": "AAAA", + "string": "abcd", + "bool": true, + "double": 0.12, + "float": 0.12, + "smallInt": 1, + "bigInt": "2", + "smallId": 100, + "bigId": "101" + } +} +``` + +The policy used in this example, `policy.rego`, is quite artificial, but allows us +to show how different protobuf fields are going to look like when made available to +OPA. The service definition used can be found in `testsrv/test.proto`. diff --git a/examples/grpc/docker-compose.yaml b/examples/grpc/docker-compose.yaml new file mode 100644 index 000000000..47e918675 --- /dev/null +++ b/examples/grpc/docker-compose.yaml @@ -0,0 +1,26 @@ +version: '3' +services: + envoy: + image: envoyproxy/envoy:v1.16-latest + ports: + - "9901:9901" + - "51051:51051" + volumes: + - ./envoy.yaml:/etc/envoy/envoy.yaml + opa-envoy: + image: openpolicyagent/opa:latest-envoy + ports: + - "9191:9191" + command: + - run + - --server + - --config-file=/opa.yaml + - /policy.rego + volumes: + - ./testsrv.pb:/testsrv.pb + - ./policy.rego:/policy.rego + - ./opa.yaml:/opa.yaml + testsrv: + image: testsrv:latest + ports: + - "9090:9090" diff --git a/examples/grpc/envoy.yaml b/examples/grpc/envoy.yaml new file mode 100644 index 000000000..f9a65289a --- /dev/null +++ b/examples/grpc/envoy.yaml @@ -0,0 +1,80 @@ +admin: + access_log_path: /dev/stdout + address: + socket_address: { address: 0.0.0.0, port_value: 9901 } + +static_resources: + listeners: + - name: listener1 + address: + socket_address: { address: 0.0.0.0, port_value: 51051 } + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + stat_prefix: testsrv + codec_type: AUTO + route_config: + name: local_route + virtual_hosts: + - name: local_service + domains: ["*"] + routes: + - match: { prefix: "/" } + route: { cluster: testsrv, timeout: { seconds: 60 } } + http_filters: + - name: envoy.ext_authz + typed_config: + '@type': type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz + transport_api_version: V3 + failure_mode_allow: false + grpc_service: + envoy_grpc: + cluster_name: opa-envoy + with_request_body: + allow_partial_message: true + max_request_bytes: 1024 + pack_as_bytes: true + - name: envoy.filters.http.router + + clusters: + - name: testsrv + connect_timeout: 1.25s + type: LOGICAL_DNS + lb_policy: ROUND_ROBIN + http2_protocol_options: {} + load_assignment: + cluster_name: testsrv + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: testsrv + port_value: 9090 + - name: opa-envoy + connect_timeout: 1.25s + type: LOGICAL_DNS + lb_policy: ROUND_ROBIN + http2_protocol_options: {} + load_assignment: + cluster_name: opa-envoy + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: opa-envoy + port_value: 9191 +layered_runtime: + layers: + - name: static_layer_0 + static_layer: + envoy: + resource_limits: + listener: + example_listener_name: + connection_limit: 10000 + overload: + global_downstream_max_connections: 50000 diff --git a/examples/grpc/message.json b/examples/grpc/message.json new file mode 100644 index 000000000..5dd153e7a --- /dev/null +++ b/examples/grpc/message.json @@ -0,0 +1,36 @@ +{ + "person": { + "id": 123, + "name": "alice", + "parent": { + "id": 122, + "name": "bob" + } + }, + "state": "AWAITING_INPUT", + "neededNumA": 1.23, + "neededNumB": 1.23, + "opaqueId": "asdf", + "wk": { + "now": "2020-12-02T10:48:42.118723000+01:00", + "period": "30s", + "neat": { + "@type": "googleapis.com/google.protobuf.StringValue", + "value": "Hithere" + }, + "object": { + "foo": "bar" + }, + "value": "string", + "list": ["zero", "one", "infinity"], + "bytes": "AAAA", + "string": "abcd", + "bool": true, + "double": "0.12", + "float": "0.12", + "small_int": 1, + "big_int": 2, + "small_id": 100, + "big_id": 101 + } +} diff --git a/examples/grpc/opa.yaml b/examples/grpc/opa.yaml new file mode 100644 index 000000000..df7f4e890 --- /dev/null +++ b/examples/grpc/opa.yaml @@ -0,0 +1,9 @@ +plugins: + envoy_ext_authz_grpc: + addr: ":9191" + path: envoy/authz/allow + dry-run: false + enable-reflection: true + proto-descriptor: /testsrv.pb +decision_logs: + console: true diff --git a/examples/grpc/policy.rego b/examples/grpc/policy.rego new file mode 100644 index 000000000..631bb5409 --- /dev/null +++ b/examples/grpc/policy.rego @@ -0,0 +1,53 @@ +package envoy.authz + +default allow = false + +allow { + # for test.KitchenSink/Ping, we don't require anything + input.parsed_path = ["test.KitchenSink", "Ping"] +} + +allow { + input.parsed_path = ["test.KitchenSink", "Exchange"] + input.parsed_body = { + "neededNumA": 1.23, + "neededNumB": 1.23, + "opaqueId": "asdf", + "person": { + "id": "123", + "name": "alice", + "parent": { + "id": "122", + "name": "bob" + } + }, + "state": "AWAITING_INPUT", + "wk": { + "bigId": "101", + "bigInt": "2", + "bool": true, + "bytes": "AAAA", + "double": 0.12, + "float": 0.12, + "list": [ + "zero", + "one", + "infinity" + ], + "neat": { + "@type": "googleapis.com/google.protobuf.StringValue", + "value": "Hithere" + }, + "now": "2020-12-02T09:48:42.118723Z", + "object": { + "foo": "bar" + }, + "period": "30s", + "smallId": 100, + "smallInt": 1, + "string": "abcd", + "value": "string" + } + } +} + diff --git a/examples/grpc/testsrv.pb b/examples/grpc/testsrv.pb new file mode 100644 index 000000000..861440799 Binary files /dev/null and b/examples/grpc/testsrv.pb differ diff --git a/examples/grpc/testsrv/Dockerfile b/examples/grpc/testsrv/Dockerfile new file mode 100644 index 000000000..69b353351 --- /dev/null +++ b/examples/grpc/testsrv/Dockerfile @@ -0,0 +1,6 @@ +FROM golang:1.15 +WORKDIR /src +COPY . /src +RUN go build . +CMD ["/src/testsrv", "--port", "9090"] +EXPOSE 9090 diff --git a/examples/grpc/testsrv/go.mod b/examples/grpc/testsrv/go.mod new file mode 100644 index 000000000..f17aa799f --- /dev/null +++ b/examples/grpc/testsrv/go.mod @@ -0,0 +1,12 @@ +module github.com/open-policy-agent/opa-envoy-plugin/examples/grpc/testsrv + +go 1.15 + +require ( + github.com/golang/protobuf v1.4.3 + golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7 + golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 // indirect + golang.org/x/text v0.3.4 // indirect + google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e // indirect + google.golang.org/grpc v1.33.2 +) diff --git a/examples/grpc/testsrv/go.sum b/examples/grpc/testsrv/go.sum new file mode 100644 index 000000000..fc0c69667 --- /dev/null +++ b/examples/grpc/testsrv/go.sum @@ -0,0 +1,90 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7 h1:3uJsdck53FDIpWwLeAXlia9p4C8j0BO2xZrqzKpL0D8= +golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 h1:kzM6+9dur93BcC2kVlYl34cHU+TYZLanmpSJHVMmL64= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e h1:wYR00/Ht+i/79g/gzhdehBgLIJCklKoc8Q/NebdzzpY= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/examples/grpc/testsrv/test.pb.go b/examples/grpc/testsrv/test.pb.go new file mode 100644 index 000000000..3712e7834 --- /dev/null +++ b/examples/grpc/testsrv/test.pb.go @@ -0,0 +1,3657 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: test.proto + +package main + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + any "github.com/golang/protobuf/ptypes/any" + duration "github.com/golang/protobuf/ptypes/duration" + empty "github.com/golang/protobuf/ptypes/empty" + _struct "github.com/golang/protobuf/ptypes/struct" + timestamp "github.com/golang/protobuf/ptypes/timestamp" + wrappers "github.com/golang/protobuf/ptypes/wrappers" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type State int32 + +const ( + State_INVALID State = 0 + State_INITIAL State = 1 + State_PENDING State = 2 + State_RUNNING State = 3 + State_PAUSED State = 4 + State_AWAITING_INPUT State = 5 + State_CANCELLING State = 6 + State_COMPLETE State = 7 + State_CANCELLED State = 8 + State_FAILED State = 9 +) + +var State_name = map[int32]string{ + 0: "INVALID", + 1: "INITIAL", + 2: "PENDING", + 3: "RUNNING", + 4: "PAUSED", + 5: "AWAITING_INPUT", + 6: "CANCELLING", + 7: "COMPLETE", + 8: "CANCELLED", + 9: "FAILED", +} + +var State_value = map[string]int32{ + "INVALID": 0, + "INITIAL": 1, + "PENDING": 2, + "RUNNING": 3, + "PAUSED": 4, + "AWAITING_INPUT": 5, + "CANCELLING": 6, + "COMPLETE": 7, + "CANCELLED": 8, + "FAILED": 9, +} + +func (x State) Enum() *State { + p := new(State) + *p = x + return p +} + +func (x State) String() string { + return proto.EnumName(State_name, int32(x)) +} + +func (x *State) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(State_value, data, "State") + if err != nil { + return err + } + *x = State(value) + return nil +} + +func (State) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{0} +} + +type Void int32 + +const ( + Void_VOID Void = 0 +) + +var Void_name = map[int32]string{ + 0: "VOID", +} + +var Void_value = map[string]int32{ + "VOID": 0, +} + +func (x Void) Enum() *Void { + p := new(Void) + *p = x + return p +} + +func (x Void) String() string { + return proto.EnumName(Void_name, int32(x)) +} + +func (x *Void) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Void_value, data, "Void") + if err != nil { + return err + } + *x = Void(value) + return nil +} + +func (Void) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{1} +} + +type Person struct { + Id *uint64 `protobuf:"varint,1,req,name=id" json:"id,omitempty"` + Name *string `protobuf:"bytes,2,req,name=name" json:"name,omitempty"` + Address *Address `protobuf:"bytes,3,opt,name=address" json:"address,omitempty"` + Xyz *float64 `protobuf:"fixed64,4,opt,name=xyz,def=3.14159" json:"xyz,omitempty"` + Title *string `protobuf:"bytes,5,opt,name=title,def=overseer" json:"title,omitempty"` + Labels []string `protobuf:"bytes,6,rep,name=labels" json:"labels,omitempty"` + IsReal *bool `protobuf:"varint,7,opt,name=is_real,json=isReal,def=1" json:"is_real,omitempty"` + Opaque []byte `protobuf:"bytes,8,opt,name=opaque,def=\\001\\002\\003\\004" json:"opaque,omitempty"` + // Types that are valid to be assigned to Relative: + // *Person_Parent + // *Person_Sibling + // *Person_Child + // *Person_None + Relative isPerson_Relative `protobuf_oneof:"relative"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Person) Reset() { *m = Person{} } +func (m *Person) String() string { return proto.CompactTextString(m) } +func (*Person) ProtoMessage() {} +func (*Person) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{0} +} + +func (m *Person) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Person.Unmarshal(m, b) +} +func (m *Person) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Person.Marshal(b, m, deterministic) +} +func (m *Person) XXX_Merge(src proto.Message) { + xxx_messageInfo_Person.Merge(m, src) +} +func (m *Person) XXX_Size() int { + return xxx_messageInfo_Person.Size(m) +} +func (m *Person) XXX_DiscardUnknown() { + xxx_messageInfo_Person.DiscardUnknown(m) +} + +var xxx_messageInfo_Person proto.InternalMessageInfo + +const Default_Person_Xyz float64 = 3.14159 +const Default_Person_Title string = "overseer" +const Default_Person_IsReal bool = true + +var Default_Person_Opaque []byte = []byte("\x01\x02\x03\x04") + +func (m *Person) GetId() uint64 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *Person) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *Person) GetAddress() *Address { + if m != nil { + return m.Address + } + return nil +} + +func (m *Person) GetXyz() float64 { + if m != nil && m.Xyz != nil { + return *m.Xyz + } + return Default_Person_Xyz +} + +func (m *Person) GetTitle() string { + if m != nil && m.Title != nil { + return *m.Title + } + return Default_Person_Title +} + +func (m *Person) GetLabels() []string { + if m != nil { + return m.Labels + } + return nil +} + +func (m *Person) GetIsReal() bool { + if m != nil && m.IsReal != nil { + return *m.IsReal + } + return Default_Person_IsReal +} + +func (m *Person) GetOpaque() []byte { + if m != nil && m.Opaque != nil { + return m.Opaque + } + return append([]byte(nil), Default_Person_Opaque...) +} + +type isPerson_Relative interface { + isPerson_Relative() +} + +type Person_Parent struct { + Parent *Person `protobuf:"bytes,9,opt,name=parent,oneof"` +} + +type Person_Sibling struct { + Sibling *Person `protobuf:"bytes,10,opt,name=sibling,oneof"` +} + +type Person_Child struct { + Child *Person `protobuf:"bytes,11,opt,name=child,oneof"` +} + +type Person_None struct { + None Void `protobuf:"varint,12,opt,name=none,enum=test.Void,oneof"` +} + +func (*Person_Parent) isPerson_Relative() {} + +func (*Person_Sibling) isPerson_Relative() {} + +func (*Person_Child) isPerson_Relative() {} + +func (*Person_None) isPerson_Relative() {} + +func (m *Person) GetRelative() isPerson_Relative { + if m != nil { + return m.Relative + } + return nil +} + +func (m *Person) GetParent() *Person { + if x, ok := m.GetRelative().(*Person_Parent); ok { + return x.Parent + } + return nil +} + +func (m *Person) GetSibling() *Person { + if x, ok := m.GetRelative().(*Person_Sibling); ok { + return x.Sibling + } + return nil +} + +func (m *Person) GetChild() *Person { + if x, ok := m.GetRelative().(*Person_Child); ok { + return x.Child + } + return nil +} + +func (m *Person) GetNone() Void { + if x, ok := m.GetRelative().(*Person_None); ok { + return x.None + } + return Void_VOID +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Person) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Person_Parent)(nil), + (*Person_Sibling)(nil), + (*Person_Child)(nil), + (*Person_None)(nil), + } +} + +type Address struct { + Line1 *string `protobuf:"bytes,1,req,name=line1" json:"line1,omitempty"` + Line2 *string `protobuf:"bytes,2,opt,name=line2" json:"line2,omitempty"` + City *string `protobuf:"bytes,3,req,name=city" json:"city,omitempty"` + State *string `protobuf:"bytes,4,req,name=state" json:"state,omitempty"` + Zip *uint32 `protobuf:"varint,5,req,name=zip" json:"zip,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Address) Reset() { *m = Address{} } +func (m *Address) String() string { return proto.CompactTextString(m) } +func (*Address) ProtoMessage() {} +func (*Address) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{1} +} + +func (m *Address) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Address.Unmarshal(m, b) +} +func (m *Address) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Address.Marshal(b, m, deterministic) +} +func (m *Address) XXX_Merge(src proto.Message) { + xxx_messageInfo_Address.Merge(m, src) +} +func (m *Address) XXX_Size() int { + return xxx_messageInfo_Address.Size(m) +} +func (m *Address) XXX_DiscardUnknown() { + xxx_messageInfo_Address.DiscardUnknown(m) +} + +var xxx_messageInfo_Address proto.InternalMessageInfo + +func (m *Address) GetLine1() string { + if m != nil && m.Line1 != nil { + return *m.Line1 + } + return "" +} + +func (m *Address) GetLine2() string { + if m != nil && m.Line2 != nil { + return *m.Line2 + } + return "" +} + +func (m *Address) GetCity() string { + if m != nil && m.City != nil { + return *m.City + } + return "" +} + +func (m *Address) GetState() string { + if m != nil && m.State != nil { + return *m.State + } + return "" +} + +func (m *Address) GetZip() uint32 { + if m != nil && m.Zip != nil { + return *m.Zip + } + return 0 +} + +type WellKnowns struct { + Now *timestamp.Timestamp `protobuf:"bytes,1,req,name=now" json:"now,omitempty"` + Past *timestamp.Timestamp `protobuf:"bytes,2,opt,name=past" json:"past,omitempty"` + Futures []*timestamp.Timestamp `protobuf:"bytes,3,rep,name=futures" json:"futures,omitempty"` + Period *duration.Duration `protobuf:"bytes,4,req,name=period" json:"period,omitempty"` + NextInterval *duration.Duration `protobuf:"bytes,5,opt,name=next_interval,json=nextInterval" json:"next_interval,omitempty"` + HistoryIntervals []*duration.Duration `protobuf:"bytes,6,rep,name=history_intervals,json=historyIntervals" json:"history_intervals,omitempty"` + Neat *any.Any `protobuf:"bytes,7,req,name=neat" json:"neat,omitempty"` + Extra *any.Any `protobuf:"bytes,8,opt,name=extra" json:"extra,omitempty"` + Extensions []*any.Any `protobuf:"bytes,9,rep,name=extensions" json:"extensions,omitempty"` + Object *_struct.Struct `protobuf:"bytes,10,req,name=object" json:"object,omitempty"` + OptionalObject *_struct.Struct `protobuf:"bytes,11,opt,name=optional_object,json=optionalObject" json:"optional_object,omitempty"` + Objects []*_struct.Struct `protobuf:"bytes,12,rep,name=objects" json:"objects,omitempty"` + Value *_struct.Value `protobuf:"bytes,13,req,name=value" json:"value,omitempty"` + OptionalValue *_struct.Value `protobuf:"bytes,14,opt,name=optional_value,json=optionalValue" json:"optional_value,omitempty"` + Values []*_struct.Value `protobuf:"bytes,15,rep,name=values" json:"values,omitempty"` + List *_struct.ListValue `protobuf:"bytes,16,req,name=list" json:"list,omitempty"` + OptionalList *_struct.ListValue `protobuf:"bytes,17,opt,name=optional_list,json=optionalList" json:"optional_list,omitempty"` + Lists []*_struct.ListValue `protobuf:"bytes,18,rep,name=lists" json:"lists,omitempty"` + Bytes *wrappers.BytesValue `protobuf:"bytes,19,req,name=bytes" json:"bytes,omitempty"` + OptionalBytes *wrappers.BytesValue `protobuf:"bytes,20,opt,name=optional_bytes,json=optionalBytes" json:"optional_bytes,omitempty"` + ListOBytes []*wrappers.BytesValue `protobuf:"bytes,21,rep,name=list_o_bytes,json=listOBytes" json:"list_o_bytes,omitempty"` + String_ *wrappers.StringValue `protobuf:"bytes,22,req,name=string" json:"string,omitempty"` + OptionalString *wrappers.StringValue `protobuf:"bytes,23,opt,name=optional_string,json=optionalString" json:"optional_string,omitempty"` + ListOStrings []*wrappers.StringValue `protobuf:"bytes,24,rep,name=list_o_strings,json=listOStrings" json:"list_o_strings,omitempty"` + Bool *wrappers.BoolValue `protobuf:"bytes,25,req,name=bool" json:"bool,omitempty"` + OptionalBool *wrappers.BoolValue `protobuf:"bytes,26,opt,name=optional_bool,json=optionalBool" json:"optional_bool,omitempty"` + ListOBools []*wrappers.BoolValue `protobuf:"bytes,27,rep,name=list_o_bools,json=listOBools" json:"list_o_bools,omitempty"` + Double *wrappers.DoubleValue `protobuf:"bytes,28,req,name=double" json:"double,omitempty"` + OptionalDouble *wrappers.DoubleValue `protobuf:"bytes,29,opt,name=optional_double,json=optionalDouble" json:"optional_double,omitempty"` + ListODoubles []*wrappers.DoubleValue `protobuf:"bytes,30,rep,name=list_o_doubles,json=listODoubles" json:"list_o_doubles,omitempty"` + Float *wrappers.FloatValue `protobuf:"bytes,31,req,name=float" json:"float,omitempty"` + OptionalFloat *wrappers.FloatValue `protobuf:"bytes,32,opt,name=optional_float,json=optionalFloat" json:"optional_float,omitempty"` + ListOFloats []*wrappers.FloatValue `protobuf:"bytes,33,rep,name=list_o_floats,json=listOFloats" json:"list_o_floats,omitempty"` + SmallInt *wrappers.Int32Value `protobuf:"bytes,34,req,name=small_int,json=smallInt" json:"small_int,omitempty"` + OptionalSmallInt *wrappers.Int32Value `protobuf:"bytes,35,opt,name=optional_small_int,json=optionalSmallInt" json:"optional_small_int,omitempty"` + ListOSmallInts []*wrappers.Int32Value `protobuf:"bytes,36,rep,name=list_o_small_ints,json=listOSmallInts" json:"list_o_small_ints,omitempty"` + BigInt *wrappers.Int64Value `protobuf:"bytes,37,req,name=big_int,json=bigInt" json:"big_int,omitempty"` + OptionalBigInt *wrappers.Int64Value `protobuf:"bytes,38,opt,name=optional_big_int,json=optionalBigInt" json:"optional_big_int,omitempty"` + ListOBigInts []*wrappers.Int64Value `protobuf:"bytes,39,rep,name=list_o_big_ints,json=listOBigInts" json:"list_o_big_ints,omitempty"` + SmallId *wrappers.UInt32Value `protobuf:"bytes,40,req,name=small_id,json=smallId" json:"small_id,omitempty"` + OptionalSmallId *wrappers.UInt32Value `protobuf:"bytes,41,opt,name=optional_small_id,json=optionalSmallId" json:"optional_small_id,omitempty"` + ListOSmallIds []*wrappers.UInt32Value `protobuf:"bytes,42,rep,name=list_o_small_ids,json=listOSmallIds" json:"list_o_small_ids,omitempty"` + BigId *wrappers.UInt64Value `protobuf:"bytes,43,req,name=big_id,json=bigId" json:"big_id,omitempty"` + OptionalBigId *wrappers.UInt64Value `protobuf:"bytes,44,opt,name=optional_big_id,json=optionalBigId" json:"optional_big_id,omitempty"` + ListOBigIds []*wrappers.UInt64Value `protobuf:"bytes,45,rep,name=list_o_big_ids,json=listOBigIds" json:"list_o_big_ids,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WellKnowns) Reset() { *m = WellKnowns{} } +func (m *WellKnowns) String() string { return proto.CompactTextString(m) } +func (*WellKnowns) ProtoMessage() {} +func (*WellKnowns) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{2} +} + +func (m *WellKnowns) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WellKnowns.Unmarshal(m, b) +} +func (m *WellKnowns) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WellKnowns.Marshal(b, m, deterministic) +} +func (m *WellKnowns) XXX_Merge(src proto.Message) { + xxx_messageInfo_WellKnowns.Merge(m, src) +} +func (m *WellKnowns) XXX_Size() int { + return xxx_messageInfo_WellKnowns.Size(m) +} +func (m *WellKnowns) XXX_DiscardUnknown() { + xxx_messageInfo_WellKnowns.DiscardUnknown(m) +} + +var xxx_messageInfo_WellKnowns proto.InternalMessageInfo + +func (m *WellKnowns) GetNow() *timestamp.Timestamp { + if m != nil { + return m.Now + } + return nil +} + +func (m *WellKnowns) GetPast() *timestamp.Timestamp { + if m != nil { + return m.Past + } + return nil +} + +func (m *WellKnowns) GetFutures() []*timestamp.Timestamp { + if m != nil { + return m.Futures + } + return nil +} + +func (m *WellKnowns) GetPeriod() *duration.Duration { + if m != nil { + return m.Period + } + return nil +} + +func (m *WellKnowns) GetNextInterval() *duration.Duration { + if m != nil { + return m.NextInterval + } + return nil +} + +func (m *WellKnowns) GetHistoryIntervals() []*duration.Duration { + if m != nil { + return m.HistoryIntervals + } + return nil +} + +func (m *WellKnowns) GetNeat() *any.Any { + if m != nil { + return m.Neat + } + return nil +} + +func (m *WellKnowns) GetExtra() *any.Any { + if m != nil { + return m.Extra + } + return nil +} + +func (m *WellKnowns) GetExtensions() []*any.Any { + if m != nil { + return m.Extensions + } + return nil +} + +func (m *WellKnowns) GetObject() *_struct.Struct { + if m != nil { + return m.Object + } + return nil +} + +func (m *WellKnowns) GetOptionalObject() *_struct.Struct { + if m != nil { + return m.OptionalObject + } + return nil +} + +func (m *WellKnowns) GetObjects() []*_struct.Struct { + if m != nil { + return m.Objects + } + return nil +} + +func (m *WellKnowns) GetValue() *_struct.Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *WellKnowns) GetOptionalValue() *_struct.Value { + if m != nil { + return m.OptionalValue + } + return nil +} + +func (m *WellKnowns) GetValues() []*_struct.Value { + if m != nil { + return m.Values + } + return nil +} + +func (m *WellKnowns) GetList() *_struct.ListValue { + if m != nil { + return m.List + } + return nil +} + +func (m *WellKnowns) GetOptionalList() *_struct.ListValue { + if m != nil { + return m.OptionalList + } + return nil +} + +func (m *WellKnowns) GetLists() []*_struct.ListValue { + if m != nil { + return m.Lists + } + return nil +} + +func (m *WellKnowns) GetBytes() *wrappers.BytesValue { + if m != nil { + return m.Bytes + } + return nil +} + +func (m *WellKnowns) GetOptionalBytes() *wrappers.BytesValue { + if m != nil { + return m.OptionalBytes + } + return nil +} + +func (m *WellKnowns) GetListOBytes() []*wrappers.BytesValue { + if m != nil { + return m.ListOBytes + } + return nil +} + +func (m *WellKnowns) GetString_() *wrappers.StringValue { + if m != nil { + return m.String_ + } + return nil +} + +func (m *WellKnowns) GetOptionalString() *wrappers.StringValue { + if m != nil { + return m.OptionalString + } + return nil +} + +func (m *WellKnowns) GetListOStrings() []*wrappers.StringValue { + if m != nil { + return m.ListOStrings + } + return nil +} + +func (m *WellKnowns) GetBool() *wrappers.BoolValue { + if m != nil { + return m.Bool + } + return nil +} + +func (m *WellKnowns) GetOptionalBool() *wrappers.BoolValue { + if m != nil { + return m.OptionalBool + } + return nil +} + +func (m *WellKnowns) GetListOBools() []*wrappers.BoolValue { + if m != nil { + return m.ListOBools + } + return nil +} + +func (m *WellKnowns) GetDouble() *wrappers.DoubleValue { + if m != nil { + return m.Double + } + return nil +} + +func (m *WellKnowns) GetOptionalDouble() *wrappers.DoubleValue { + if m != nil { + return m.OptionalDouble + } + return nil +} + +func (m *WellKnowns) GetListODoubles() []*wrappers.DoubleValue { + if m != nil { + return m.ListODoubles + } + return nil +} + +func (m *WellKnowns) GetFloat() *wrappers.FloatValue { + if m != nil { + return m.Float + } + return nil +} + +func (m *WellKnowns) GetOptionalFloat() *wrappers.FloatValue { + if m != nil { + return m.OptionalFloat + } + return nil +} + +func (m *WellKnowns) GetListOFloats() []*wrappers.FloatValue { + if m != nil { + return m.ListOFloats + } + return nil +} + +func (m *WellKnowns) GetSmallInt() *wrappers.Int32Value { + if m != nil { + return m.SmallInt + } + return nil +} + +func (m *WellKnowns) GetOptionalSmallInt() *wrappers.Int32Value { + if m != nil { + return m.OptionalSmallInt + } + return nil +} + +func (m *WellKnowns) GetListOSmallInts() []*wrappers.Int32Value { + if m != nil { + return m.ListOSmallInts + } + return nil +} + +func (m *WellKnowns) GetBigInt() *wrappers.Int64Value { + if m != nil { + return m.BigInt + } + return nil +} + +func (m *WellKnowns) GetOptionalBigInt() *wrappers.Int64Value { + if m != nil { + return m.OptionalBigInt + } + return nil +} + +func (m *WellKnowns) GetListOBigInts() []*wrappers.Int64Value { + if m != nil { + return m.ListOBigInts + } + return nil +} + +func (m *WellKnowns) GetSmallId() *wrappers.UInt32Value { + if m != nil { + return m.SmallId + } + return nil +} + +func (m *WellKnowns) GetOptionalSmallId() *wrappers.UInt32Value { + if m != nil { + return m.OptionalSmallId + } + return nil +} + +func (m *WellKnowns) GetListOSmallIds() []*wrappers.UInt32Value { + if m != nil { + return m.ListOSmallIds + } + return nil +} + +func (m *WellKnowns) GetBigId() *wrappers.UInt64Value { + if m != nil { + return m.BigId + } + return nil +} + +func (m *WellKnowns) GetOptionalBigId() *wrappers.UInt64Value { + if m != nil { + return m.OptionalBigId + } + return nil +} + +func (m *WellKnowns) GetListOBigIds() []*wrappers.UInt64Value { + if m != nil { + return m.ListOBigIds + } + return nil +} + +type NumbersNumbersNumbers struct { + Usually_1 *int32 `protobuf:"varint,1,opt,name=usually_1,json=usually1,def=1" json:"usually_1,omitempty"` + SomeNum_1 *int32 `protobuf:"varint,2,opt,name=some_num_1,json=someNum1" json:"some_num_1,omitempty"` + NeededNum_1 *int32 `protobuf:"varint,3,req,name=needed_num_1,json=neededNum1" json:"needed_num_1,omitempty"` + Usually_2 *int64 `protobuf:"varint,4,opt,name=usually_2,json=usually2,def=2" json:"usually_2,omitempty"` + SomeNum_2 *int64 `protobuf:"varint,5,opt,name=some_num_2,json=someNum2" json:"some_num_2,omitempty"` + NeededNum_2 *int64 `protobuf:"varint,6,req,name=needed_num_2,json=neededNum2" json:"needed_num_2,omitempty"` + Usually_3 *uint32 `protobuf:"varint,7,opt,name=usually_3,json=usually3,def=3" json:"usually_3,omitempty"` + SomeNum_3 *uint32 `protobuf:"varint,8,opt,name=some_num_3,json=someNum3" json:"some_num_3,omitempty"` + NeededNum_3 *uint32 `protobuf:"varint,9,req,name=needed_num_3,json=neededNum3" json:"needed_num_3,omitempty"` + Usually_4 *uint64 `protobuf:"varint,10,opt,name=usually_4,json=usually4,def=4" json:"usually_4,omitempty"` + SomeNum_4 *uint64 `protobuf:"varint,11,opt,name=some_num_4,json=someNum4" json:"some_num_4,omitempty"` + NeededNum_4 *uint64 `protobuf:"varint,12,req,name=needed_num_4,json=neededNum4" json:"needed_num_4,omitempty"` + Usually_5 *int32 `protobuf:"zigzag32,13,opt,name=usually_5,json=usually5,def=5" json:"usually_5,omitempty"` + SomeNum_5 *int32 `protobuf:"zigzag32,14,opt,name=some_num_5,json=someNum5" json:"some_num_5,omitempty"` + NeededNum_5 *int32 `protobuf:"zigzag32,15,req,name=needed_num_5,json=neededNum5" json:"needed_num_5,omitempty"` + Usually_6 *int64 `protobuf:"zigzag64,16,opt,name=usually_6,json=usually6,def=6" json:"usually_6,omitempty"` + SomeNum_6 *int64 `protobuf:"zigzag64,17,opt,name=some_num_6,json=someNum6" json:"some_num_6,omitempty"` + NeededNum_6 *int64 `protobuf:"zigzag64,18,req,name=needed_num_6,json=neededNum6" json:"needed_num_6,omitempty"` + Usually_7 *uint32 `protobuf:"fixed32,19,opt,name=usually_7,json=usually7,def=7" json:"usually_7,omitempty"` + SomeNum_7 *uint32 `protobuf:"fixed32,20,opt,name=some_num_7,json=someNum7" json:"some_num_7,omitempty"` + NeededNum_7 *uint32 `protobuf:"fixed32,21,req,name=needed_num_7,json=neededNum7" json:"needed_num_7,omitempty"` + Usually_8 *uint64 `protobuf:"fixed64,22,opt,name=usually_8,json=usually8,def=8" json:"usually_8,omitempty"` + SomeNum_8 *uint64 `protobuf:"fixed64,23,opt,name=some_num_8,json=someNum8" json:"some_num_8,omitempty"` + NeededNum_8 *uint64 `protobuf:"fixed64,24,req,name=needed_num_8,json=neededNum8" json:"needed_num_8,omitempty"` + Usually_9 *int32 `protobuf:"fixed32,25,opt,name=usually_9,json=usually9,def=9" json:"usually_9,omitempty"` + SomeNum_9 *int32 `protobuf:"fixed32,26,opt,name=some_num_9,json=someNum9" json:"some_num_9,omitempty"` + NeededNum_9 *int32 `protobuf:"fixed32,27,req,name=needed_num_9,json=neededNum9" json:"needed_num_9,omitempty"` + Usually_10 *int64 `protobuf:"fixed64,28,opt,name=usually_10,json=usually10,def=10" json:"usually_10,omitempty"` + SomeNum_10 *int64 `protobuf:"fixed64,29,opt,name=some_num_10,json=someNum10" json:"some_num_10,omitempty"` + NeededNum_10 *int64 `protobuf:"fixed64,30,req,name=needed_num_10,json=neededNum10" json:"needed_num_10,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *NumbersNumbersNumbers) Reset() { *m = NumbersNumbersNumbers{} } +func (m *NumbersNumbersNumbers) String() string { return proto.CompactTextString(m) } +func (*NumbersNumbersNumbers) ProtoMessage() {} +func (*NumbersNumbersNumbers) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{3} +} + +func (m *NumbersNumbersNumbers) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_NumbersNumbersNumbers.Unmarshal(m, b) +} +func (m *NumbersNumbersNumbers) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_NumbersNumbersNumbers.Marshal(b, m, deterministic) +} +func (m *NumbersNumbersNumbers) XXX_Merge(src proto.Message) { + xxx_messageInfo_NumbersNumbersNumbers.Merge(m, src) +} +func (m *NumbersNumbersNumbers) XXX_Size() int { + return xxx_messageInfo_NumbersNumbersNumbers.Size(m) +} +func (m *NumbersNumbersNumbers) XXX_DiscardUnknown() { + xxx_messageInfo_NumbersNumbersNumbers.DiscardUnknown(m) +} + +var xxx_messageInfo_NumbersNumbersNumbers proto.InternalMessageInfo + +const Default_NumbersNumbersNumbers_Usually_1 int32 = 1 +const Default_NumbersNumbersNumbers_Usually_2 int64 = 2 +const Default_NumbersNumbersNumbers_Usually_3 uint32 = 3 +const Default_NumbersNumbersNumbers_Usually_4 uint64 = 4 +const Default_NumbersNumbersNumbers_Usually_5 int32 = 5 +const Default_NumbersNumbersNumbers_Usually_6 int64 = 6 +const Default_NumbersNumbersNumbers_Usually_7 uint32 = 7 +const Default_NumbersNumbersNumbers_Usually_8 uint64 = 8 +const Default_NumbersNumbersNumbers_Usually_9 int32 = 9 +const Default_NumbersNumbersNumbers_Usually_10 int64 = 10 + +func (m *NumbersNumbersNumbers) GetUsually_1() int32 { + if m != nil && m.Usually_1 != nil { + return *m.Usually_1 + } + return Default_NumbersNumbersNumbers_Usually_1 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_1() int32 { + if m != nil && m.SomeNum_1 != nil { + return *m.SomeNum_1 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_1() int32 { + if m != nil && m.NeededNum_1 != nil { + return *m.NeededNum_1 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_2() int64 { + if m != nil && m.Usually_2 != nil { + return *m.Usually_2 + } + return Default_NumbersNumbersNumbers_Usually_2 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_2() int64 { + if m != nil && m.SomeNum_2 != nil { + return *m.SomeNum_2 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_2() int64 { + if m != nil && m.NeededNum_2 != nil { + return *m.NeededNum_2 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_3() uint32 { + if m != nil && m.Usually_3 != nil { + return *m.Usually_3 + } + return Default_NumbersNumbersNumbers_Usually_3 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_3() uint32 { + if m != nil && m.SomeNum_3 != nil { + return *m.SomeNum_3 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_3() uint32 { + if m != nil && m.NeededNum_3 != nil { + return *m.NeededNum_3 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_4() uint64 { + if m != nil && m.Usually_4 != nil { + return *m.Usually_4 + } + return Default_NumbersNumbersNumbers_Usually_4 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_4() uint64 { + if m != nil && m.SomeNum_4 != nil { + return *m.SomeNum_4 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_4() uint64 { + if m != nil && m.NeededNum_4 != nil { + return *m.NeededNum_4 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_5() int32 { + if m != nil && m.Usually_5 != nil { + return *m.Usually_5 + } + return Default_NumbersNumbersNumbers_Usually_5 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_5() int32 { + if m != nil && m.SomeNum_5 != nil { + return *m.SomeNum_5 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_5() int32 { + if m != nil && m.NeededNum_5 != nil { + return *m.NeededNum_5 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_6() int64 { + if m != nil && m.Usually_6 != nil { + return *m.Usually_6 + } + return Default_NumbersNumbersNumbers_Usually_6 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_6() int64 { + if m != nil && m.SomeNum_6 != nil { + return *m.SomeNum_6 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_6() int64 { + if m != nil && m.NeededNum_6 != nil { + return *m.NeededNum_6 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_7() uint32 { + if m != nil && m.Usually_7 != nil { + return *m.Usually_7 + } + return Default_NumbersNumbersNumbers_Usually_7 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_7() uint32 { + if m != nil && m.SomeNum_7 != nil { + return *m.SomeNum_7 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_7() uint32 { + if m != nil && m.NeededNum_7 != nil { + return *m.NeededNum_7 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_8() uint64 { + if m != nil && m.Usually_8 != nil { + return *m.Usually_8 + } + return Default_NumbersNumbersNumbers_Usually_8 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_8() uint64 { + if m != nil && m.SomeNum_8 != nil { + return *m.SomeNum_8 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_8() uint64 { + if m != nil && m.NeededNum_8 != nil { + return *m.NeededNum_8 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_9() int32 { + if m != nil && m.Usually_9 != nil { + return *m.Usually_9 + } + return Default_NumbersNumbersNumbers_Usually_9 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_9() int32 { + if m != nil && m.SomeNum_9 != nil { + return *m.SomeNum_9 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_9() int32 { + if m != nil && m.NeededNum_9 != nil { + return *m.NeededNum_9 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetUsually_10() int64 { + if m != nil && m.Usually_10 != nil { + return *m.Usually_10 + } + return Default_NumbersNumbersNumbers_Usually_10 +} + +func (m *NumbersNumbersNumbers) GetSomeNum_10() int64 { + if m != nil && m.SomeNum_10 != nil { + return *m.SomeNum_10 + } + return 0 +} + +func (m *NumbersNumbersNumbers) GetNeededNum_10() int64 { + if m != nil && m.NeededNum_10 != nil { + return *m.NeededNum_10 + } + return 0 +} + +type Arrays struct { + Names []string `protobuf:"bytes,1,rep,name=names" json:"names,omitempty"` + Data [][]byte `protobuf:"bytes,2,rep,name=data" json:"data,omitempty"` + Relatives []*Person `protobuf:"bytes,3,rep,name=relatives" json:"relatives,omitempty"` + OtherStates []State `protobuf:"varint,14,rep,name=other_states,json=otherStates,enum=test.State" json:"other_states,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Arrays) Reset() { *m = Arrays{} } +func (m *Arrays) String() string { return proto.CompactTextString(m) } +func (*Arrays) ProtoMessage() {} +func (*Arrays) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{4} +} + +func (m *Arrays) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Arrays.Unmarshal(m, b) +} +func (m *Arrays) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Arrays.Marshal(b, m, deterministic) +} +func (m *Arrays) XXX_Merge(src proto.Message) { + xxx_messageInfo_Arrays.Merge(m, src) +} +func (m *Arrays) XXX_Size() int { + return xxx_messageInfo_Arrays.Size(m) +} +func (m *Arrays) XXX_DiscardUnknown() { + xxx_messageInfo_Arrays.DiscardUnknown(m) +} + +var xxx_messageInfo_Arrays proto.InternalMessageInfo + +func (m *Arrays) GetNames() []string { + if m != nil { + return m.Names + } + return nil +} + +func (m *Arrays) GetData() [][]byte { + if m != nil { + return m.Data + } + return nil +} + +func (m *Arrays) GetRelatives() []*Person { + if m != nil { + return m.Relatives + } + return nil +} + +func (m *Arrays) GetOtherStates() []State { + if m != nil { + return m.OtherStates + } + return nil +} + +type Maps struct { + StringSet map[string]Void `protobuf:"bytes,1,rep,name=string_set,json=stringSet" json:"string_set,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.Void"` + Int32Set map[int32]Void `protobuf:"bytes,2,rep,name=int32_set,json=int32Set" json:"int32_set,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.Void"` + Int64Set map[int64]Void `protobuf:"bytes,3,rep,name=int64_set,json=int64Set" json:"int64_set,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.Void"` + Uint32Set map[uint32]Void `protobuf:"bytes,4,rep,name=uint32_set,json=uint32Set" json:"uint32_set,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.Void"` + Uint64Set map[uint64]Void `protobuf:"bytes,5,rep,name=uint64_set,json=uint64Set" json:"uint64_set,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.Void"` + Sint32Set map[int32]Void `protobuf:"bytes,6,rep,name=sint32_set,json=sint32Set" json:"sint32_set,omitempty" protobuf_key:"zigzag32,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.Void"` + Sint64Set map[int64]Void `protobuf:"bytes,7,rep,name=sint64_set,json=sint64Set" json:"sint64_set,omitempty" protobuf_key:"zigzag64,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.Void"` + Fixed32Set map[uint32]*empty.Empty `protobuf:"bytes,8,rep,name=fixed32_set,json=fixed32Set" json:"fixed32_set,omitempty" protobuf_key:"fixed32,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Fixed64Set map[uint64]*empty.Empty `protobuf:"bytes,9,rep,name=fixed64_set,json=fixed64Set" json:"fixed64_set,omitempty" protobuf_key:"fixed64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Sfixed32Set map[int32]*empty.Empty `protobuf:"bytes,10,rep,name=sfixed32_set,json=sfixed32Set" json:"sfixed32_set,omitempty" protobuf_key:"fixed32,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Sfixed64Set map[int64]*empty.Empty `protobuf:"bytes,11,rep,name=sfixed64_set,json=sfixed64Set" json:"sfixed64_set,omitempty" protobuf_key:"fixed64,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + PeopleByEmployeeNum map[int32]*Person `protobuf:"bytes,12,rep,name=people_by_employee_num,json=peopleByEmployeeNum" json:"people_by_employee_num,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + States map[int32]State `protobuf:"bytes,13,rep,name=states" json:"states,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value,enum=test.State"` + StringNames map[string]string `protobuf:"bytes,14,rep,name=string_names,json=stringNames" json:"string_names,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + BytesNames map[string][]byte `protobuf:"bytes,15,rep,name=bytes_names,json=bytesNames" json:"bytes_names,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + BoolNames map[string]bool `protobuf:"bytes,16,rep,name=bool_names,json=boolNames" json:"bool_names,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"` + DoubleNames map[string]float64 `protobuf:"bytes,17,rep,name=double_names,json=doubleNames" json:"double_names,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"` + FloatNames map[string]float32 `protobuf:"bytes,18,rep,name=float_names,json=floatNames" json:"float_names,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Maps) Reset() { *m = Maps{} } +func (m *Maps) String() string { return proto.CompactTextString(m) } +func (*Maps) ProtoMessage() {} +func (*Maps) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{5} +} + +func (m *Maps) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Maps.Unmarshal(m, b) +} +func (m *Maps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Maps.Marshal(b, m, deterministic) +} +func (m *Maps) XXX_Merge(src proto.Message) { + xxx_messageInfo_Maps.Merge(m, src) +} +func (m *Maps) XXX_Size() int { + return xxx_messageInfo_Maps.Size(m) +} +func (m *Maps) XXX_DiscardUnknown() { + xxx_messageInfo_Maps.DiscardUnknown(m) +} + +var xxx_messageInfo_Maps proto.InternalMessageInfo + +func (m *Maps) GetStringSet() map[string]Void { + if m != nil { + return m.StringSet + } + return nil +} + +func (m *Maps) GetInt32Set() map[int32]Void { + if m != nil { + return m.Int32Set + } + return nil +} + +func (m *Maps) GetInt64Set() map[int64]Void { + if m != nil { + return m.Int64Set + } + return nil +} + +func (m *Maps) GetUint32Set() map[uint32]Void { + if m != nil { + return m.Uint32Set + } + return nil +} + +func (m *Maps) GetUint64Set() map[uint64]Void { + if m != nil { + return m.Uint64Set + } + return nil +} + +func (m *Maps) GetSint32Set() map[int32]Void { + if m != nil { + return m.Sint32Set + } + return nil +} + +func (m *Maps) GetSint64Set() map[int64]Void { + if m != nil { + return m.Sint64Set + } + return nil +} + +func (m *Maps) GetFixed32Set() map[uint32]*empty.Empty { + if m != nil { + return m.Fixed32Set + } + return nil +} + +func (m *Maps) GetFixed64Set() map[uint64]*empty.Empty { + if m != nil { + return m.Fixed64Set + } + return nil +} + +func (m *Maps) GetSfixed32Set() map[int32]*empty.Empty { + if m != nil { + return m.Sfixed32Set + } + return nil +} + +func (m *Maps) GetSfixed64Set() map[int64]*empty.Empty { + if m != nil { + return m.Sfixed64Set + } + return nil +} + +func (m *Maps) GetPeopleByEmployeeNum() map[int32]*Person { + if m != nil { + return m.PeopleByEmployeeNum + } + return nil +} + +func (m *Maps) GetStates() map[int32]State { + if m != nil { + return m.States + } + return nil +} + +func (m *Maps) GetStringNames() map[string]string { + if m != nil { + return m.StringNames + } + return nil +} + +func (m *Maps) GetBytesNames() map[string][]byte { + if m != nil { + return m.BytesNames + } + return nil +} + +func (m *Maps) GetBoolNames() map[string]bool { + if m != nil { + return m.BoolNames + } + return nil +} + +func (m *Maps) GetDoubleNames() map[string]float64 { + if m != nil { + return m.DoubleNames + } + return nil +} + +func (m *Maps) GetFloatNames() map[string]float32 { + if m != nil { + return m.FloatNames + } + return nil +} + +type TestMessage struct { + Recurse *TestMessage `protobuf:"bytes,2,opt,name=recurse" json:"recurse,omitempty"` + RepeatedRecurse []*TestMessage `protobuf:"bytes,3,rep,name=repeated_recurse,json=repeatedRecurse" json:"repeated_recurse,omitempty"` + Person *Person `protobuf:"bytes,4,req,name=person" json:"person,omitempty"` + State *State `protobuf:"varint,5,req,name=state,enum=test.State" json:"state,omitempty"` + Numbers *NumbersNumbersNumbers `protobuf:"bytes,6,opt,name=numbers" json:"numbers,omitempty"` + Usually_4242 *float32 `protobuf:"fixed32,7,opt,name=usually_4242,json=usually4242,def=4242" json:"usually_4242,omitempty"` + SomeNumA *float32 `protobuf:"fixed32,8,opt,name=some_num_a,json=someNumA" json:"some_num_a,omitempty"` + NeededNumA *float32 `protobuf:"fixed32,9,req,name=needed_num_a,json=neededNumA" json:"needed_num_a,omitempty"` + Usually_9999 *float64 `protobuf:"fixed64,10,opt,name=usually_9999,json=usually9999,def=9999" json:"usually_9999,omitempty"` + SomeNumB *float64 `protobuf:"fixed64,11,opt,name=some_num_b,json=someNumB" json:"some_num_b,omitempty"` + NeededNumB *float64 `protobuf:"fixed64,12,req,name=needed_num_b,json=neededNumB" json:"needed_num_b,omitempty"` + NextState *State `protobuf:"varint,13,opt,name=next_state,json=nextState,enum=test.State,def=2" json:"next_state,omitempty"` + Base64Stuff []byte `protobuf:"bytes,14,opt,name=base64_stuff,json=base64Stuff" json:"base64_stuff,omitempty"` + OpaqueId []byte `protobuf:"bytes,15,req,name=opaque_id,json=opaqueId" json:"opaque_id,omitempty"` + Wk *WellKnowns `protobuf:"bytes,16,opt,name=wk" json:"wk,omitempty"` + Arrays *Arrays `protobuf:"bytes,17,opt,name=arrays" json:"arrays,omitempty"` + Maps *Maps `protobuf:"bytes,18,opt,name=maps" json:"maps,omitempty"` + Misc *TestMessage_Misc `protobuf:"group,19,opt,name=Misc,json=misc" json:"misc,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TestMessage) Reset() { *m = TestMessage{} } +func (m *TestMessage) String() string { return proto.CompactTextString(m) } +func (*TestMessage) ProtoMessage() {} +func (*TestMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{6} +} + +func (m *TestMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TestMessage.Unmarshal(m, b) +} +func (m *TestMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TestMessage.Marshal(b, m, deterministic) +} +func (m *TestMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestMessage.Merge(m, src) +} +func (m *TestMessage) XXX_Size() int { + return xxx_messageInfo_TestMessage.Size(m) +} +func (m *TestMessage) XXX_DiscardUnknown() { + xxx_messageInfo_TestMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_TestMessage proto.InternalMessageInfo + +const Default_TestMessage_Usually_4242 float32 = 4242 +const Default_TestMessage_Usually_9999 float64 = 9999 +const Default_TestMessage_NextState State = State_PENDING + +func (m *TestMessage) GetRecurse() *TestMessage { + if m != nil { + return m.Recurse + } + return nil +} + +func (m *TestMessage) GetRepeatedRecurse() []*TestMessage { + if m != nil { + return m.RepeatedRecurse + } + return nil +} + +func (m *TestMessage) GetPerson() *Person { + if m != nil { + return m.Person + } + return nil +} + +func (m *TestMessage) GetState() State { + if m != nil && m.State != nil { + return *m.State + } + return State_INVALID +} + +func (m *TestMessage) GetNumbers() *NumbersNumbersNumbers { + if m != nil { + return m.Numbers + } + return nil +} + +func (m *TestMessage) GetUsually_4242() float32 { + if m != nil && m.Usually_4242 != nil { + return *m.Usually_4242 + } + return Default_TestMessage_Usually_4242 +} + +func (m *TestMessage) GetSomeNumA() float32 { + if m != nil && m.SomeNumA != nil { + return *m.SomeNumA + } + return 0 +} + +func (m *TestMessage) GetNeededNumA() float32 { + if m != nil && m.NeededNumA != nil { + return *m.NeededNumA + } + return 0 +} + +func (m *TestMessage) GetUsually_9999() float64 { + if m != nil && m.Usually_9999 != nil { + return *m.Usually_9999 + } + return Default_TestMessage_Usually_9999 +} + +func (m *TestMessage) GetSomeNumB() float64 { + if m != nil && m.SomeNumB != nil { + return *m.SomeNumB + } + return 0 +} + +func (m *TestMessage) GetNeededNumB() float64 { + if m != nil && m.NeededNumB != nil { + return *m.NeededNumB + } + return 0 +} + +func (m *TestMessage) GetNextState() State { + if m != nil && m.NextState != nil { + return *m.NextState + } + return Default_TestMessage_NextState +} + +func (m *TestMessage) GetBase64Stuff() []byte { + if m != nil { + return m.Base64Stuff + } + return nil +} + +func (m *TestMessage) GetOpaqueId() []byte { + if m != nil { + return m.OpaqueId + } + return nil +} + +func (m *TestMessage) GetWk() *WellKnowns { + if m != nil { + return m.Wk + } + return nil +} + +func (m *TestMessage) GetArrays() *Arrays { + if m != nil { + return m.Arrays + } + return nil +} + +func (m *TestMessage) GetMaps() *Maps { + if m != nil { + return m.Maps + } + return nil +} + +func (m *TestMessage) GetMisc() *TestMessage_Misc { + if m != nil { + return m.Misc + } + return nil +} + +type TestMessage_Misc struct { + Foo *string `protobuf:"bytes,1,opt,name=foo" json:"foo,omitempty"` + Bar *int32 `protobuf:"varint,2,opt,name=bar" json:"bar,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TestMessage_Misc) Reset() { *m = TestMessage_Misc{} } +func (m *TestMessage_Misc) String() string { return proto.CompactTextString(m) } +func (*TestMessage_Misc) ProtoMessage() {} +func (*TestMessage_Misc) Descriptor() ([]byte, []int) { + return fileDescriptor_c161fcfdc0c3ff1e, []int{6, 0} +} + +func (m *TestMessage_Misc) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TestMessage_Misc.Unmarshal(m, b) +} +func (m *TestMessage_Misc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TestMessage_Misc.Marshal(b, m, deterministic) +} +func (m *TestMessage_Misc) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestMessage_Misc.Merge(m, src) +} +func (m *TestMessage_Misc) XXX_Size() int { + return xxx_messageInfo_TestMessage_Misc.Size(m) +} +func (m *TestMessage_Misc) XXX_DiscardUnknown() { + xxx_messageInfo_TestMessage_Misc.DiscardUnknown(m) +} + +var xxx_messageInfo_TestMessage_Misc proto.InternalMessageInfo + +func (m *TestMessage_Misc) GetFoo() string { + if m != nil && m.Foo != nil { + return *m.Foo + } + return "" +} + +func (m *TestMessage_Misc) GetBar() int32 { + if m != nil && m.Bar != nil { + return *m.Bar + } + return 0 +} + +func init() { + proto.RegisterEnum("test.State", State_name, State_value) + proto.RegisterEnum("test.Void", Void_name, Void_value) + proto.RegisterType((*Person)(nil), "test.Person") + proto.RegisterType((*Address)(nil), "test.Address") + proto.RegisterType((*WellKnowns)(nil), "test.WellKnowns") + proto.RegisterType((*NumbersNumbersNumbers)(nil), "test.NumbersNumbersNumbers") + proto.RegisterType((*Arrays)(nil), "test.Arrays") + proto.RegisterType((*Maps)(nil), "test.Maps") + proto.RegisterMapType((map[string]bool)(nil), "test.Maps.BoolNamesEntry") + proto.RegisterMapType((map[string][]byte)(nil), "test.Maps.BytesNamesEntry") + proto.RegisterMapType((map[string]float64)(nil), "test.Maps.DoubleNamesEntry") + proto.RegisterMapType((map[uint32]*empty.Empty)(nil), "test.Maps.Fixed32SetEntry") + proto.RegisterMapType((map[uint64]*empty.Empty)(nil), "test.Maps.Fixed64SetEntry") + proto.RegisterMapType((map[string]float32)(nil), "test.Maps.FloatNamesEntry") + proto.RegisterMapType((map[int32]Void)(nil), "test.Maps.Int32SetEntry") + proto.RegisterMapType((map[int64]Void)(nil), "test.Maps.Int64SetEntry") + proto.RegisterMapType((map[int32]*Person)(nil), "test.Maps.PeopleByEmployeeNumEntry") + proto.RegisterMapType((map[int32]*empty.Empty)(nil), "test.Maps.Sfixed32SetEntry") + proto.RegisterMapType((map[int64]*empty.Empty)(nil), "test.Maps.Sfixed64SetEntry") + proto.RegisterMapType((map[int32]Void)(nil), "test.Maps.Sint32SetEntry") + proto.RegisterMapType((map[int64]Void)(nil), "test.Maps.Sint64SetEntry") + proto.RegisterMapType((map[int32]State)(nil), "test.Maps.StatesEntry") + proto.RegisterMapType((map[string]string)(nil), "test.Maps.StringNamesEntry") + proto.RegisterMapType((map[string]Void)(nil), "test.Maps.StringSetEntry") + proto.RegisterMapType((map[uint32]Void)(nil), "test.Maps.Uint32SetEntry") + proto.RegisterMapType((map[uint64]Void)(nil), "test.Maps.Uint64SetEntry") + proto.RegisterType((*TestMessage)(nil), "test.TestMessage") + proto.RegisterType((*TestMessage_Misc)(nil), "test.TestMessage.Misc") +} + +func init() { + proto.RegisterFile("test.proto", fileDescriptor_c161fcfdc0c3ff1e) +} + +var fileDescriptor_c161fcfdc0c3ff1e = []byte{ + // 3032 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x59, 0x5b, 0x73, 0xdb, 0x46, + 0xb2, 0x0e, 0x78, 0x67, 0x93, 0x94, 0xa8, 0xf1, 0x25, 0x63, 0xd9, 0x71, 0x60, 0x25, 0x27, 0xc1, + 0x71, 0x7c, 0x14, 0x8a, 0xa2, 0x6e, 0x4c, 0xec, 0x13, 0xca, 0x92, 0x6d, 0x9e, 0xd8, 0xb2, 0x0b, + 0x92, 0x9d, 0x53, 0x5b, 0xae, 0x62, 0x81, 0xc2, 0x48, 0xc6, 0x1a, 0x04, 0x18, 0x0c, 0x68, 0x9b, + 0x79, 0xdc, 0xc7, 0x7d, 0xd8, 0xa7, 0xad, 0xda, 0x7f, 0xb7, 0xef, 0xfb, 0x2b, 0x76, 0x6b, 0x2e, + 0x00, 0x07, 0x24, 0x41, 0xd9, 0xf2, 0x13, 0x81, 0x9e, 0xfe, 0xbe, 0xee, 0xe9, 0xe9, 0x69, 0x4e, + 0x63, 0x00, 0x42, 0x42, 0xc3, 0xf5, 0x61, 0xe0, 0x87, 0x3e, 0xca, 0xb1, 0xe7, 0xd5, 0x1b, 0xe7, + 0xbe, 0x7f, 0xee, 0x92, 0x1f, 0xb9, 0xac, 0x3f, 0x3a, 0xfb, 0xd1, 0xf2, 0xc6, 0x42, 0x61, 0xf5, + 0xf6, 0xf4, 0x90, 0x3d, 0x0a, 0xac, 0xd0, 0xf1, 0x3d, 0x39, 0x7e, 0x73, 0x7a, 0x9c, 0x0c, 0x86, + 0x61, 0x04, 0xbe, 0x35, 0x3d, 0x48, 0xc3, 0x60, 0x74, 0x2a, 0x6d, 0xaf, 0x7e, 0x3d, 0x3d, 0x1a, + 0x3a, 0x03, 0x42, 0x43, 0x6b, 0x30, 0x4c, 0xb3, 0xfd, 0x3e, 0xb0, 0x86, 0x43, 0x12, 0x50, 0x31, + 0xbe, 0xf6, 0x8f, 0x2c, 0x14, 0x5e, 0x90, 0x80, 0xfa, 0x1e, 0x5a, 0x82, 0x8c, 0x63, 0x63, 0x4d, + 0xcf, 0x18, 0x39, 0x33, 0xe3, 0xd8, 0x08, 0x41, 0xce, 0xb3, 0x06, 0x04, 0x67, 0xf4, 0x8c, 0x51, + 0x36, 0xf9, 0x33, 0xfa, 0x1e, 0x8a, 0x96, 0x6d, 0x07, 0x84, 0x52, 0x9c, 0xd5, 0x35, 0xa3, 0xd2, + 0xac, 0xad, 0xf3, 0x48, 0x74, 0x84, 0xd0, 0x8c, 0x46, 0xd1, 0x0d, 0xc8, 0x7e, 0x18, 0xff, 0x81, + 0x73, 0xba, 0x66, 0x68, 0xed, 0xe2, 0xe6, 0xfa, 0x46, 0x6b, 0x63, 0x6b, 0xcf, 0x64, 0x32, 0x74, + 0x1b, 0xf2, 0xa1, 0x13, 0xba, 0x04, 0xe7, 0x75, 0xcd, 0x28, 0xb7, 0x4b, 0xfe, 0x3b, 0x12, 0x50, + 0x42, 0x02, 0x53, 0x88, 0xd1, 0x75, 0x28, 0xb8, 0x56, 0x9f, 0xb8, 0x14, 0x17, 0xf4, 0xac, 0x51, + 0x36, 0xe5, 0x1b, 0xfa, 0x0a, 0x8a, 0x0e, 0xed, 0x05, 0xc4, 0x72, 0x71, 0x51, 0xd7, 0x8c, 0x52, + 0x3b, 0x17, 0x06, 0x23, 0x62, 0x16, 0x1c, 0x6a, 0x12, 0xcb, 0x45, 0x06, 0x14, 0xfc, 0xa1, 0xf5, + 0xfb, 0x88, 0xe0, 0x92, 0xae, 0x19, 0xd5, 0x76, 0xfd, 0x75, 0xa3, 0xb1, 0xf1, 0xba, 0xd1, 0x68, + 0xbe, 0x6e, 0x34, 0x36, 0x5f, 0x37, 0x1a, 0x2d, 0x53, 0x8e, 0xa3, 0xef, 0xa0, 0x30, 0xb4, 0x02, + 0xe2, 0x85, 0xb8, 0xcc, 0xe7, 0x50, 0x15, 0x73, 0x10, 0x61, 0x78, 0xf2, 0x85, 0x29, 0x47, 0x91, + 0x01, 0x45, 0xea, 0xf4, 0x5d, 0xc7, 0x3b, 0xc7, 0x30, 0x57, 0x31, 0x1a, 0x46, 0xdf, 0x42, 0xfe, + 0xf4, 0x8d, 0xe3, 0xda, 0xb8, 0x32, 0x57, 0x4f, 0x0c, 0x22, 0x1d, 0x72, 0x9e, 0xef, 0x11, 0x5c, + 0xd5, 0x35, 0x63, 0xa9, 0x09, 0x42, 0xe9, 0x95, 0xef, 0xd8, 0x4f, 0xbe, 0x30, 0xf9, 0xc8, 0x3e, + 0x40, 0x29, 0x20, 0xae, 0x15, 0x3a, 0xef, 0xc8, 0xda, 0xef, 0x50, 0x94, 0x51, 0x45, 0x57, 0x21, + 0xef, 0x3a, 0x1e, 0xd9, 0xe0, 0x8b, 0x53, 0x36, 0xc5, 0x4b, 0x24, 0x6d, 0xe2, 0x0c, 0x8b, 0xa3, + 0x90, 0x36, 0xd9, 0xaa, 0x9d, 0x3a, 0xe1, 0x18, 0x67, 0xc5, 0xaa, 0xb1, 0x67, 0xa6, 0x49, 0x43, + 0x2b, 0x24, 0x38, 0x27, 0xf0, 0xfc, 0x05, 0xd5, 0x21, 0xfb, 0x87, 0x33, 0xc4, 0x79, 0x3d, 0x63, + 0xd4, 0x4c, 0xf6, 0xb8, 0xf6, 0x97, 0x6b, 0x00, 0xbf, 0x11, 0xd7, 0xfd, 0xd5, 0xf3, 0xdf, 0x7b, + 0x14, 0xdd, 0x83, 0xac, 0xe7, 0xbf, 0xe7, 0x46, 0x2b, 0xcd, 0xd5, 0x75, 0x91, 0x49, 0xeb, 0x51, + 0x26, 0xad, 0x9f, 0x44, 0xa9, 0x66, 0x32, 0x35, 0xb4, 0x0e, 0xb9, 0xa1, 0x45, 0x43, 0xee, 0xcd, + 0x62, 0x75, 0xae, 0x87, 0x5a, 0x50, 0x3c, 0x1b, 0x85, 0xa3, 0x80, 0xb0, 0x54, 0xca, 0x5e, 0x00, + 0x89, 0x54, 0xd1, 0x06, 0x14, 0x86, 0x24, 0x70, 0x7c, 0x9b, 0xcf, 0xa5, 0xd2, 0xbc, 0x31, 0x03, + 0x3a, 0x90, 0x9b, 0xcb, 0x94, 0x8a, 0xe8, 0x01, 0xd4, 0x3c, 0xf2, 0x21, 0xec, 0x39, 0x5e, 0x48, + 0x82, 0x77, 0x96, 0xcb, 0xf3, 0x6e, 0x21, 0xb2, 0xca, 0xf4, 0xbb, 0x52, 0x1d, 0x3d, 0x82, 0x95, + 0x37, 0x0e, 0x0d, 0xfd, 0x60, 0x1c, 0x53, 0x88, 0xd4, 0x5c, 0xc8, 0x51, 0x97, 0x98, 0x88, 0x86, + 0x22, 0x03, 0x72, 0x1e, 0xb1, 0x42, 0x5c, 0xe4, 0x8e, 0x5f, 0x9d, 0x81, 0x76, 0xbc, 0xb1, 0xc9, + 0x35, 0xd0, 0x5d, 0xc8, 0x93, 0x0f, 0x61, 0x60, 0xf1, 0x4c, 0x4e, 0x53, 0x15, 0x2a, 0xa8, 0x05, + 0x40, 0x3e, 0x84, 0xc4, 0xa3, 0x8e, 0xef, 0x51, 0x5c, 0xe6, 0x6e, 0xcd, 0x07, 0x28, 0x7a, 0xe8, + 0x47, 0x28, 0xf8, 0xfd, 0x3f, 0x93, 0xd3, 0x10, 0x03, 0xf7, 0xe6, 0xcb, 0x19, 0xc4, 0x31, 0x2f, + 0x33, 0xa6, 0x54, 0x43, 0xbf, 0xc0, 0xb2, 0x3f, 0x64, 0x13, 0xb3, 0xdc, 0x9e, 0x44, 0x8a, 0x5c, + 0x4f, 0x45, 0x2e, 0x45, 0xfa, 0xcf, 0x05, 0xc3, 0x06, 0x14, 0x05, 0x90, 0xe2, 0x2a, 0xf7, 0x32, + 0x15, 0x19, 0xe9, 0xa1, 0x7b, 0x90, 0x7f, 0x67, 0xb9, 0x23, 0x82, 0x6b, 0xdc, 0xc9, 0xeb, 0x33, + 0x80, 0x57, 0x6c, 0xd4, 0x14, 0x4a, 0xe8, 0x3e, 0xc4, 0x26, 0x7b, 0x02, 0xb6, 0xc4, 0x3d, 0x4c, + 0x83, 0xd5, 0x22, 0x6d, 0xfe, 0x8a, 0xd6, 0xa1, 0xc0, 0x51, 0x14, 0x2f, 0x73, 0xf7, 0xd2, 0x60, + 0x52, 0x8b, 0xe5, 0xbb, 0xeb, 0xd0, 0x10, 0xd7, 0x53, 0xb6, 0xc7, 0x53, 0x87, 0x86, 0x02, 0xc1, + 0xf5, 0xd0, 0xff, 0x42, 0x6c, 0xb0, 0xc7, 0x81, 0x2b, 0x29, 0x1b, 0x65, 0x02, 0xac, 0x46, 0x00, + 0x26, 0x42, 0x0d, 0xb6, 0xdf, 0x69, 0x48, 0x31, 0x4a, 0xd9, 0x2e, 0x13, 0xa0, 0x50, 0x44, 0x1b, + 0x90, 0xef, 0x8f, 0x43, 0x42, 0xf1, 0x15, 0xee, 0xe3, 0xcd, 0x19, 0xc4, 0x3e, 0x1b, 0x95, 0x10, + 0xae, 0x89, 0xf6, 0x95, 0x20, 0x0a, 0xec, 0x55, 0xee, 0xe6, 0x42, 0x6c, 0x3c, 0x31, 0x2e, 0x43, + 0xf7, 0xa1, 0xca, 0xec, 0xf7, 0x7c, 0xc9, 0x70, 0x8d, 0xfb, 0xbb, 0x90, 0x01, 0x18, 0xe0, 0xb9, + 0x80, 0xb7, 0xa0, 0x40, 0xc3, 0x80, 0x55, 0xdd, 0xeb, 0xdc, 0xed, 0x5b, 0xf3, 0xf2, 0xc4, 0xf1, + 0xce, 0xe5, 0x72, 0x08, 0x5d, 0x74, 0xa8, 0x24, 0xa8, 0x84, 0x7f, 0xc9, 0x3d, 0x5f, 0x0c, 0x8f, + 0x67, 0x2b, 0x84, 0x6c, 0xfe, 0xd2, 0x77, 0x41, 0x42, 0x31, 0xe6, 0xde, 0x2f, 0x66, 0xe1, 0xf3, + 0x7d, 0x2e, 0x24, 0x3c, 0x33, 0xfa, 0xbe, 0xef, 0xe2, 0x1b, 0x29, 0x99, 0xb1, 0xef, 0xfb, 0xae, + 0xcc, 0x0c, 0xa6, 0x97, 0xc8, 0x0c, 0x0e, 0x5c, 0x4d, 0xc9, 0x8c, 0x09, 0x30, 0xce, 0x0c, 0x26, + 0x42, 0x3f, 0x4f, 0x02, 0xee, 0xfb, 0x2e, 0xc5, 0x37, 0x53, 0x12, 0x64, 0x82, 0x97, 0xf1, 0x66, + 0xda, 0x2c, 0xde, 0xb6, 0x3f, 0xea, 0xbb, 0x04, 0xdf, 0x4a, 0x89, 0xf7, 0x01, 0x1f, 0x96, 0xf1, + 0x16, 0xba, 0x89, 0x78, 0x4b, 0xf8, 0x57, 0x29, 0xf1, 0x56, 0xe1, 0x71, 0xbc, 0x85, 0x50, 0x89, + 0xb7, 0x20, 0xa1, 0xf8, 0x76, 0x4a, 0xbc, 0x55, 0x16, 0x11, 0x6f, 0x21, 0xe1, 0x69, 0x7e, 0xe6, + 0xfa, 0x56, 0x88, 0xbf, 0x4e, 0x49, 0xf3, 0x47, 0x6c, 0x54, 0xa6, 0x39, 0xd7, 0x4c, 0xa4, 0xb9, + 0xc0, 0xea, 0x29, 0x69, 0xae, 0x60, 0xe3, 0x55, 0xe2, 0x32, 0xb6, 0x6c, 0xd2, 0x75, 0xce, 0x40, + 0xf1, 0x9d, 0x94, 0x3c, 0x57, 0x28, 0x2a, 0xdc, 0x71, 0x2e, 0xa0, 0x68, 0x17, 0xca, 0x74, 0x60, + 0xb9, 0x2e, 0xfb, 0x5b, 0xc1, 0x6b, 0x29, 0xbe, 0x77, 0xbd, 0x70, 0xb3, 0x29, 0xc0, 0x25, 0xae, + 0xdd, 0xf5, 0x42, 0xd4, 0x05, 0x34, 0x49, 0xf6, 0x98, 0xe2, 0x9b, 0x94, 0x29, 0x28, 0x14, 0xf5, + 0x38, 0xdd, 0x23, 0xaa, 0x47, 0xb0, 0x12, 0x25, 0x7c, 0x44, 0x44, 0xf1, 0xb7, 0x29, 0x33, 0x51, + 0x98, 0x96, 0x44, 0xca, 0x4b, 0x1a, 0x96, 0x45, 0xc5, 0xbe, 0x73, 0xce, 0xfd, 0xf8, 0xaf, 0xf4, + 0xa9, 0x6c, 0xb7, 0x64, 0x16, 0xf5, 0x9d, 0x73, 0x66, 0xfd, 0x10, 0xea, 0x93, 0xd4, 0x97, 0xf0, + 0xef, 0xd2, 0xa7, 0x11, 0xc1, 0xe3, 0xc5, 0xdb, 0x17, 0x34, 0xfb, 0xb0, 0x1c, 0x6d, 0x00, 0x41, + 0x42, 0xf1, 0xf7, 0xe9, 0x53, 0x88, 0x58, 0x44, 0x16, 0x09, 0x0a, 0x8a, 0x76, 0xa0, 0x24, 0x23, + 0x60, 0x63, 0x23, 0x65, 0x23, 0xbc, 0x54, 0x02, 0x50, 0x14, 0xab, 0x61, 0xa3, 0x27, 0xb0, 0x32, + 0xbd, 0x18, 0x36, 0xfe, 0xef, 0x94, 0xbd, 0xa0, 0x32, 0x2c, 0x27, 0x17, 0xc3, 0x66, 0xd1, 0x48, + 0xae, 0x85, 0x4d, 0xf1, 0xdd, 0x94, 0xed, 0xa0, 0x12, 0xd5, 0x94, 0xb5, 0xb0, 0x29, 0xda, 0x84, + 0x02, 0x0f, 0x83, 0x8d, 0x7f, 0x58, 0x30, 0x8f, 0x28, 0x0a, 0x79, 0xb6, 0x14, 0x36, 0x3a, 0x50, + 0xf6, 0xb3, 0x44, 0xdf, 0x5b, 0x30, 0x87, 0x08, 0x5d, 0x53, 0x57, 0xc2, 0x46, 0x9d, 0x78, 0x3b, + 0x0b, 0x0e, 0x8a, 0xff, 0x67, 0x81, 0xff, 0x11, 0x49, 0x25, 0x5e, 0x08, 0x9b, 0xae, 0xfd, 0xb3, + 0x08, 0xd7, 0x8e, 0x46, 0x83, 0x3e, 0x09, 0x68, 0xf2, 0x07, 0xdd, 0x86, 0xf2, 0x88, 0x8e, 0x2c, + 0xd7, 0x1d, 0xf7, 0xd8, 0x51, 0x58, 0x33, 0xf2, 0x6d, 0x6d, 0xc3, 0x2c, 0x49, 0xd9, 0x06, 0xba, + 0x05, 0x40, 0xfd, 0x01, 0xe9, 0x79, 0xa3, 0x41, 0x6f, 0x83, 0x9f, 0x43, 0xf3, 0x66, 0x89, 0x49, + 0x8e, 0x46, 0x83, 0x0d, 0xa4, 0x43, 0xd5, 0x23, 0xc4, 0x26, 0xb6, 0x1c, 0x67, 0x07, 0xe4, 0xbc, + 0x09, 0x42, 0xc6, 0x35, 0x14, 0xfe, 0x26, 0xef, 0x5c, 0xb2, 0x6d, 0xad, 0x19, 0xf3, 0x37, 0x13, + 0xfc, 0x4d, 0x7e, 0x8a, 0xcc, 0xc6, 0xfc, 0xcd, 0x29, 0xfe, 0x26, 0x2e, 0xe8, 0x19, 0x23, 0xab, + 0xf0, 0x37, 0x55, 0xfe, 0x4d, 0xde, 0xc2, 0xd4, 0xda, 0xda, 0x66, 0xcc, 0xbf, 0x99, 0xe0, 0xdf, + 0xe4, 0x67, 0xbf, 0x5a, 0xcc, 0xbf, 0x39, 0xc5, 0xbf, 0x89, 0xcb, 0xfc, 0xdc, 0x3e, 0xe1, 0xdf, + 0x54, 0xf9, 0x5b, 0xbc, 0x63, 0xc9, 0xb5, 0xb5, 0x56, 0xcc, 0xdf, 0x4a, 0xf0, 0xb7, 0xf8, 0xf1, + 0x2d, 0x17, 0xf3, 0xb7, 0xa6, 0xf8, 0x5b, 0xb8, 0xca, 0x1b, 0xc1, 0x09, 0x7f, 0x4b, 0xe5, 0xdf, + 0xc2, 0x35, 0x5d, 0x33, 0x56, 0xda, 0xda, 0x56, 0xcc, 0xbf, 0x95, 0xe0, 0xdf, 0xe2, 0x87, 0xaf, + 0x95, 0x98, 0x7f, 0x6b, 0x8a, 0x7f, 0x0b, 0x2f, 0xeb, 0x19, 0x63, 0x45, 0xe1, 0xdf, 0x52, 0xf9, + 0xb7, 0x71, 0x5d, 0xd7, 0x0c, 0xd4, 0xd6, 0xb6, 0x63, 0xfe, 0xed, 0x04, 0xff, 0x36, 0x3f, 0x3e, + 0xa1, 0x98, 0x7f, 0x7b, 0x8a, 0x7f, 0x1b, 0x23, 0x3d, 0x63, 0x20, 0x85, 0x7f, 0x5b, 0xe5, 0xdf, + 0xc1, 0x57, 0x74, 0xcd, 0x28, 0xb6, 0xb5, 0x9d, 0x98, 0x7f, 0x27, 0xc1, 0xbf, 0xc3, 0xcf, 0x3d, + 0xc5, 0x98, 0x7f, 0x67, 0x8a, 0x7f, 0x07, 0x5f, 0xd3, 0x33, 0x46, 0x51, 0xe1, 0xdf, 0x51, 0xf9, + 0x77, 0xf1, 0x75, 0x5d, 0x33, 0x0a, 0x6d, 0x6d, 0x37, 0xe6, 0xdf, 0x4d, 0xf0, 0xef, 0xf2, 0xd3, + 0x49, 0x21, 0xe6, 0xdf, 0x9d, 0xe2, 0xdf, 0xc5, 0x58, 0xcf, 0x18, 0x05, 0x85, 0x7f, 0x57, 0xe5, + 0xdf, 0xc3, 0x37, 0x74, 0xcd, 0x58, 0x6e, 0x6b, 0x7b, 0x31, 0xff, 0x5e, 0x82, 0x7f, 0x8f, 0x1f, + 0x22, 0x96, 0x63, 0xfe, 0xbd, 0x29, 0xfe, 0x3d, 0x7c, 0x53, 0xcf, 0x18, 0xcb, 0x0a, 0xff, 0x1e, + 0xba, 0x03, 0x10, 0xef, 0xaf, 0x06, 0xbe, 0xa5, 0x6b, 0x46, 0xbd, 0x9d, 0xd9, 0x68, 0x98, 0x91, + 0xd5, 0x8d, 0x06, 0xba, 0x0d, 0x95, 0xc9, 0x16, 0x6b, 0xf0, 0x7f, 0xfc, 0xba, 0x59, 0x8e, 0xf6, + 0x58, 0x03, 0xad, 0xb1, 0x5e, 0x6b, 0xb2, 0xc9, 0x1a, 0xf8, 0xb6, 0x9e, 0x31, 0xea, 0x66, 0x65, + 0xb2, 0xcb, 0x1a, 0x6b, 0x7f, 0xd3, 0xa0, 0xd0, 0x09, 0x02, 0x6b, 0xcc, 0x1b, 0x5b, 0xcf, 0x1a, + 0x10, 0x8a, 0x35, 0xde, 0xe9, 0x8b, 0x17, 0xd6, 0xc2, 0xda, 0x56, 0x68, 0xe1, 0x8c, 0x9e, 0x35, + 0xaa, 0x26, 0x7f, 0x46, 0x77, 0xa1, 0x1c, 0x75, 0xc6, 0x51, 0xbf, 0x98, 0xe8, 0xb2, 0xcd, 0xc9, + 0x30, 0x5a, 0x87, 0xaa, 0x1f, 0xbe, 0x21, 0x41, 0x8f, 0xf7, 0xb9, 0x14, 0x2f, 0xe9, 0x59, 0x63, + 0xa9, 0x59, 0x11, 0xea, 0xc7, 0x4c, 0x66, 0x56, 0xb8, 0x02, 0x7f, 0xa6, 0x6b, 0x7f, 0xbd, 0x02, + 0xb9, 0x67, 0xd6, 0x90, 0xfd, 0x21, 0x83, 0x38, 0xf5, 0xf5, 0x28, 0x09, 0xb9, 0x4f, 0xac, 0xc5, + 0xe3, 0x30, 0x36, 0x2e, 0x8f, 0x7c, 0xc7, 0x24, 0x3c, 0xf4, 0xc2, 0x60, 0x6c, 0x96, 0x69, 0xf4, + 0x8e, 0xb6, 0xa0, 0xec, 0xb0, 0x7a, 0xcc, 0x81, 0x19, 0x0e, 0xc4, 0x0a, 0x90, 0xd7, 0xea, 0x18, + 0x57, 0x72, 0xe4, 0xab, 0x84, 0x6d, 0xb7, 0x38, 0x2c, 0x3b, 0x0f, 0xb6, 0xdd, 0x4a, 0xc0, 0xf8, + 0x2b, 0xf3, 0x73, 0x34, 0x31, 0x97, 0x9b, 0xf1, 0xf3, 0xa5, 0x93, 0xb0, 0x57, 0x1e, 0xc5, 0x06, + 0x25, 0x52, 0x5a, 0xcc, 0xcf, 0x45, 0x2a, 0x26, 0xcb, 0x23, 0xd5, 0x26, 0x9d, 0xd8, 0x2c, 0xcc, + 0xc6, 0x66, 0xca, 0x26, 0x55, 0x6d, 0xd2, 0x89, 0xcd, 0xe2, 0x5c, 0xa4, 0x6a, 0x93, 0xc6, 0x36, + 0x7f, 0x82, 0xca, 0x99, 0xf3, 0x81, 0xd8, 0xd2, 0x68, 0x49, 0x1e, 0x6b, 0x27, 0xd0, 0x47, 0x62, + 0x34, 0xc6, 0xc2, 0x59, 0x2c, 0x88, 0xc1, 0xd2, 0x6e, 0x79, 0x3e, 0x58, 0x31, 0x0c, 0x67, 0xb1, + 0x00, 0x3d, 0x80, 0x2a, 0x55, 0x4d, 0x83, 0x3c, 0x4d, 0x28, 0x5e, 0x9f, 0x4d, 0xd9, 0xae, 0x50, + 0xc5, 0x78, 0x8c, 0x97, 0xd6, 0x2b, 0x29, 0x78, 0xc5, 0x7c, 0x85, 0x2a, 0xf6, 0xff, 0x1f, 0xae, + 0x0f, 0x89, 0x3f, 0x74, 0x49, 0xaf, 0x3f, 0xee, 0x91, 0xc1, 0xd0, 0xf5, 0xc7, 0x84, 0xef, 0x3a, + 0xd9, 0x3b, 0x7f, 0xa3, 0x30, 0xbd, 0xe0, 0x8a, 0xfb, 0xe3, 0x43, 0xa9, 0x76, 0x34, 0x1a, 0x08, + 0xc6, 0x2b, 0xc3, 0xd9, 0x11, 0xd6, 0xe6, 0xca, 0x6d, 0x51, 0x93, 0x6d, 0xae, 0x9a, 0xdf, 0x6c, + 0x40, 0x80, 0xa5, 0x16, 0x9f, 0x89, 0xd8, 0x13, 0x62, 0xa7, 0x2e, 0xcd, 0xce, 0x84, 0x0f, 0x1f, + 0xb1, 0xd1, 0x68, 0x26, 0x13, 0x09, 0x5b, 0x06, 0xde, 0x05, 0x4a, 0xf8, 0xf2, 0xcc, 0x32, 0xf0, + 0xa6, 0x4f, 0x41, 0x43, 0x3f, 0x16, 0xb0, 0xd4, 0x61, 0x1d, 0x8d, 0xc4, 0xd6, 0x67, 0x52, 0x87, + 0x35, 0x30, 0x0a, 0xb4, 0xdc, 0x8f, 0xde, 0x99, 0xdb, 0xa2, 0xa1, 0x90, 0xd8, 0x95, 0x19, 0xb7, + 0x45, 0xf7, 0xa0, 0xba, 0x6d, 0x4f, 0x24, 0x3c, 0x7b, 0xd8, 0x29, 0x5d, 0xc2, 0xd1, 0x6c, 0xf6, + 0xb0, 0x51, 0xd5, 0xed, 0xb3, 0x58, 0xb0, 0xfa, 0x04, 0x96, 0x92, 0xa5, 0x02, 0xd5, 0x21, 0xfb, + 0x96, 0x8c, 0xf9, 0xa1, 0xa5, 0x6c, 0xb2, 0x47, 0xa4, 0x47, 0xdf, 0x36, 0x32, 0xd3, 0x5f, 0x03, + 0xe5, 0xf7, 0x8c, 0x76, 0x66, 0x57, 0x5b, 0x7d, 0x0c, 0xb5, 0x44, 0xed, 0x50, 0x89, 0xf2, 0x9f, + 0x4e, 0x34, 0x49, 0x37, 0x95, 0x28, 0xfb, 0x29, 0x44, 0x4f, 0x60, 0x29, 0x59, 0x5e, 0x54, 0xa6, + 0xda, 0x25, 0x98, 0xe6, 0xfb, 0x94, 0xfb, 0x44, 0xa6, 0xe3, 0x54, 0x9f, 0x56, 0x2e, 0xc1, 0x34, + 0xdf, 0x27, 0xf4, 0x29, 0x4c, 0x2f, 0x61, 0x79, 0xaa, 0x3a, 0xa9, 0x54, 0x45, 0x41, 0x75, 0x4f, + 0xa5, 0x9a, 0xf7, 0xc9, 0xe9, 0x70, 0x30, 0x0c, 0xc7, 0xf3, 0x68, 0xe7, 0x7b, 0x58, 0xb8, 0x2c, + 0xed, 0x2b, 0xa8, 0x4f, 0x17, 0x34, 0x95, 0x77, 0xf9, 0xb3, 0x79, 0xe7, 0xfb, 0x5b, 0xbf, 0x2c, + 0xef, 0x09, 0xe0, 0xb4, 0xb2, 0x37, 0x67, 0x8b, 0xac, 0x25, 0xf9, 0x93, 0x07, 0x07, 0x85, 0xf5, + 0x11, 0x54, 0x94, 0x12, 0x38, 0x87, 0xe8, 0x4e, 0x72, 0xe9, 0x13, 0x47, 0x0a, 0x85, 0xe7, 0x01, + 0xd4, 0xa7, 0x8b, 0xe2, 0x9c, 0x0a, 0x70, 0x55, 0x25, 0x2b, 0xab, 0xf8, 0xfb, 0xb0, 0x3c, 0x55, + 0x15, 0x2f, 0x82, 0x57, 0x55, 0xf8, 0xcf, 0xb0, 0x94, 0x2c, 0x8c, 0x17, 0xa1, 0x4b, 0x53, 0xce, + 0x4f, 0x97, 0xc6, 0x8b, 0xf0, 0xda, 0x94, 0xf3, 0x53, 0xb5, 0xf1, 0x22, 0x78, 0x46, 0x81, 0xaf, + 0xfd, 0x3b, 0x0f, 0x95, 0x13, 0x42, 0xc3, 0x67, 0x84, 0x52, 0xeb, 0x9c, 0xa0, 0x1f, 0xa0, 0x18, + 0x90, 0xd3, 0x51, 0x40, 0xa3, 0xd5, 0x5b, 0x11, 0x41, 0x57, 0x74, 0xcc, 0x48, 0x03, 0xfd, 0x0c, + 0xf5, 0x80, 0x0c, 0x89, 0x15, 0x12, 0xbb, 0x17, 0xa1, 0xc4, 0xb1, 0x6a, 0x0e, 0x6a, 0x39, 0x52, + 0x35, 0x25, 0xfa, 0x5b, 0x7e, 0xb7, 0x40, 0x7d, 0x4f, 0xde, 0x2d, 0x24, 0xf3, 0x44, 0x8e, 0xb1, + 0x1c, 0x10, 0x97, 0x29, 0x79, 0x3d, 0x33, 0x93, 0x03, 0xe2, 0x66, 0x65, 0x0b, 0x8a, 0x9e, 0xe8, + 0x59, 0x71, 0x41, 0x7e, 0xcc, 0xe0, 0x4a, 0x73, 0xdb, 0x5a, 0x33, 0xd2, 0x45, 0xdf, 0x43, 0x35, + 0xee, 0xdf, 0x9a, 0xad, 0x26, 0x6f, 0x11, 0x33, 0xed, 0x1c, 0x7b, 0x36, 0x2b, 0x51, 0x17, 0xd7, + 0x6c, 0x25, 0x1b, 0x51, 0x71, 0x49, 0x90, 0x89, 0x0f, 0xfa, 0x9d, 0xa9, 0x83, 0xbe, 0xc5, 0x1b, + 0xc5, 0x8c, 0x72, 0xd0, 0xef, 0xa8, 0x86, 0xf6, 0xf6, 0xf6, 0xf6, 0x78, 0xaf, 0xa8, 0xb5, 0x73, + 0xec, 0x39, 0x36, 0xc4, 0x5e, 0x12, 0x86, 0xfa, 0xbc, 0x63, 0xd4, 0x62, 0x43, 0xfb, 0x53, 0x86, + 0xfa, 0xbc, 0x63, 0xd4, 0x14, 0x43, 0xfb, 0x68, 0x13, 0x80, 0x5f, 0xbd, 0x88, 0x80, 0xd5, 0x66, + 0x36, 0x4d, 0xbb, 0xf8, 0xe2, 0xf0, 0xe8, 0xa0, 0x7b, 0xf4, 0xd8, 0x2c, 0x33, 0x3d, 0x2e, 0x43, + 0x77, 0xa0, 0xda, 0xb7, 0x28, 0x61, 0x27, 0xa7, 0x70, 0x74, 0x76, 0xc6, 0x1b, 0xc9, 0xaa, 0x59, + 0x11, 0xb2, 0x63, 0x26, 0x42, 0x37, 0xa1, 0x2c, 0xee, 0xf2, 0x7a, 0x8e, 0xcd, 0x1b, 0xc9, 0xaa, + 0x59, 0x12, 0x82, 0xae, 0x8d, 0x74, 0xc8, 0xbc, 0x7f, 0xcb, 0xfb, 0xc7, 0x4a, 0xb3, 0x2e, 0x8c, + 0x4d, 0x2e, 0xb5, 0xcc, 0xcc, 0xfb, 0xb7, 0x6c, 0xa1, 0x2d, 0xde, 0x80, 0xc8, 0x6f, 0xf0, 0x72, + 0xa1, 0x45, 0x53, 0x62, 0xca, 0x31, 0x74, 0x1b, 0x72, 0x03, 0x6b, 0xc8, 0xfe, 0xfb, 0x99, 0x0e, + 0x4c, 0xfe, 0xfb, 0x4d, 0x2e, 0x47, 0x77, 0x21, 0x37, 0x70, 0xe8, 0x29, 0xef, 0x24, 0x21, 0x3a, + 0x47, 0x29, 0x09, 0xb6, 0xfe, 0xcc, 0xa1, 0xa7, 0x26, 0xd7, 0x59, 0xbd, 0x0b, 0x39, 0xf6, 0xc6, + 0x76, 0xc2, 0x99, 0xef, 0x47, 0x3b, 0xe1, 0xcc, 0xf7, 0x99, 0xa4, 0x6f, 0x05, 0xf2, 0x6b, 0x05, + 0x7b, 0xbc, 0xfb, 0x77, 0x0d, 0xf2, 0x22, 0x12, 0x15, 0x28, 0x76, 0x8f, 0x5e, 0x75, 0x9e, 0x76, + 0x0f, 0xea, 0x5f, 0x88, 0x97, 0xee, 0x49, 0xb7, 0xf3, 0xb4, 0xae, 0xb1, 0x17, 0x19, 0xb9, 0x7a, + 0x86, 0xbd, 0x98, 0x2f, 0x8f, 0x8e, 0xd8, 0x4b, 0x16, 0x01, 0x14, 0x5e, 0x74, 0x5e, 0x1e, 0x1f, + 0x1e, 0xd4, 0x73, 0x08, 0xc1, 0x52, 0xe7, 0xb7, 0x4e, 0xf7, 0xa4, 0x7b, 0xf4, 0xb8, 0xd7, 0x3d, + 0x7a, 0xf1, 0xf2, 0xa4, 0x9e, 0x47, 0x4b, 0x00, 0x0f, 0x3b, 0x47, 0x0f, 0x0f, 0x9f, 0x3e, 0x65, + 0xfa, 0x05, 0x54, 0x85, 0xd2, 0xc3, 0xe7, 0xcf, 0x5e, 0x3c, 0x3d, 0x3c, 0x39, 0xac, 0x17, 0x51, + 0x0d, 0xca, 0x72, 0xf4, 0xf0, 0xa0, 0x5e, 0x62, 0x64, 0x8f, 0x3a, 0x5d, 0xf6, 0x5c, 0xbe, 0x5b, + 0x87, 0x1c, 0xfb, 0x8f, 0x43, 0x25, 0xc8, 0xbd, 0x7a, 0xce, 0x3c, 0x6a, 0xfe, 0x0b, 0x41, 0xe5, + 0x57, 0x27, 0x3c, 0x7d, 0x43, 0xbc, 0x63, 0xc7, 0x7b, 0x8b, 0xb6, 0x21, 0xf7, 0xc2, 0xf1, 0xce, + 0x51, 0x4a, 0xfd, 0x5e, 0x4d, 0x91, 0xa3, 0x06, 0x94, 0x0e, 0x3f, 0x9c, 0xbe, 0xb1, 0xbc, 0x73, + 0x82, 0x66, 0xf7, 0xe9, 0xea, 0xac, 0x08, 0xb5, 0x00, 0x5e, 0x0e, 0x5d, 0xdf, 0xb2, 0x9f, 0x59, + 0xde, 0xf8, 0xe3, 0x30, 0x86, 0x86, 0xb6, 0xa1, 0x7a, 0xe0, 0xbf, 0xf7, 0x3e, 0x0d, 0xd7, 0xd0, + 0xd0, 0x2e, 0xc3, 0x31, 0xc4, 0xc9, 0x1b, 0xfe, 0x7d, 0xff, 0x23, 0xed, 0x35, 0x34, 0xf4, 0x10, + 0x6a, 0xc7, 0xc4, 0xb3, 0xe3, 0x7b, 0x4c, 0xb4, 0xe0, 0x8e, 0x33, 0x35, 0x3c, 0x1d, 0xa8, 0x32, + 0x92, 0xe8, 0x66, 0x11, 0xa5, 0x5f, 0x3a, 0xa6, 0x52, 0xec, 0x40, 0x91, 0x51, 0x74, 0xbc, 0x31, + 0x9a, 0x7b, 0x37, 0x98, 0x0a, 0xbc, 0x0f, 0xc0, 0x80, 0xe2, 0x62, 0x0e, 0xa5, 0xdd, 0xd8, 0xa5, + 0xc2, 0x7f, 0x82, 0x32, 0x83, 0x8b, 0x0b, 0xb6, 0x94, 0x0b, 0xb5, 0x54, 0xb0, 0x0c, 0x5e, 0x7c, + 0xab, 0x85, 0x16, 0xdc, 0x78, 0xa5, 0x92, 0xfc, 0x22, 0x3c, 0x10, 0x37, 0x4b, 0x8b, 0xae, 0xa0, + 0x52, 0x19, 0xf6, 0xe3, 0x10, 0xb0, 0xdc, 0x5e, 0x78, 0x0f, 0x94, 0xca, 0xf1, 0x00, 0x4a, 0xdc, + 0x0b, 0xdf, 0x77, 0xd1, 0x82, 0x6b, 0x99, 0x8b, 0x7c, 0x90, 0x77, 0x26, 0x0b, 0xef, 0x46, 0x2e, + 0x8a, 0x84, 0xb8, 0xbb, 0x58, 0x74, 0x49, 0x71, 0x11, 0x03, 0x6f, 0x48, 0xd0, 0xa2, 0xcb, 0x81, + 0x8f, 0x60, 0xd8, 0x6e, 0xa1, 0x45, 0xdf, 0xe6, 0x2f, 0x8a, 0x84, 0xf8, 0xfa, 0x8d, 0x16, 0x7e, + 0x16, 0xff, 0x18, 0x8e, 0xed, 0x16, 0x5a, 0xf8, 0x69, 0x3a, 0x95, 0xe3, 0x19, 0x5c, 0x63, 0x1c, + 0xcf, 0x46, 0x6e, 0xe8, 0x0c, 0x5d, 0xf2, 0x59, 0x3b, 0xdc, 0xd0, 0xd0, 0xaf, 0x70, 0x55, 0xa5, + 0xfb, 0x8c, 0xbd, 0x6e, 0x68, 0xa8, 0x03, 0xcb, 0x2a, 0xd9, 0x27, 0xef, 0x7a, 0x43, 0x43, 0x8f, + 0x01, 0xa9, 0x14, 0x97, 0xdc, 0xff, 0x86, 0x86, 0x0e, 0x61, 0x45, 0x25, 0xba, 0x54, 0x25, 0x30, + 0xb4, 0xe9, 0x70, 0x7f, 0x56, 0x4d, 0x30, 0x34, 0xf4, 0x7f, 0x49, 0xaf, 0x2e, 0x5f, 0x1d, 0x0c, + 0x0d, 0x3d, 0x9d, 0x09, 0xd5, 0xa5, 0xeb, 0x84, 0xa1, 0xa1, 0x27, 0x50, 0x4f, 0x78, 0x76, 0xc9, + 0x8a, 0x31, 0xeb, 0xd7, 0xe7, 0xd4, 0x8e, 0xd9, 0x88, 0x5d, 0xbe, 0x8a, 0xcc, 0x72, 0x5d, 0xbe, + 0x9e, 0xcc, 0xe5, 0xba, 0x64, 0x65, 0x99, 0x8d, 0xd8, 0xe7, 0xd4, 0x98, 0xf9, 0x6c, 0x97, 0xad, + 0x36, 0x86, 0xb6, 0x5f, 0xf8, 0x53, 0x6e, 0x60, 0x39, 0xde, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x65, 0xe3, 0xc3, 0x8a, 0x79, 0x28, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// KitchenSinkClient is the client API for KitchenSink service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type KitchenSinkClient interface { + Ping(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) + Exchange(ctx context.Context, in *TestMessage, opts ...grpc.CallOption) (*TestMessage, error) + UploadMany(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_UploadManyClient, error) + DownloadMany(ctx context.Context, in *TestMessage, opts ...grpc.CallOption) (KitchenSink_DownloadManyClient, error) + DoManyThings(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_DoManyThingsClient, error) + SendTimestamp(ctx context.Context, in *timestamp.Timestamp, opts ...grpc.CallOption) (*empty.Empty, error) + SendDuration(ctx context.Context, in *duration.Duration, opts ...grpc.CallOption) (*empty.Empty, error) + SendAny(ctx context.Context, in *any.Any, opts ...grpc.CallOption) (*empty.Empty, error) + SendStruct(ctx context.Context, in *_struct.Struct, opts ...grpc.CallOption) (*empty.Empty, error) + SendValue(ctx context.Context, in *_struct.Value, opts ...grpc.CallOption) (*empty.Empty, error) + SendListValue(ctx context.Context, in *_struct.ListValue, opts ...grpc.CallOption) (*empty.Empty, error) + SendBytes(ctx context.Context, in *wrappers.BytesValue, opts ...grpc.CallOption) (*empty.Empty, error) + SendString(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*empty.Empty, error) + SendBool(ctx context.Context, in *wrappers.BoolValue, opts ...grpc.CallOption) (*empty.Empty, error) + SendDouble(ctx context.Context, in *wrappers.DoubleValue, opts ...grpc.CallOption) (*empty.Empty, error) + SendFloat(ctx context.Context, in *wrappers.FloatValue, opts ...grpc.CallOption) (*empty.Empty, error) + SendInt32(ctx context.Context, in *wrappers.Int32Value, opts ...grpc.CallOption) (*empty.Empty, error) + SendInt64(ctx context.Context, in *wrappers.Int64Value, opts ...grpc.CallOption) (*empty.Empty, error) + SendUInt32(ctx context.Context, in *wrappers.UInt32Value, opts ...grpc.CallOption) (*empty.Empty, error) + SendUInt64(ctx context.Context, in *wrappers.UInt64Value, opts ...grpc.CallOption) (*empty.Empty, error) + SendMultipleTimestamp(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleTimestampClient, error) + SendMultipleDuration(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleDurationClient, error) + SendMultipleAny(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleAnyClient, error) + SendMultipleStruct(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleStructClient, error) + SendMultipleValue(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleValueClient, error) + SendMultipleListValue(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleListValueClient, error) + SendMultipleBytes(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleBytesClient, error) + SendMultipleString(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleStringClient, error) + SendMultipleBool(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleBoolClient, error) + SendMultipleDouble(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleDoubleClient, error) + SendMultipleFloat(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleFloatClient, error) + SendMultipleInt32(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleInt32Client, error) + SendMultipleInt64(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleInt64Client, error) + SendMultipleUInt32(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleUInt32Client, error) + SendMultipleUInt64(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleUInt64Client, error) +} + +type kitchenSinkClient struct { + cc grpc.ClientConnInterface +} + +func NewKitchenSinkClient(cc grpc.ClientConnInterface) KitchenSinkClient { + return &kitchenSinkClient{cc} +} + +func (c *kitchenSinkClient) Ping(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/Ping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) Exchange(ctx context.Context, in *TestMessage, opts ...grpc.CallOption) (*TestMessage, error) { + out := new(TestMessage) + err := c.cc.Invoke(ctx, "/test.KitchenSink/Exchange", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) UploadMany(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_UploadManyClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[0], "/test.KitchenSink/UploadMany", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkUploadManyClient{stream} + return x, nil +} + +type KitchenSink_UploadManyClient interface { + Send(*TestMessage) error + CloseAndRecv() (*TestMessage, error) + grpc.ClientStream +} + +type kitchenSinkUploadManyClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkUploadManyClient) Send(m *TestMessage) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkUploadManyClient) CloseAndRecv() (*TestMessage, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(TestMessage) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) DownloadMany(ctx context.Context, in *TestMessage, opts ...grpc.CallOption) (KitchenSink_DownloadManyClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[1], "/test.KitchenSink/DownloadMany", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkDownloadManyClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type KitchenSink_DownloadManyClient interface { + Recv() (*TestMessage, error) + grpc.ClientStream +} + +type kitchenSinkDownloadManyClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkDownloadManyClient) Recv() (*TestMessage, error) { + m := new(TestMessage) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) DoManyThings(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_DoManyThingsClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[2], "/test.KitchenSink/DoManyThings", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkDoManyThingsClient{stream} + return x, nil +} + +type KitchenSink_DoManyThingsClient interface { + Send(*TestMessage) error + Recv() (*TestMessage, error) + grpc.ClientStream +} + +type kitchenSinkDoManyThingsClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkDoManyThingsClient) Send(m *TestMessage) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkDoManyThingsClient) Recv() (*TestMessage, error) { + m := new(TestMessage) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendTimestamp(ctx context.Context, in *timestamp.Timestamp, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendTimestamp", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendDuration(ctx context.Context, in *duration.Duration, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendDuration", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendAny(ctx context.Context, in *any.Any, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendAny", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendStruct(ctx context.Context, in *_struct.Struct, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendStruct", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendValue(ctx context.Context, in *_struct.Value, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendValue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendListValue(ctx context.Context, in *_struct.ListValue, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendListValue", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendBytes(ctx context.Context, in *wrappers.BytesValue, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendBytes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendString(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendString", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendBool(ctx context.Context, in *wrappers.BoolValue, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendBool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendDouble(ctx context.Context, in *wrappers.DoubleValue, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendDouble", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendFloat(ctx context.Context, in *wrappers.FloatValue, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendFloat", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendInt32(ctx context.Context, in *wrappers.Int32Value, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendInt32", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendInt64(ctx context.Context, in *wrappers.Int64Value, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendInt64", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendUInt32(ctx context.Context, in *wrappers.UInt32Value, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendUInt32", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendUInt64(ctx context.Context, in *wrappers.UInt64Value, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/test.KitchenSink/SendUInt64", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kitchenSinkClient) SendMultipleTimestamp(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleTimestampClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[3], "/test.KitchenSink/SendMultipleTimestamp", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleTimestampClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleTimestampClient interface { + Send(*timestamp.Timestamp) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleTimestampClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleTimestampClient) Send(m *timestamp.Timestamp) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleTimestampClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleDuration(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleDurationClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[4], "/test.KitchenSink/SendMultipleDuration", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleDurationClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleDurationClient interface { + Send(*duration.Duration) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleDurationClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleDurationClient) Send(m *duration.Duration) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleDurationClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleAny(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleAnyClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[5], "/test.KitchenSink/SendMultipleAny", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleAnyClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleAnyClient interface { + Send(*any.Any) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleAnyClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleAnyClient) Send(m *any.Any) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleAnyClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleStruct(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleStructClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[6], "/test.KitchenSink/SendMultipleStruct", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleStructClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleStructClient interface { + Send(*_struct.Struct) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleStructClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleStructClient) Send(m *_struct.Struct) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleStructClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleValue(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleValueClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[7], "/test.KitchenSink/SendMultipleValue", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleValueClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleValueClient interface { + Send(*_struct.Value) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleValueClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleValueClient) Send(m *_struct.Value) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleValueClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleListValue(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleListValueClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[8], "/test.KitchenSink/SendMultipleListValue", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleListValueClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleListValueClient interface { + Send(*_struct.ListValue) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleListValueClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleListValueClient) Send(m *_struct.ListValue) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleListValueClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleBytes(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleBytesClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[9], "/test.KitchenSink/SendMultipleBytes", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleBytesClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleBytesClient interface { + Send(*wrappers.BytesValue) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleBytesClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleBytesClient) Send(m *wrappers.BytesValue) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleBytesClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleString(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleStringClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[10], "/test.KitchenSink/SendMultipleString", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleStringClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleStringClient interface { + Send(*wrappers.StringValue) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleStringClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleStringClient) Send(m *wrappers.StringValue) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleStringClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleBool(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleBoolClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[11], "/test.KitchenSink/SendMultipleBool", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleBoolClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleBoolClient interface { + Send(*wrappers.BoolValue) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleBoolClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleBoolClient) Send(m *wrappers.BoolValue) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleBoolClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleDouble(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleDoubleClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[12], "/test.KitchenSink/SendMultipleDouble", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleDoubleClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleDoubleClient interface { + Send(*wrappers.DoubleValue) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleDoubleClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleDoubleClient) Send(m *wrappers.DoubleValue) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleDoubleClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleFloat(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleFloatClient, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[13], "/test.KitchenSink/SendMultipleFloat", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleFloatClient{stream} + return x, nil +} + +type KitchenSink_SendMultipleFloatClient interface { + Send(*wrappers.FloatValue) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleFloatClient struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleFloatClient) Send(m *wrappers.FloatValue) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleFloatClient) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleInt32(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleInt32Client, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[14], "/test.KitchenSink/SendMultipleInt32", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleInt32Client{stream} + return x, nil +} + +type KitchenSink_SendMultipleInt32Client interface { + Send(*wrappers.Int32Value) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleInt32Client struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleInt32Client) Send(m *wrappers.Int32Value) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleInt32Client) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleInt64(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleInt64Client, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[15], "/test.KitchenSink/SendMultipleInt64", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleInt64Client{stream} + return x, nil +} + +type KitchenSink_SendMultipleInt64Client interface { + Send(*wrappers.Int64Value) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleInt64Client struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleInt64Client) Send(m *wrappers.Int64Value) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleInt64Client) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleUInt32(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleUInt32Client, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[16], "/test.KitchenSink/SendMultipleUInt32", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleUInt32Client{stream} + return x, nil +} + +type KitchenSink_SendMultipleUInt32Client interface { + Send(*wrappers.UInt32Value) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleUInt32Client struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleUInt32Client) Send(m *wrappers.UInt32Value) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleUInt32Client) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *kitchenSinkClient) SendMultipleUInt64(ctx context.Context, opts ...grpc.CallOption) (KitchenSink_SendMultipleUInt64Client, error) { + stream, err := c.cc.NewStream(ctx, &_KitchenSink_serviceDesc.Streams[17], "/test.KitchenSink/SendMultipleUInt64", opts...) + if err != nil { + return nil, err + } + x := &kitchenSinkSendMultipleUInt64Client{stream} + return x, nil +} + +type KitchenSink_SendMultipleUInt64Client interface { + Send(*wrappers.UInt64Value) error + CloseAndRecv() (*empty.Empty, error) + grpc.ClientStream +} + +type kitchenSinkSendMultipleUInt64Client struct { + grpc.ClientStream +} + +func (x *kitchenSinkSendMultipleUInt64Client) Send(m *wrappers.UInt64Value) error { + return x.ClientStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleUInt64Client) CloseAndRecv() (*empty.Empty, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(empty.Empty) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// KitchenSinkServer is the server API for KitchenSink service. +type KitchenSinkServer interface { + Ping(context.Context, *empty.Empty) (*empty.Empty, error) + Exchange(context.Context, *TestMessage) (*TestMessage, error) + UploadMany(KitchenSink_UploadManyServer) error + DownloadMany(*TestMessage, KitchenSink_DownloadManyServer) error + DoManyThings(KitchenSink_DoManyThingsServer) error + SendTimestamp(context.Context, *timestamp.Timestamp) (*empty.Empty, error) + SendDuration(context.Context, *duration.Duration) (*empty.Empty, error) + SendAny(context.Context, *any.Any) (*empty.Empty, error) + SendStruct(context.Context, *_struct.Struct) (*empty.Empty, error) + SendValue(context.Context, *_struct.Value) (*empty.Empty, error) + SendListValue(context.Context, *_struct.ListValue) (*empty.Empty, error) + SendBytes(context.Context, *wrappers.BytesValue) (*empty.Empty, error) + SendString(context.Context, *wrappers.StringValue) (*empty.Empty, error) + SendBool(context.Context, *wrappers.BoolValue) (*empty.Empty, error) + SendDouble(context.Context, *wrappers.DoubleValue) (*empty.Empty, error) + SendFloat(context.Context, *wrappers.FloatValue) (*empty.Empty, error) + SendInt32(context.Context, *wrappers.Int32Value) (*empty.Empty, error) + SendInt64(context.Context, *wrappers.Int64Value) (*empty.Empty, error) + SendUInt32(context.Context, *wrappers.UInt32Value) (*empty.Empty, error) + SendUInt64(context.Context, *wrappers.UInt64Value) (*empty.Empty, error) + SendMultipleTimestamp(KitchenSink_SendMultipleTimestampServer) error + SendMultipleDuration(KitchenSink_SendMultipleDurationServer) error + SendMultipleAny(KitchenSink_SendMultipleAnyServer) error + SendMultipleStruct(KitchenSink_SendMultipleStructServer) error + SendMultipleValue(KitchenSink_SendMultipleValueServer) error + SendMultipleListValue(KitchenSink_SendMultipleListValueServer) error + SendMultipleBytes(KitchenSink_SendMultipleBytesServer) error + SendMultipleString(KitchenSink_SendMultipleStringServer) error + SendMultipleBool(KitchenSink_SendMultipleBoolServer) error + SendMultipleDouble(KitchenSink_SendMultipleDoubleServer) error + SendMultipleFloat(KitchenSink_SendMultipleFloatServer) error + SendMultipleInt32(KitchenSink_SendMultipleInt32Server) error + SendMultipleInt64(KitchenSink_SendMultipleInt64Server) error + SendMultipleUInt32(KitchenSink_SendMultipleUInt32Server) error + SendMultipleUInt64(KitchenSink_SendMultipleUInt64Server) error +} + +// UnimplementedKitchenSinkServer can be embedded to have forward compatible implementations. +type UnimplementedKitchenSinkServer struct { +} + +func (*UnimplementedKitchenSinkServer) Ping(ctx context.Context, req *empty.Empty) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") +} +func (*UnimplementedKitchenSinkServer) Exchange(ctx context.Context, req *TestMessage) (*TestMessage, error) { + return nil, status.Errorf(codes.Unimplemented, "method Exchange not implemented") +} +func (*UnimplementedKitchenSinkServer) UploadMany(srv KitchenSink_UploadManyServer) error { + return status.Errorf(codes.Unimplemented, "method UploadMany not implemented") +} +func (*UnimplementedKitchenSinkServer) DownloadMany(req *TestMessage, srv KitchenSink_DownloadManyServer) error { + return status.Errorf(codes.Unimplemented, "method DownloadMany not implemented") +} +func (*UnimplementedKitchenSinkServer) DoManyThings(srv KitchenSink_DoManyThingsServer) error { + return status.Errorf(codes.Unimplemented, "method DoManyThings not implemented") +} +func (*UnimplementedKitchenSinkServer) SendTimestamp(ctx context.Context, req *timestamp.Timestamp) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendTimestamp not implemented") +} +func (*UnimplementedKitchenSinkServer) SendDuration(ctx context.Context, req *duration.Duration) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendDuration not implemented") +} +func (*UnimplementedKitchenSinkServer) SendAny(ctx context.Context, req *any.Any) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendAny not implemented") +} +func (*UnimplementedKitchenSinkServer) SendStruct(ctx context.Context, req *_struct.Struct) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendStruct not implemented") +} +func (*UnimplementedKitchenSinkServer) SendValue(ctx context.Context, req *_struct.Value) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendValue not implemented") +} +func (*UnimplementedKitchenSinkServer) SendListValue(ctx context.Context, req *_struct.ListValue) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendListValue not implemented") +} +func (*UnimplementedKitchenSinkServer) SendBytes(ctx context.Context, req *wrappers.BytesValue) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendBytes not implemented") +} +func (*UnimplementedKitchenSinkServer) SendString(ctx context.Context, req *wrappers.StringValue) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendString not implemented") +} +func (*UnimplementedKitchenSinkServer) SendBool(ctx context.Context, req *wrappers.BoolValue) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendBool not implemented") +} +func (*UnimplementedKitchenSinkServer) SendDouble(ctx context.Context, req *wrappers.DoubleValue) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendDouble not implemented") +} +func (*UnimplementedKitchenSinkServer) SendFloat(ctx context.Context, req *wrappers.FloatValue) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendFloat not implemented") +} +func (*UnimplementedKitchenSinkServer) SendInt32(ctx context.Context, req *wrappers.Int32Value) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendInt32 not implemented") +} +func (*UnimplementedKitchenSinkServer) SendInt64(ctx context.Context, req *wrappers.Int64Value) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendInt64 not implemented") +} +func (*UnimplementedKitchenSinkServer) SendUInt32(ctx context.Context, req *wrappers.UInt32Value) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendUInt32 not implemented") +} +func (*UnimplementedKitchenSinkServer) SendUInt64(ctx context.Context, req *wrappers.UInt64Value) (*empty.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendUInt64 not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleTimestamp(srv KitchenSink_SendMultipleTimestampServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleTimestamp not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleDuration(srv KitchenSink_SendMultipleDurationServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleDuration not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleAny(srv KitchenSink_SendMultipleAnyServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleAny not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleStruct(srv KitchenSink_SendMultipleStructServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleStruct not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleValue(srv KitchenSink_SendMultipleValueServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleValue not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleListValue(srv KitchenSink_SendMultipleListValueServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleListValue not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleBytes(srv KitchenSink_SendMultipleBytesServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleBytes not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleString(srv KitchenSink_SendMultipleStringServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleString not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleBool(srv KitchenSink_SendMultipleBoolServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleBool not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleDouble(srv KitchenSink_SendMultipleDoubleServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleDouble not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleFloat(srv KitchenSink_SendMultipleFloatServer) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleFloat not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleInt32(srv KitchenSink_SendMultipleInt32Server) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleInt32 not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleInt64(srv KitchenSink_SendMultipleInt64Server) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleInt64 not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleUInt32(srv KitchenSink_SendMultipleUInt32Server) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleUInt32 not implemented") +} +func (*UnimplementedKitchenSinkServer) SendMultipleUInt64(srv KitchenSink_SendMultipleUInt64Server) error { + return status.Errorf(codes.Unimplemented, "method SendMultipleUInt64 not implemented") +} + +func RegisterKitchenSinkServer(s *grpc.Server, srv KitchenSinkServer) { + s.RegisterService(&_KitchenSink_serviceDesc, srv) +} + +func _KitchenSink_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(empty.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).Ping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/Ping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).Ping(ctx, req.(*empty.Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_Exchange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TestMessage) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).Exchange(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/Exchange", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).Exchange(ctx, req.(*TestMessage)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_UploadMany_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).UploadMany(&kitchenSinkUploadManyServer{stream}) +} + +type KitchenSink_UploadManyServer interface { + SendAndClose(*TestMessage) error + Recv() (*TestMessage, error) + grpc.ServerStream +} + +type kitchenSinkUploadManyServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkUploadManyServer) SendAndClose(m *TestMessage) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkUploadManyServer) Recv() (*TestMessage, error) { + m := new(TestMessage) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_DownloadMany_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(TestMessage) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(KitchenSinkServer).DownloadMany(m, &kitchenSinkDownloadManyServer{stream}) +} + +type KitchenSink_DownloadManyServer interface { + Send(*TestMessage) error + grpc.ServerStream +} + +type kitchenSinkDownloadManyServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkDownloadManyServer) Send(m *TestMessage) error { + return x.ServerStream.SendMsg(m) +} + +func _KitchenSink_DoManyThings_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).DoManyThings(&kitchenSinkDoManyThingsServer{stream}) +} + +type KitchenSink_DoManyThingsServer interface { + Send(*TestMessage) error + Recv() (*TestMessage, error) + grpc.ServerStream +} + +type kitchenSinkDoManyThingsServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkDoManyThingsServer) Send(m *TestMessage) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkDoManyThingsServer) Recv() (*TestMessage, error) { + m := new(TestMessage) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendTimestamp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(timestamp.Timestamp) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendTimestamp(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendTimestamp", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendTimestamp(ctx, req.(*timestamp.Timestamp)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendDuration_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(duration.Duration) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendDuration(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendDuration", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendDuration(ctx, req.(*duration.Duration)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendAny_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(any.Any) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendAny(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendAny", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendAny(ctx, req.(*any.Any)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendStruct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(_struct.Struct) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendStruct(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendStruct", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendStruct(ctx, req.(*_struct.Struct)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(_struct.Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendValue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendValue(ctx, req.(*_struct.Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendListValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(_struct.ListValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendListValue(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendListValue", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendListValue(ctx, req.(*_struct.ListValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendBytes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.BytesValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendBytes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendBytes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendBytes(ctx, req.(*wrappers.BytesValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendString_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.StringValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendString(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendString", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendString(ctx, req.(*wrappers.StringValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendBool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.BoolValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendBool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendBool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendBool(ctx, req.(*wrappers.BoolValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendDouble_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.DoubleValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendDouble(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendDouble", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendDouble(ctx, req.(*wrappers.DoubleValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendFloat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.FloatValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendFloat(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendFloat", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendFloat(ctx, req.(*wrappers.FloatValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendInt32_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.Int32Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendInt32(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendInt32", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendInt32(ctx, req.(*wrappers.Int32Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendInt64_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.Int64Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendInt64(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendInt64", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendInt64(ctx, req.(*wrappers.Int64Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendUInt32_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.UInt32Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendUInt32(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendUInt32", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendUInt32(ctx, req.(*wrappers.UInt32Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendUInt64_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.UInt64Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KitchenSinkServer).SendUInt64(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/test.KitchenSink/SendUInt64", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KitchenSinkServer).SendUInt64(ctx, req.(*wrappers.UInt64Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _KitchenSink_SendMultipleTimestamp_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleTimestamp(&kitchenSinkSendMultipleTimestampServer{stream}) +} + +type KitchenSink_SendMultipleTimestampServer interface { + SendAndClose(*empty.Empty) error + Recv() (*timestamp.Timestamp, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleTimestampServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleTimestampServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleTimestampServer) Recv() (*timestamp.Timestamp, error) { + m := new(timestamp.Timestamp) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleDuration_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleDuration(&kitchenSinkSendMultipleDurationServer{stream}) +} + +type KitchenSink_SendMultipleDurationServer interface { + SendAndClose(*empty.Empty) error + Recv() (*duration.Duration, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleDurationServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleDurationServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleDurationServer) Recv() (*duration.Duration, error) { + m := new(duration.Duration) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleAny_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleAny(&kitchenSinkSendMultipleAnyServer{stream}) +} + +type KitchenSink_SendMultipleAnyServer interface { + SendAndClose(*empty.Empty) error + Recv() (*any.Any, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleAnyServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleAnyServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleAnyServer) Recv() (*any.Any, error) { + m := new(any.Any) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleStruct_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleStruct(&kitchenSinkSendMultipleStructServer{stream}) +} + +type KitchenSink_SendMultipleStructServer interface { + SendAndClose(*empty.Empty) error + Recv() (*_struct.Struct, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleStructServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleStructServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleStructServer) Recv() (*_struct.Struct, error) { + m := new(_struct.Struct) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleValue_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleValue(&kitchenSinkSendMultipleValueServer{stream}) +} + +type KitchenSink_SendMultipleValueServer interface { + SendAndClose(*empty.Empty) error + Recv() (*_struct.Value, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleValueServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleValueServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleValueServer) Recv() (*_struct.Value, error) { + m := new(_struct.Value) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleListValue_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleListValue(&kitchenSinkSendMultipleListValueServer{stream}) +} + +type KitchenSink_SendMultipleListValueServer interface { + SendAndClose(*empty.Empty) error + Recv() (*_struct.ListValue, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleListValueServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleListValueServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleListValueServer) Recv() (*_struct.ListValue, error) { + m := new(_struct.ListValue) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleBytes_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleBytes(&kitchenSinkSendMultipleBytesServer{stream}) +} + +type KitchenSink_SendMultipleBytesServer interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.BytesValue, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleBytesServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleBytesServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleBytesServer) Recv() (*wrappers.BytesValue, error) { + m := new(wrappers.BytesValue) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleString_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleString(&kitchenSinkSendMultipleStringServer{stream}) +} + +type KitchenSink_SendMultipleStringServer interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.StringValue, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleStringServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleStringServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleStringServer) Recv() (*wrappers.StringValue, error) { + m := new(wrappers.StringValue) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleBool_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleBool(&kitchenSinkSendMultipleBoolServer{stream}) +} + +type KitchenSink_SendMultipleBoolServer interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.BoolValue, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleBoolServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleBoolServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleBoolServer) Recv() (*wrappers.BoolValue, error) { + m := new(wrappers.BoolValue) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleDouble_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleDouble(&kitchenSinkSendMultipleDoubleServer{stream}) +} + +type KitchenSink_SendMultipleDoubleServer interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.DoubleValue, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleDoubleServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleDoubleServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleDoubleServer) Recv() (*wrappers.DoubleValue, error) { + m := new(wrappers.DoubleValue) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleFloat_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleFloat(&kitchenSinkSendMultipleFloatServer{stream}) +} + +type KitchenSink_SendMultipleFloatServer interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.FloatValue, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleFloatServer struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleFloatServer) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleFloatServer) Recv() (*wrappers.FloatValue, error) { + m := new(wrappers.FloatValue) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleInt32_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleInt32(&kitchenSinkSendMultipleInt32Server{stream}) +} + +type KitchenSink_SendMultipleInt32Server interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.Int32Value, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleInt32Server struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleInt32Server) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleInt32Server) Recv() (*wrappers.Int32Value, error) { + m := new(wrappers.Int32Value) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleInt64_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleInt64(&kitchenSinkSendMultipleInt64Server{stream}) +} + +type KitchenSink_SendMultipleInt64Server interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.Int64Value, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleInt64Server struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleInt64Server) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleInt64Server) Recv() (*wrappers.Int64Value, error) { + m := new(wrappers.Int64Value) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleUInt32_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleUInt32(&kitchenSinkSendMultipleUInt32Server{stream}) +} + +type KitchenSink_SendMultipleUInt32Server interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.UInt32Value, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleUInt32Server struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleUInt32Server) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleUInt32Server) Recv() (*wrappers.UInt32Value, error) { + m := new(wrappers.UInt32Value) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _KitchenSink_SendMultipleUInt64_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(KitchenSinkServer).SendMultipleUInt64(&kitchenSinkSendMultipleUInt64Server{stream}) +} + +type KitchenSink_SendMultipleUInt64Server interface { + SendAndClose(*empty.Empty) error + Recv() (*wrappers.UInt64Value, error) + grpc.ServerStream +} + +type kitchenSinkSendMultipleUInt64Server struct { + grpc.ServerStream +} + +func (x *kitchenSinkSendMultipleUInt64Server) SendAndClose(m *empty.Empty) error { + return x.ServerStream.SendMsg(m) +} + +func (x *kitchenSinkSendMultipleUInt64Server) Recv() (*wrappers.UInt64Value, error) { + m := new(wrappers.UInt64Value) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _KitchenSink_serviceDesc = grpc.ServiceDesc{ + ServiceName: "test.KitchenSink", + HandlerType: (*KitchenSinkServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Ping", + Handler: _KitchenSink_Ping_Handler, + }, + { + MethodName: "Exchange", + Handler: _KitchenSink_Exchange_Handler, + }, + { + MethodName: "SendTimestamp", + Handler: _KitchenSink_SendTimestamp_Handler, + }, + { + MethodName: "SendDuration", + Handler: _KitchenSink_SendDuration_Handler, + }, + { + MethodName: "SendAny", + Handler: _KitchenSink_SendAny_Handler, + }, + { + MethodName: "SendStruct", + Handler: _KitchenSink_SendStruct_Handler, + }, + { + MethodName: "SendValue", + Handler: _KitchenSink_SendValue_Handler, + }, + { + MethodName: "SendListValue", + Handler: _KitchenSink_SendListValue_Handler, + }, + { + MethodName: "SendBytes", + Handler: _KitchenSink_SendBytes_Handler, + }, + { + MethodName: "SendString", + Handler: _KitchenSink_SendString_Handler, + }, + { + MethodName: "SendBool", + Handler: _KitchenSink_SendBool_Handler, + }, + { + MethodName: "SendDouble", + Handler: _KitchenSink_SendDouble_Handler, + }, + { + MethodName: "SendFloat", + Handler: _KitchenSink_SendFloat_Handler, + }, + { + MethodName: "SendInt32", + Handler: _KitchenSink_SendInt32_Handler, + }, + { + MethodName: "SendInt64", + Handler: _KitchenSink_SendInt64_Handler, + }, + { + MethodName: "SendUInt32", + Handler: _KitchenSink_SendUInt32_Handler, + }, + { + MethodName: "SendUInt64", + Handler: _KitchenSink_SendUInt64_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "UploadMany", + Handler: _KitchenSink_UploadMany_Handler, + ClientStreams: true, + }, + { + StreamName: "DownloadMany", + Handler: _KitchenSink_DownloadMany_Handler, + ServerStreams: true, + }, + { + StreamName: "DoManyThings", + Handler: _KitchenSink_DoManyThings_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "SendMultipleTimestamp", + Handler: _KitchenSink_SendMultipleTimestamp_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleDuration", + Handler: _KitchenSink_SendMultipleDuration_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleAny", + Handler: _KitchenSink_SendMultipleAny_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleStruct", + Handler: _KitchenSink_SendMultipleStruct_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleValue", + Handler: _KitchenSink_SendMultipleValue_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleListValue", + Handler: _KitchenSink_SendMultipleListValue_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleBytes", + Handler: _KitchenSink_SendMultipleBytes_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleString", + Handler: _KitchenSink_SendMultipleString_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleBool", + Handler: _KitchenSink_SendMultipleBool_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleDouble", + Handler: _KitchenSink_SendMultipleDouble_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleFloat", + Handler: _KitchenSink_SendMultipleFloat_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleInt32", + Handler: _KitchenSink_SendMultipleInt32_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleInt64", + Handler: _KitchenSink_SendMultipleInt64_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleUInt32", + Handler: _KitchenSink_SendMultipleUInt32_Handler, + ClientStreams: true, + }, + { + StreamName: "SendMultipleUInt64", + Handler: _KitchenSink_SendMultipleUInt64_Handler, + ClientStreams: true, + }, + }, + Metadata: "test.proto", +} diff --git a/examples/grpc/testsrv/test.proto b/examples/grpc/testsrv/test.proto new file mode 100644 index 000000000..e1f368ae4 --- /dev/null +++ b/examples/grpc/testsrv/test.proto @@ -0,0 +1,264 @@ +syntax = "proto2"; + +package test; + +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option go_package = "main"; + +// A service that allows testing all kinds of permutations of message +// and field types in the grpcui web form. + +service KitchenSink { + rpc Ping (google.protobuf.Empty) returns (google.protobuf.Empty); + rpc Exchange (TestMessage) returns (TestMessage); + rpc UploadMany (stream TestMessage) returns (TestMessage); + rpc DownloadMany (TestMessage) returns (stream TestMessage); + rpc DoManyThings (stream TestMessage) returns (stream TestMessage); + + rpc SendTimestamp(google.protobuf.Timestamp) returns (google.protobuf.Empty); + rpc SendDuration(google.protobuf.Duration) returns (google.protobuf.Empty); + rpc SendAny(google.protobuf.Any) returns (google.protobuf.Empty); + rpc SendStruct(google.protobuf.Struct) returns (google.protobuf.Empty); + rpc SendValue(google.protobuf.Value) returns (google.protobuf.Empty); + rpc SendListValue(google.protobuf.ListValue) returns (google.protobuf.Empty); + rpc SendBytes(google.protobuf.BytesValue) returns (google.protobuf.Empty); + rpc SendString(google.protobuf.StringValue) returns (google.protobuf.Empty); + rpc SendBool(google.protobuf.BoolValue) returns (google.protobuf.Empty); + rpc SendDouble(google.protobuf.DoubleValue) returns (google.protobuf.Empty); + rpc SendFloat(google.protobuf.FloatValue) returns (google.protobuf.Empty); + rpc SendInt32(google.protobuf.Int32Value) returns (google.protobuf.Empty); + rpc SendInt64(google.protobuf.Int64Value) returns (google.protobuf.Empty); + rpc SendUInt32(google.protobuf.UInt32Value) returns (google.protobuf.Empty); + rpc SendUInt64(google.protobuf.UInt64Value) returns (google.protobuf.Empty); + + rpc SendMultipleTimestamp(stream google.protobuf.Timestamp) returns (google.protobuf.Empty); + rpc SendMultipleDuration(stream google.protobuf.Duration) returns (google.protobuf.Empty); + rpc SendMultipleAny(stream google.protobuf.Any) returns (google.protobuf.Empty); + rpc SendMultipleStruct(stream google.protobuf.Struct) returns (google.protobuf.Empty); + rpc SendMultipleValue(stream google.protobuf.Value) returns (google.protobuf.Empty); + rpc SendMultipleListValue(stream google.protobuf.ListValue) returns (google.protobuf.Empty); + rpc SendMultipleBytes(stream google.protobuf.BytesValue) returns (google.protobuf.Empty); + rpc SendMultipleString(stream google.protobuf.StringValue) returns (google.protobuf.Empty); + rpc SendMultipleBool(stream google.protobuf.BoolValue) returns (google.protobuf.Empty); + rpc SendMultipleDouble(stream google.protobuf.DoubleValue) returns (google.protobuf.Empty); + rpc SendMultipleFloat(stream google.protobuf.FloatValue) returns (google.protobuf.Empty); + rpc SendMultipleInt32(stream google.protobuf.Int32Value) returns (google.protobuf.Empty); + rpc SendMultipleInt64(stream google.protobuf.Int64Value) returns (google.protobuf.Empty); + rpc SendMultipleUInt32(stream google.protobuf.UInt32Value) returns (google.protobuf.Empty); + rpc SendMultipleUInt64(stream google.protobuf.UInt64Value) returns (google.protobuf.Empty); +} + +enum State { + INVALID = 0; + INITIAL = 1; + PENDING = 2; + RUNNING = 3; + PAUSED = 4; + AWAITING_INPUT = 5; + CANCELLING = 6; + COMPLETE = 7; + CANCELLED = 8; + FAILED = 9; +} + +enum Void { + VOID = 0; +} + +message Person { + required uint64 id = 1; + required string name = 2; + optional Address address = 3; + optional double xyz = 4 [default = 3.14159]; + optional string title = 5 [default = "overseer"]; + repeated string labels = 6; + optional bool is_real = 7 [default = true]; + optional bytes opaque = 8 [default = "\01\02\03\04"]; + + oneof relative { + Person parent = 9; + Person sibling = 10; + Person child = 11; + Void none = 12; + } +} + +message Address { + required string line1 = 1; + optional string line2 = 2; + required string city = 3; + required string state = 4; + required uint32 zip = 5; +} + +message WellKnowns { + required google.protobuf.Timestamp now = 1; + optional google.protobuf.Timestamp past = 2; + repeated google.protobuf.Timestamp futures = 3; + + required google.protobuf.Duration period = 4; + optional google.protobuf.Duration next_interval = 5; + repeated google.protobuf.Duration history_intervals = 6; + + required google.protobuf.Any neat = 7; + optional google.protobuf.Any extra = 8; + repeated google.protobuf.Any extensions = 9; + + required google.protobuf.Struct object = 10; + optional google.protobuf.Struct optional_object = 11; + repeated google.protobuf.Struct objects = 12; + + required google.protobuf.Value value = 13; + optional google.protobuf.Value optional_value = 14; + repeated google.protobuf.Value values = 15; + + required google.protobuf.ListValue list = 16; + optional google.protobuf.ListValue optional_list = 17; + repeated google.protobuf.ListValue lists = 18; + + required google.protobuf.BytesValue bytes = 19; + optional google.protobuf.BytesValue optional_bytes = 20; + repeated google.protobuf.BytesValue list_o_bytes = 21; + + required google.protobuf.StringValue string = 22; + optional google.protobuf.StringValue optional_string = 23; + repeated google.protobuf.StringValue list_o_strings = 24; + + required google.protobuf.BoolValue bool = 25; + optional google.protobuf.BoolValue optional_bool = 26; + repeated google.protobuf.BoolValue list_o_bools = 27; + + required google.protobuf.DoubleValue double = 28; + optional google.protobuf.DoubleValue optional_double = 29; + repeated google.protobuf.DoubleValue list_o_doubles = 30; + + required google.protobuf.FloatValue float = 31; + optional google.protobuf.FloatValue optional_float = 32; + repeated google.protobuf.FloatValue list_o_floats = 33; + + required google.protobuf.Int32Value small_int = 34; + optional google.protobuf.Int32Value optional_small_int = 35; + repeated google.protobuf.Int32Value list_o_small_ints = 36; + + required google.protobuf.Int64Value big_int = 37; + optional google.protobuf.Int64Value optional_big_int = 38; + repeated google.protobuf.Int64Value list_o_big_ints = 39; + + required google.protobuf.UInt32Value small_id = 40; + optional google.protobuf.UInt32Value optional_small_id = 41; + repeated google.protobuf.UInt32Value list_o_small_ids = 42; + + required google.protobuf.UInt64Value big_id = 43; + optional google.protobuf.UInt64Value optional_big_id = 44; + repeated google.protobuf.UInt64Value list_o_big_ids = 45; +} + +message NumbersNumbersNumbers { + optional int32 usually_1 = 1 [default = 1]; + optional int32 some_num_1 = 2; + required int32 needed_num_1 = 3; + + optional int64 usually_2 = 4 [default = 2]; + optional int64 some_num_2 = 5; + required int64 needed_num_2 = 6; + + optional uint32 usually_3 = 7 [default = 3]; + optional uint32 some_num_3 = 8; + required uint32 needed_num_3 = 9; + + optional uint64 usually_4 = 10 [default = 4]; + optional uint64 some_num_4 = 11; + required uint64 needed_num_4 = 12; + + optional sint32 usually_5 = 13 [default = 5]; + optional sint32 some_num_5 = 14; + required sint32 needed_num_5 = 15; + + optional sint64 usually_6 = 16 [default = 6]; + optional sint64 some_num_6 = 17; + required sint64 needed_num_6 = 18; + + optional fixed32 usually_7 = 19 [default = 7]; + optional fixed32 some_num_7 = 20; + required fixed32 needed_num_7 = 21; + + optional fixed64 usually_8 = 22 [default = 8]; + optional fixed64 some_num_8 = 23; + required fixed64 needed_num_8 = 24; + + optional sfixed32 usually_9 = 25 [default = 9]; + optional sfixed32 some_num_9 = 26; + required sfixed32 needed_num_9 = 27; + + optional sfixed64 usually_10 = 28 [default = 10]; + optional sfixed64 some_num_10 = 29; + required sfixed64 needed_num_10 = 30; +} + +message Arrays { + repeated string names = 1; + repeated bytes data = 2; + repeated Person relatives = 3; + repeated State other_states = 14; +} + +message Maps { + map string_set = 1; + map int32_set = 2; + map int64_set = 3; + map uint32_set = 4; + map uint64_set = 5; + map sint32_set = 6; + map sint64_set = 7; + map fixed32_set = 8; + map fixed64_set = 9; + map sfixed32_set = 10; + map sfixed64_set = 11; + + map people_by_employee_num = 12; + map states = 13; + + map string_names = 14; + map bytes_names = 15; + map bool_names = 16; + map double_names = 17; + map float_names = 18; +} + +message TestMessage { + optional TestMessage recurse = 2; + repeated TestMessage repeated_recurse = 3; + + required Person person = 4; + required State state = 5; + + optional NumbersNumbersNumbers numbers = 6; + + optional float usually_4242 = 7 [default = 4242]; + optional float some_num_a = 8; + required float needed_num_a = 9; + + optional double usually_9999 = 10 [default = 9999]; + optional double some_num_b = 11; + required double needed_num_b = 12; + + optional State next_state = 13 [default = PENDING]; + + optional bytes base64_stuff = 14; + required bytes opaque_id = 15; + + optional WellKnowns wk = 16; + optional Arrays arrays = 17; + optional Maps maps = 18; + + optional group Misc = 19 { + optional string foo = 1; + optional int32 bar = 2; + } +} \ No newline at end of file diff --git a/examples/grpc/testsrv/testsvr.go b/examples/grpc/testsrv/testsvr.go new file mode 100644 index 000000000..273b60d5c --- /dev/null +++ b/examples/grpc/testsrv/testsvr.go @@ -0,0 +1,390 @@ +// Command testsvr is a gRPC server for testing grpcui. It has a wide gRPC API +// that exercises every combination of form inputs that the web UI can handle. +package main + +import ( + "flag" + "fmt" + "io" + "net" + "os" + "strings" + + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes/any" + "github.com/golang/protobuf/ptypes/duration" + "github.com/golang/protobuf/ptypes/empty" + "github.com/golang/protobuf/ptypes/struct" + "github.com/golang/protobuf/ptypes/timestamp" + "github.com/golang/protobuf/ptypes/wrappers" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/reflection" + "google.golang.org/grpc/status" +) + +//go:generate protoc --go_out=plugins=grpc:. test.proto + +func main() { + port := flag.Int("port", 0, "Port on which to listen") + flag.Parse() + + if flag.NArg() > 0 { + fmt.Fprintf(os.Stderr, "Invalid argument(s): %v\n", flag.Args()) + fmt.Fprintf(os.Stderr, "This program does not take any arguments\n") + os.Exit(1) + } + + l, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", *port)) + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to create network listener: %v\n", err) + os.Exit(1) + } + fmt.Printf("Listening on %v\n", l.Addr().(*net.TCPAddr).String()) + + svr := grpc.NewServer() + RegisterKitchenSinkServer(svr, &testSvr{}) + reflection.Register(svr) + if err := svr.Serve(l); err != nil { + fmt.Fprintf(os.Stderr, "Failed to start gRPC server: %v\n", err) + os.Exit(1) + } +} + +type testSvr struct{} + +func (s testSvr) Ping(context.Context, *empty.Empty) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) Exchange(ctx context.Context, m *TestMessage) (*TestMessage, error) { + if headers, ok := metadata.FromIncomingContext(ctx); ok { + hdrs := metadata.MD{} + tlrs := metadata.MD{} + for k, v := range headers { + if strings.HasSuffix("-t", k) { + tlrs[k] = v + } else { + hdrs[k] = v + } + } + _ = grpc.SendHeader(ctx, hdrs) + _ = grpc.SetTrailer(ctx, tlrs) + } + return m, nil +} + +func (s testSvr) UploadMany(stream KitchenSink_UploadManyServer) error { + if headers, ok := metadata.FromIncomingContext(stream.Context()); ok { + hdrs := metadata.MD{} + tlrs := metadata.MD{} + for k, v := range headers { + if strings.HasSuffix("-t", k) { + tlrs[k] = v + } else { + hdrs[k] = v + } + } + _ = stream.SendHeader(hdrs) + stream.SetTrailer(tlrs) + } + + var m *TestMessage + count := 0 + for { + var err error + m, err = stream.Recv() + if err == io.EOF { + break + } else if err != nil { + return err + } + count++ + } + if m == nil { + return status.Error(codes.InvalidArgument, "must provide at least one request message") + } + m.NeededNumA = proto.Float32(float32(count)) + return stream.SendAndClose(m) +} + +func (s testSvr) DownloadMany(m *TestMessage, stream KitchenSink_DownloadManyServer) error { + if headers, ok := metadata.FromIncomingContext(stream.Context()); ok { + hdrs := metadata.MD{} + tlrs := metadata.MD{} + for k, v := range headers { + if strings.HasSuffix("-t", k) { + tlrs[k] = v + } else { + hdrs[k] = v + } + } + _ = stream.SendHeader(hdrs) + stream.SetTrailer(tlrs) + } + + numResponses := m.Numbers.GetNeededNum_1() + for i := int32(0); i < numResponses; i++ { + err := stream.Send(m) + if err != nil { + return err + } + } + return nil +} + +func (s testSvr) DoManyThings(stream KitchenSink_DoManyThingsServer) error { + if headers, ok := metadata.FromIncomingContext(stream.Context()); ok { + hdrs := metadata.MD{} + tlrs := metadata.MD{} + for k, v := range headers { + if strings.HasSuffix("-t", k) { + tlrs[k] = v + } else { + hdrs[k] = v + } + } + _ = stream.SendHeader(hdrs) + stream.SetTrailer(tlrs) + } + + for { + m, err := stream.Recv() + if err == io.EOF { + return nil + } else if err != nil { + return err + } + err = stream.Send(m) + if err != nil { + return err + } + } +} + +func (s testSvr) SendTimestamp(context.Context, *timestamp.Timestamp) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendDuration(context.Context, *duration.Duration) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendAny(context.Context, *any.Any) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendStruct(context.Context, *structpb.Struct) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendValue(context.Context, *structpb.Value) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendListValue(context.Context, *structpb.ListValue) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendBytes(context.Context, *wrappers.BytesValue) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendString(context.Context, *wrappers.StringValue) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendBool(context.Context, *wrappers.BoolValue) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendDouble(context.Context, *wrappers.DoubleValue) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendFloat(context.Context, *wrappers.FloatValue) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendInt32(context.Context, *wrappers.Int32Value) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendInt64(context.Context, *wrappers.Int64Value) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendUInt32(context.Context, *wrappers.UInt32Value) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendUInt64(context.Context, *wrappers.UInt64Value) (*empty.Empty, error) { + return &empty.Empty{}, nil +} + +func (s testSvr) SendMultipleTimestamp(stream KitchenSink_SendMultipleTimestampServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleDuration(stream KitchenSink_SendMultipleDurationServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleAny(stream KitchenSink_SendMultipleAnyServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleStruct(stream KitchenSink_SendMultipleStructServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleValue(stream KitchenSink_SendMultipleValueServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleListValue(stream KitchenSink_SendMultipleListValueServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleBytes(stream KitchenSink_SendMultipleBytesServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleString(stream KitchenSink_SendMultipleStringServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleBool(stream KitchenSink_SendMultipleBoolServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleDouble(stream KitchenSink_SendMultipleDoubleServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleFloat(stream KitchenSink_SendMultipleFloatServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleInt32(stream KitchenSink_SendMultipleInt32Server) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleInt64(stream KitchenSink_SendMultipleInt64Server) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleUInt32(stream KitchenSink_SendMultipleUInt32Server) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} + +func (s testSvr) SendMultipleUInt64(stream KitchenSink_SendMultipleUInt64Server) error { + for { + _, err := stream.Recv() + if err == io.EOF { + return stream.SendAndClose(&empty.Empty{}) + } else if err != nil { + return err + } + } +} diff --git a/go.mod b/go.mod index 5fef91fc3..dfdc774f1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.12 require ( github.com/envoyproxy/go-control-plane v0.9.7 - github.com/gogo/protobuf v1.3.0 // indirect github.com/open-policy-agent/opa v0.25.2 github.com/peterh/liner v1.1.0 // indirect github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 3ed9b7038..c844c15fe 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/OneOfOne/xxhash v1.2.7 h1:fzrmmkskv067ZQbd9wERNGuxckWw67dyzoMG62p7LMo= -github.com/OneOfOne/xxhash v1.2.7/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -78,7 +76,6 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -95,13 +92,11 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v0.0.0-20181025225059-d3de96c4c28e/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -133,7 +128,6 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v0.0.0-20181024020800-521ea7b17d02/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= @@ -179,11 +173,8 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -198,11 +189,8 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-runewidth v0.0.0-20181025052659-b20a3daf6a39/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= @@ -240,12 +228,6 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/open-policy-agent/opa v0.24.0 h1:fnGOIux+TTGZsC0du1bRBtV8F+KPN55Hks12uE3Fq3E= -github.com/open-policy-agent/opa v0.24.0/go.mod h1:qEyD/i8j+RQettHGp4f86yjrjvv+ZYia+JHCMv2G7wA= -github.com/open-policy-agent/opa v0.25.0 h1:pFcoNDPPhD8kiY908PvfG/kPlpHg69WorWLwME5cqqk= -github.com/open-policy-agent/opa v0.25.0/go.mod h1:iGThTRECCfKQKICueOZkXUi0opN7BR3qiAnIrNHCmlI= -github.com/open-policy-agent/opa v0.25.1 h1:oqC/1wSrnkiddeFA7V/oKImsIeLIR7LPy/0F295AhFM= -github.com/open-policy-agent/opa v0.25.1/go.mod h1:iGThTRECCfKQKICueOZkXUi0opN7BR3qiAnIrNHCmlI= github.com/open-policy-agent/opa v0.25.2 h1:zTQuUMvB5xkYixKB9LFVbUd7DcUt1jfS0QKTo+/Vfyc= github.com/open-policy-agent/opa v0.25.2/go.mod h1:iGThTRECCfKQKICueOZkXUi0opN7BR3qiAnIrNHCmlI= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= @@ -266,7 +248,6 @@ github.com/peterh/liner v1.1.0 h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os= github.com/peterh/liner v1.1.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.0.0-20181023235946-059132a15dd0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -276,13 +257,10 @@ github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6J github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/prometheus/client_golang v0.0.0-20181025174421-f30f42803563/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= -github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= @@ -295,11 +273,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= -github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.14.0 h1:RHRyE8UocrbjU+6UvRzwi6HjiDfxrrBU91TtbKzkGp4= @@ -307,15 +282,11 @@ github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= -github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4= github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962 h1:eUm8ma4+yPknhXtkYlWh3tMkE6gBjXZToDned9s2gbQ= -github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -327,7 +298,6 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= @@ -339,12 +309,10 @@ github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.0-20181021141114-fe5e611709b0/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v0.0.0-20181024212040-082b515c9490/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -393,7 +361,6 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181023182221-1baf3a9d7d67/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -452,8 +419,6 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 h1:4y9KwBHBgBNwDbtu44R5o1fdOCQUEXhbk/P4A9WmJq0= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -477,7 +442,6 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -486,8 +450,6 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72 h1:bw9doJza/SFBEweII/rHQh338oozWyiFsBRHtrflcws= -golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -506,7 +468,6 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= @@ -545,6 +506,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/internal/internal.go b/internal/internal.go index cc5f0439f..589975082 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -7,9 +7,11 @@ package internal import ( "context" "crypto/rand" + "encoding/binary" "encoding/json" "fmt" "io" + "io/ioutil" "net" "net/url" "strconv" @@ -30,6 +32,12 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/reflection" "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" + "google.golang.org/protobuf/types/dynamicpb" "github.com/open-policy-agent/opa/ast" "github.com/open-policy-agent/opa/metrics" @@ -103,9 +111,29 @@ func Validate(m *plugins.Manager, bs []byte) (*Config, error) { cfg.parsedQuery = parsedQuery + if cfg.ProtoDescriptor != "" { + ps, err := readProtoSet(cfg.ProtoDescriptor) + if err != nil { + return nil, err + } + cfg.protoSet = ps + } + return &cfg, nil } +func readProtoSet(path string) (*protoregistry.Files, error) { + protoSet, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + var fileSet descriptorpb.FileDescriptorSet + if err := proto.Unmarshal(protoSet, &fileSet); err != nil { + return nil, err + } + return protodesc.NewFiles(&fileSet) +} + // New returns a Plugin that implements the Envoy ext_authz API. func New(m *plugins.Manager, cfg *Config) plugins.Plugin { @@ -141,6 +169,8 @@ type Config struct { DryRun bool `json:"dry-run"` EnableReflection bool `json:"enable-reflection"` parsedQuery ast.Body + ProtoDescriptor string `json:"proto-descriptor"` + protoSet *protoregistry.Files } type envoyExtAuthzGrpcServer struct { @@ -217,13 +247,12 @@ func (p *envoyExtAuthzGrpcServer) check(ctx context.Context, req interface{}) (* result := evalResult{} result.metrics = metrics.New() result.metrics.Timer(metrics.ServerHandler).Start() - result.decisionID, err = uuid4() - if err != nil { logrus.WithField("err", err).Error("Unable to generate decision ID.") return nil, func() *rpc_status.Status { return nil }, err } + logEntry := logrus.WithField("decision-id", result.decisionID) var input map[string]interface{} @@ -244,7 +273,7 @@ func (p *envoyExtAuthzGrpcServer) check(ctx context.Context, req interface{}) (* return nil, stop, err } - var bs []byte + var bs, rawBody []byte var path, body string var headers, version map[string]string @@ -261,6 +290,7 @@ func (p *envoyExtAuthzGrpcServer) check(ctx context.Context, req interface{}) (* path = req.GetAttributes().GetRequest().GetHttp().GetPath() body = req.GetAttributes().GetRequest().GetHttp().GetBody() headers = req.GetAttributes().GetRequest().GetHttp().GetHeaders() + rawBody = req.GetAttributes().GetRequest().GetHttp().GetRawBody() version = v3Info case *ext_authz_v2.CheckRequest: bs, err = json.Marshal(req) @@ -287,7 +317,7 @@ func (p *envoyExtAuthzGrpcServer) check(ctx context.Context, req interface{}) (* input["parsed_path"] = parsedPath input["parsed_query"] = parsedQuery - parsedBody, isBodyTruncated, err := getParsedBody(headers, body) + parsedBody, isBodyTruncated, err := getParsedBody(logEntry, headers, body, rawBody, parsedPath, p.cfg.protoSet) if err != nil { return nil, stop, err } @@ -362,17 +392,15 @@ func (p *envoyExtAuthzGrpcServer) check(ctx context.Context, req interface{}) (* return nil, stop, err } - if logrus.IsLevelEnabled(logrus.DebugLevel) { - logrus.WithFields(logrus.Fields{ - "query": p.cfg.parsedQuery.String(), - "dry-run": p.cfg.DryRun, - "decision": result.decision, - "err": err, - "txn": result.txnID, - "metrics": result.metrics.All(), - "total_decision_time": time.Since(start), - }).Debug("Returning policy decision.") - } + logrus.WithFields(logrus.Fields{ + "query": p.cfg.parsedQuery.String(), + "dry-run": p.cfg.DryRun, + "decision": result.decision, + "err": err, + "txn": result.txnID, + "metrics": result.metrics.All(), + "total_decision_time": time.Since(start), + }).Debug("Returning policy decision.") // If dry-run mode, override the Status code to unconditionally Allow the request // DecisionLogging should reflect what "would" have happened @@ -401,14 +429,12 @@ func (p *envoyExtAuthzGrpcServer) eval(ctx context.Context, input ast.Value, res result.txnID = txn.ID() - if logrus.IsLevelEnabled(logrus.DebugLevel) { - logrus.WithFields(logrus.Fields{ - "input": input, - "query": p.cfg.parsedQuery.String(), - "dry-run": p.cfg.DryRun, - "txn": result.txnID, - }).Debug("Executing policy query.") - } + logrus.WithFields(logrus.Fields{ + "input": input, + "query": p.cfg.parsedQuery.String(), + "dry-run": p.cfg.DryRun, + "txn": result.txnID, + }).Debug("Executing policy query.") err = p.constructPreparedQuery(txn, result.metrics, opts) if err != nil { @@ -695,36 +721,141 @@ func getParsedPathAndQuery(path string) ([]interface{}, map[string]interface{}, return parsedPathInterface, parsedQueryInterface, nil } -func getParsedBody(headers map[string]string, body string) (interface{}, bool, error) { - if body == "" { - return nil, false, nil - } - - if val, ok := headers["content-length"]; ok { - cl, err := strconv.ParseInt(val, 10, 64) - if err != nil { - return nil, false, err - } - - if cl != -1 && cl > int64(len(body)) { - return nil, true, nil - } - } - +func getParsedBody(logEntry *logrus.Entry, headers map[string]string, body string, rawBody []byte, parsedPath []interface{}, protoSet *protoregistry.Files) (interface{}, bool, error) { var data interface{} if val, ok := headers["content-type"]; ok { if strings.Contains(val, "application/json") { + + if body == "" { + return nil, false, nil + } + + if val, ok := headers["content-length"]; ok { + cl, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return nil, false, err + } + if cl != -1 && cl > int64(len(body)) { + return nil, true, nil + } + } + err := util.Unmarshal([]byte(body), &data) if err != nil { return nil, false, err } + } else if strings.Contains(val, "application/grpc") { + + if protoSet == nil { + return nil, false, nil + } + + // This happens when the plugin was configured to read gRPC payloads, + // but the Envoy instance requesting an authz decision didn't have + // pack_as_bytes set to true. + if len(rawBody) == 0 { + logEntry.Debug("no rawBody field sent") + return nil, false, nil + } + // In gRPC, a call of method DoThing on service ThingService is a + // POST to /ThingService/DoThing. If our path length is anything but + // two, something is wrong. + if len(parsedPath) != 2 { + return nil, false, fmt.Errorf("invalid parsed path") + } + + known, truncated, err := getGRPCBody(logEntry, rawBody, parsedPath, &data, protoSet) + if err != nil { + return nil, false, err + } + if truncated { + return nil, true, nil + } + if !known { + return nil, false, nil + } } } return data, false, nil } +func getGRPCBody(logEntry *logrus.Entry, in []byte, parsedPath []interface{}, data interface{}, files *protoregistry.Files) (found, truncated bool, _ error) { + + // the first 5 bytes are part of gRPC framing. We need to remove them to be able to parse + // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md + + if len(in) < 5 { + return false, false, fmt.Errorf("less than 5 bytes") + } + + // Can be 0 or 1, 1 indicates that the payload is compressed. + // The method could be looked up in the request headers, and the + // request decompressed; but for now, let's skip it. + if in[0] != 0 { + logEntry.Debug("gRPC payload compression not supported") + return false, false, nil + } + + // Note: we're only reading one message, this is the first message's size + size := binary.BigEndian.Uint32(in[1:5]) + if int(size) > len(in)-5 { + return false, true, nil // truncated body + } + in = in[5 : size+5] + + // Note: we've already checked that len(path)>=2 + svc, err := findService(parsedPath[0].(string), files) + if err != nil { + logEntry.WithField("err", err).Debug("could not find service") + return false, false, nil + } + msgDesc, err := findMessageInputDesc(parsedPath[1].(string), svc) + if err != nil { + logEntry.WithField("err", err).Debug("could not find message") + return false, false, nil + } + + msg := dynamicpb.NewMessage(msgDesc) + if err := proto.Unmarshal(in, msg); err != nil { + return true, false, err + } + + jsonBody, err := protojson.Marshal(msg) + if err != nil { + return true, false, err + } + + if err := util.Unmarshal([]byte(jsonBody), &data); err != nil { + return true, false, err + } + + return true, false, nil +} + +func findService(path string, files *protoregistry.Files) (protoreflect.ServiceDescriptor, error) { + desc, err := files.FindDescriptorByName(protoreflect.FullName(path)) + if err != nil { + return nil, err + } + svcDesc, ok := desc.(protoreflect.ServiceDescriptor) + if !ok { + return nil, fmt.Errorf("could not find service descriptor for path %q", path) + } + return svcDesc, nil +} + +func findMessageInputDesc(name string, svc protoreflect.ServiceDescriptor) (protoreflect.MessageDescriptor, error) { + if method := svc.Methods().ByName(protoreflect.Name(name)); method != nil { + if method.IsStreamingClient() { + return nil, fmt.Errorf("streaming client method %s not supported", method.Name()) + } + return method.Input(), nil + } + return nil, fmt.Errorf("method %q not found", name) +} + func stringPathToDataRef(s string) (r ast.Ref) { result := ast.Ref{ast.DefaultRootDocument} result = append(result, stringPathToRef(s)...) diff --git a/internal/internal_test.go b/internal/internal_test.go index 1ccc666a8..3d2d6328f 100644 --- a/internal/internal_test.go +++ b/internal/internal_test.go @@ -20,7 +20,9 @@ import ( ext_core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" ext_authz_v2 "github.com/envoyproxy/go-control-plane/envoy/service/auth/v2" ext_authz "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3" + "github.com/sirupsen/logrus" "google.golang.org/genproto/googleapis/rpc/code" + "google.golang.org/protobuf/reflect/protoregistry" "github.com/open-policy-agent/opa/ast" "github.com/open-policy-agent/opa/plugins" @@ -498,7 +500,7 @@ func TestCheckIllegalDecisionWithLogger(t *testing.T) { } if len(customLogger.events) != 1 { - t.Fatal("Unexpected events:", customLogger.events) + t.Fatalf("Unexpected events: %+v", customLogger.events) } event := customLogger.events[0] @@ -547,7 +549,7 @@ func TestCheckDenyDecisionTruncatedBodyWithLogger(t *testing.T) { } if len(customLogger.events) != 1 { - t.Fatal("Unexpected events:", customLogger.events) + t.Fatalf("Unexpected events: %+v", customLogger.events) } event := customLogger.events[0] @@ -992,6 +994,31 @@ func TestConfigInvalid(t *testing.T) { } } +func TestConfigWithProtoDescriptor(t *testing.T) { + tests := map[string]struct { + path string + wantErr bool + }{ + "nonexistent": {"this/does/not/exist", true}, + "other file type": {"../test/files/book/Book.proto", true}, + "valid file": {"../test/files/combined.pb", false}, + } + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + m, err := plugins.New([]byte{}, "test", inmem.New()) + if err != nil { + t.Fatal(err) + } + + in := fmt.Sprintf(`{"proto-descriptor": "%s"}`, tc.path) + _, err = Validate(m, []byte(in)) + if expected, actual := tc.wantErr, err != nil; expected != actual { + t.Errorf("expected err: %v", expected) + } + }) + } +} + func TestCheckAllowObjectDecision(t *testing.T) { // Example Envoy Check Request for input: @@ -1430,11 +1457,10 @@ func TestGetParsedBody(t *testing.T) { }` expectedNumber := json.Number("42") - - expectedObject := map[string]interface{}{} - expectedObject["firstname"] = "foo" - expectedObject["lastname"] = "bar" - + expectedObject := map[string]interface{}{ + "firstname": "foo", + "lastname": "bar", + } expectedArray := []interface{}{"hello", "opa"} tests := map[string]struct { @@ -1457,8 +1483,12 @@ func TestGetParsedBody(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - headers, body := tc.input.GetAttributes().GetRequest().GetHttp().GetHeaders(), tc.input.GetAttributes().GetRequest().GetHttp().GetBody() - got, isBodyTruncated, err := getParsedBody(headers, body) + logEntry := logrus.WithField("test", name) + headers := tc.input.GetAttributes().GetRequest().GetHttp().GetHeaders() + body := tc.input.GetAttributes().GetRequest().GetHttp().GetBody() + path := tc.input.GetAttributes().GetRequest().GetHttp().GetPath() + parsedPath, _, _ := getParsedPathAndQuery(path) + got, isBodyTruncated, err := getParsedBody(logEntry, headers, body, nil, parsedPath, nil) if !reflect.DeepEqual(got, tc.want) { t.Fatalf("expected result: %v, got: %v", tc.want, got) } @@ -1486,14 +1516,238 @@ func TestGetParsedBody(t *testing.T) { } }` + logEntry := logrus.WithField("test", "invalid json") req := createCheckRequest(requestContentTypeJSONInvalid) + path := []interface{}{} + protoSet := (*protoregistry.Files)(nil) headers, body := req.GetAttributes().GetRequest().GetHttp().GetHeaders(), req.GetAttributes().GetRequest().GetHttp().GetBody() - _, _, err := getParsedBody(headers, body) + _, _, err := getParsedBody(logEntry, headers, body, nil, path, protoSet) if err == nil { t.Fatal("Expected error but got nil") } } +func TestGetParsedBodygRPC(t *testing.T) { + + requestValidExample := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/Example.Test.GRPC.ProtoServiceIExampleApplication/RegisterExample", + "protocol": "HTTP/2", + "raw_body": "AAAAADYKFgoHCgVFUlJPUhILCglTZWNOdW1iZXISHAoMCgpCb2R5IHZhbHVlEgwKCk5hbWUgVmFsdWU=" + } + }, + "parsed_path": [ + "Example.Test.GRPC.ProtoServiceIExampleApplication", + "RegisterExample" + ] + } +} +` + + requestValidBook := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/com.book.BookService/GetBooksViaAuthor", + "protocol": "HTTP/2", + "raw_body": "AAAAAAYKBEpvaG4=" + } + } + } +} +` + + requestInvalidRawBodyExample := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/Example.Test.GRPC.ProtoServiceIExampleApplication/RegisterExample", + "protocol": "HTTP/2" + } + }, + "parsed_path": [ + "Example.Test.GRPC.ProtoServiceIExampleApplication", + "RegisterExample" + ] + } +} +` + + requestInvalidParsedPathExample := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "protocol": "HTTP/2", + "raw_body": "AAAAAC0KDQoHCgVFUlJPUhICCAESHAoMCgpCb2R5IHZhbHVlEgwKCk5hbWUgVmFsdWU=" + } + } + } +} +` + + requestUnknownService := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/com.book.SecondBookService/GetBooksViaAuthor", + "protocol": "HTTP/2", + "raw_body": "AAAAAAYKBEpvaG4=" + } + } + } +} +` + + requestUnknownMethod := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/com.book.BookService/GetBooksViaSecondAuthor", + "protocol": "HTTP/2", + "raw_body": "AAAAAAYKBEpvaG4=" + } + } + } +} +` + requestEmpty := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/com.book.BookService/GetBooksViaAuthor", + "protocol": "HTTP/2", + "raw_body": "AAAAAAA=" + } + } + } +} +` + requestCompressedPayload := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/com.book.BookService/GetBooksViaAuthor", + "protocol": "HTTP/2", + "raw_body": "AQAAADwfiwgAAAAAAAD/4hLkaOi4t49RoOHi+ll//////59RSJCj4dGiE4wCDau/LIYIAQIAAP//aJ9RpSYAAAA=" + } + } + } +} +` + + requestTruncatedPayload := `{ + "attributes": { + "request": { + "http": { + "headers": { + "content-type": "application/grpc" + }, + "method": "POST", + "path": "/com.book.BookService/GetBooksViaAuthor", + "protocol": "HTTP/2", + "raw_body": "AAAAABEImqaMww==" + } + } + } +} +` + + expectedObject := map[string]interface{}{ + "Data": map[string]interface{}{ + "Body": "Body value", + "Name": "Name Value", + }, + "Metadata": map[string]interface{}{ + "SeverityNumber": "SecNumber", + "SeverityText": "ERROR", + }, + } + expectedObjectExampleBook := map[string]interface{}{"author": "John"} + protoDescriptorPath := "../test/files/combined.pb" + protoSet, err := readProtoSet(protoDescriptorPath) + if err != nil { + t.Fatalf("read protoset: %v", err) + } + + tests := map[string]struct { + input *ext_authz.CheckRequest + want interface{} + isBodyTruncated bool + err error + }{ + "parsed_path_error": {input: createCheckRequest(requestInvalidParsedPathExample), want: nil, isBodyTruncated: false, err: fmt.Errorf("invalid parsed path")}, + "without_raw_body": {input: createCheckRequest(requestInvalidRawBodyExample), want: nil, isBodyTruncated: false, err: nil}, + "valid_parsed_example": {input: createCheckRequest(requestValidExample), want: expectedObject, isBodyTruncated: false, err: nil}, + "valid_parsed_book": {input: createCheckRequest(requestValidBook), want: expectedObjectExampleBook, isBodyTruncated: false, err: nil}, + "unknown_service": {input: createCheckRequest(requestUnknownService), want: nil, isBodyTruncated: false, err: nil}, + "unknown_method": {input: createCheckRequest(requestUnknownMethod), want: nil, isBodyTruncated: false, err: nil}, + "empty_request": {input: createCheckRequest(requestEmpty), want: map[string]interface{}{}, isBodyTruncated: false, err: nil}, + "compressed_payload": {input: createCheckRequest(requestCompressedPayload), want: nil, isBodyTruncated: false, err: nil}, + "truncated_payload": {input: createCheckRequest(requestTruncatedPayload), want: nil, isBodyTruncated: true, err: nil}, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + logEntry := logrus.WithField("test", name) + + headers := tc.input.GetAttributes().GetRequest().GetHttp().GetHeaders() + body := tc.input.GetAttributes().GetRequest().GetHttp().GetBody() + rawBody := tc.input.GetAttributes().GetRequest().GetHttp().GetRawBody() + path := tc.input.GetAttributes().GetRequest().GetHttp().GetPath() + + parsedPath, _, _ := getParsedPathAndQuery(path) + got, isBodyTruncated, err := getParsedBody(logEntry, headers, body, rawBody, parsedPath, protoSet) + + if !reflect.DeepEqual(err, tc.err) { + t.Fatalf("expected error: %v, got: %v", tc.err, err) + } + + if !reflect.DeepEqual(got, tc.want) { + t.Fatalf("expected result: %v, got: %v", tc.want, got) + } + + if isBodyTruncated != tc.isBodyTruncated { + t.Fatalf("expected isBodyTruncated: %v, got: %v", tc.isBodyTruncated, got) + } + + }) + } +} + func TestPluginStatusLifeCycle(t *testing.T) { m, err := getPluginManager("package foo", &testPlugin{}) if err != nil { @@ -1622,6 +1876,7 @@ func testAuthzServer(customLogger plugins.Plugin, dryRun bool) *envoyExtAuthzGrp } func testAuthzServerWithModule(module string, path string, customLogger plugins.Plugin, dryRun bool) *envoyExtAuthzGrpcServer { + m, err := getPluginManager(module, customLogger) if err != nil { panic(err) @@ -1661,12 +1916,13 @@ func testAuthzServerWithObjectDecision(customLogger plugins.Plugin, dryRun bool) "allowed": true, "headers": {"x": "hello", "y": "world"} } - }` + }` return testAuthzServerWithModule(module, "envoy/authz/allow", customLogger, dryRun) } func testAuthzServerWithTruncatedBody(customLogger plugins.Plugin, dryRun bool) *envoyExtAuthzGrpcServer { + module := ` package envoy.authz diff --git a/test/files/book/Book.proto b/test/files/book/Book.proto new file mode 100644 index 000000000..ff51cafb0 --- /dev/null +++ b/test/files/book/Book.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; + +package com.book; + +message Book { + int64 isbn = 1; + string title = 2; + string author = 3; +} + +message GetBookRequest { + int64 isbn = 1; +} + +message GetBookViaAuthor { + string author = 1; +} + +service BookService { + rpc GetBook (GetBookRequest) returns (Book) {} + rpc GetBooksViaAuthor (GetBookViaAuthor) returns (stream Book) {} + rpc GetGreatestBook (stream GetBookRequest) returns (Book) {} + rpc GetBooks (stream GetBookRequest) returns (stream Book) {} +} + +message BookStore { + string name = 1; + map books = 2; +} + +enum EnumSample { + option allow_alias = true; + UNKNOWN = 0; + STARTED = 1; + RUNNING = 1; +} \ No newline at end of file diff --git a/test/files/combined.pb b/test/files/combined.pb new file mode 100644 index 000000000..11f371fd1 Binary files /dev/null and b/test/files/combined.pb differ diff --git a/test/files/example/Example.proto b/test/files/example/Example.proto new file mode 100644 index 000000000..754120acd --- /dev/null +++ b/test/files/example/Example.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; +package Example.Test.GRPC; +import "google/protobuf/wrappers.proto"; + +service ProtoServiceIExampleApplication { + rpc RegisterExample (InputRegisterDTOExample) returns (OutputVoidDTOExample); + rpc GetStatusExample (InputGetStatusDTOExample) returns (OutputGetStatusDTOExample); +} + +message InputRegisterDTOExample { + InputMetadataExample Metadata = 1; + InputRegisterExample Data = 2; +} + +message InputMetadataExample { + google.protobuf.StringValue SeverityText = 1; + google.protobuf.StringValue SeverityNumber = 2; +} + +message InputRegisterExample { + google.protobuf.StringValue Body = 1; + google.protobuf.StringValue Name = 2; +} + +message OutputVoidDTOExample { + OutputMetadataExample Metadata = 1; + OutputVoidExample Data = 2; +} + +message OutputMetadataExample { + google.protobuf.BoolValue Success = 1; + repeated ErrorExample Errors = 2; + google.protobuf.BoolValue HasUnexpectedErrors = 3; + google.protobuf.StringValue RequestId = 4; +} + +message OutputVoidExample { +} + + +message ErrorExample { + google.protobuf.StringValue Code = 1; + google.protobuf.StringValue Message = 2; +} + +message OutputGetStatusDTOExample { + OutputMetadataExample Metadata = 1; + OutputGetStatusExample Data = 2; +} + + +message OutputGetStatusExample { +} + + +message InputGetStatusDTOExample { + InputMetadataExample Metadata = 1; + InputGetStatusExample Data = 2; +} + + +message InputGetStatusExample { + google.protobuf.StringValue Id = 1; + google.protobuf.BoolValue Disabled = 2; +} \ No newline at end of file diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go new file mode 100644 index 000000000..37f254d4c --- /dev/null +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go @@ -0,0 +1,275 @@ +// Copyright 2018 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 protodesc provides functionality for converting +// FileDescriptorProto messages to/from protoreflect.FileDescriptor values. +// +// The google.protobuf.FileDescriptorProto is a protobuf message that describes +// the type information for a .proto file in a form that is easily serializable. +// The protoreflect.FileDescriptor is a more structured representation of +// the FileDescriptorProto message where references and remote dependencies +// can be directly followed. +package protodesc + +import ( + "google.golang.org/protobuf/internal/errors" + "google.golang.org/protobuf/internal/filedesc" + "google.golang.org/protobuf/internal/pragma" + "google.golang.org/protobuf/internal/strs" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + + "google.golang.org/protobuf/types/descriptorpb" +) + +// Resolver is the resolver used by NewFile to resolve dependencies. +// The enums and messages provided must belong to some parent file, +// which is also registered. +// +// It is implemented by protoregistry.Files. +type Resolver interface { + FindFileByPath(string) (protoreflect.FileDescriptor, error) + FindDescriptorByName(protoreflect.FullName) (protoreflect.Descriptor, error) +} + +// FileOptions configures the construction of file descriptors. +type FileOptions struct { + pragma.NoUnkeyedLiterals + + // AllowUnresolvable configures New to permissively allow unresolvable + // file, enum, or message dependencies. Unresolved dependencies are replaced + // by placeholder equivalents. + // + // The following dependencies may be left unresolved: + // • Resolving an imported file. + // • Resolving the type for a message field or extension field. + // If the kind of the field is unknown, then a placeholder is used for both + // the Enum and Message accessors on the protoreflect.FieldDescriptor. + // • Resolving an enum value set as the default for an optional enum field. + // If unresolvable, the protoreflect.FieldDescriptor.Default is set to the + // first value in the associated enum (or zero if the also enum dependency + // is also unresolvable). The protoreflect.FieldDescriptor.DefaultEnumValue + // is populated with a placeholder. + // • Resolving the extended message type for an extension field. + // • Resolving the input or output message type for a service method. + // + // If the unresolved dependency uses a relative name, + // then the placeholder will contain an invalid FullName with a "*." prefix, + // indicating that the starting prefix of the full name is unknown. + AllowUnresolvable bool +} + +// NewFile creates a new protoreflect.FileDescriptor from the provided +// file descriptor message. See FileOptions.New for more information. +func NewFile(fd *descriptorpb.FileDescriptorProto, r Resolver) (protoreflect.FileDescriptor, error) { + return FileOptions{}.New(fd, r) +} + +// NewFiles creates a new protoregistry.Files from the provided +// FileDescriptorSet message. See FileOptions.NewFiles for more information. +func NewFiles(fd *descriptorpb.FileDescriptorSet) (*protoregistry.Files, error) { + return FileOptions{}.NewFiles(fd) +} + +// New creates a new protoreflect.FileDescriptor from the provided +// file descriptor message. The file must represent a valid proto file according +// to protobuf semantics. The returned descriptor is a deep copy of the input. +// +// Any imported files, enum types, or message types referenced in the file are +// resolved using the provided registry. When looking up an import file path, +// the path must be unique. The newly created file descriptor is not registered +// back into the provided file registry. +func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (protoreflect.FileDescriptor, error) { + if r == nil { + r = (*protoregistry.Files)(nil) // empty resolver + } + + // Handle the file descriptor content. + f := &filedesc.File{L2: &filedesc.FileL2{}} + switch fd.GetSyntax() { + case "proto2", "": + f.L1.Syntax = protoreflect.Proto2 + case "proto3": + f.L1.Syntax = protoreflect.Proto3 + default: + return nil, errors.New("invalid syntax: %q", fd.GetSyntax()) + } + f.L1.Path = fd.GetName() + if f.L1.Path == "" { + return nil, errors.New("file path must be populated") + } + f.L1.Package = protoreflect.FullName(fd.GetPackage()) + if !f.L1.Package.IsValid() && f.L1.Package != "" { + return nil, errors.New("invalid package: %q", f.L1.Package) + } + if opts := fd.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.FileOptions) + f.L2.Options = func() protoreflect.ProtoMessage { return opts } + } + + f.L2.Imports = make(filedesc.FileImports, len(fd.GetDependency())) + for _, i := range fd.GetPublicDependency() { + if !(0 <= i && int(i) < len(f.L2.Imports)) || f.L2.Imports[i].IsPublic { + return nil, errors.New("invalid or duplicate public import index: %d", i) + } + f.L2.Imports[i].IsPublic = true + } + for _, i := range fd.GetWeakDependency() { + if !(0 <= i && int(i) < len(f.L2.Imports)) || f.L2.Imports[i].IsWeak { + return nil, errors.New("invalid or duplicate weak import index: %d", i) + } + f.L2.Imports[i].IsWeak = true + } + imps := importSet{f.Path(): true} + for i, path := range fd.GetDependency() { + imp := &f.L2.Imports[i] + f, err := r.FindFileByPath(path) + if err == protoregistry.NotFound && (o.AllowUnresolvable || imp.IsWeak) { + f = filedesc.PlaceholderFile(path) + } else if err != nil { + return nil, errors.New("could not resolve import %q: %v", path, err) + } + imp.FileDescriptor = f + + if imps[imp.Path()] { + return nil, errors.New("already imported %q", path) + } + imps[imp.Path()] = true + } + for i := range fd.GetDependency() { + imp := &f.L2.Imports[i] + imps.importPublic(imp.Imports()) + } + + // Handle source locations. + for _, loc := range fd.GetSourceCodeInfo().GetLocation() { + var l protoreflect.SourceLocation + // TODO: Validate that the path points to an actual declaration? + l.Path = protoreflect.SourcePath(loc.GetPath()) + s := loc.GetSpan() + switch len(s) { + case 3: + l.StartLine, l.StartColumn, l.EndLine, l.EndColumn = int(s[0]), int(s[1]), int(s[0]), int(s[2]) + case 4: + l.StartLine, l.StartColumn, l.EndLine, l.EndColumn = int(s[0]), int(s[1]), int(s[2]), int(s[3]) + default: + return nil, errors.New("invalid span: %v", s) + } + // TODO: Validate that the span information is sensible? + // See https://github.com/protocolbuffers/protobuf/issues/6378. + if false && (l.EndLine < l.StartLine || l.StartLine < 0 || l.StartColumn < 0 || l.EndColumn < 0 || + (l.StartLine == l.EndLine && l.EndColumn <= l.StartColumn)) { + return nil, errors.New("invalid span: %v", s) + } + l.LeadingDetachedComments = loc.GetLeadingDetachedComments() + l.LeadingComments = loc.GetLeadingComments() + l.TrailingComments = loc.GetTrailingComments() + f.L2.Locations.List = append(f.L2.Locations.List, l) + } + + // Step 1: Allocate and derive the names for all declarations. + // This copies all fields from the descriptor proto except: + // google.protobuf.FieldDescriptorProto.type_name + // google.protobuf.FieldDescriptorProto.default_value + // google.protobuf.FieldDescriptorProto.oneof_index + // google.protobuf.FieldDescriptorProto.extendee + // google.protobuf.MethodDescriptorProto.input + // google.protobuf.MethodDescriptorProto.output + var err error + sb := new(strs.Builder) + r1 := make(descsByName) + if f.L1.Enums.List, err = r1.initEnumDeclarations(fd.GetEnumType(), f, sb); err != nil { + return nil, err + } + if f.L1.Messages.List, err = r1.initMessagesDeclarations(fd.GetMessageType(), f, sb); err != nil { + return nil, err + } + if f.L1.Extensions.List, err = r1.initExtensionDeclarations(fd.GetExtension(), f, sb); err != nil { + return nil, err + } + if f.L1.Services.List, err = r1.initServiceDeclarations(fd.GetService(), f, sb); err != nil { + return nil, err + } + + // Step 2: Resolve every dependency reference not handled by step 1. + r2 := &resolver{local: r1, remote: r, imports: imps, allowUnresolvable: o.AllowUnresolvable} + if err := r2.resolveMessageDependencies(f.L1.Messages.List, fd.GetMessageType()); err != nil { + return nil, err + } + if err := r2.resolveExtensionDependencies(f.L1.Extensions.List, fd.GetExtension()); err != nil { + return nil, err + } + if err := r2.resolveServiceDependencies(f.L1.Services.List, fd.GetService()); err != nil { + return nil, err + } + + // Step 3: Validate every enum, message, and extension declaration. + if err := validateEnumDeclarations(f.L1.Enums.List, fd.GetEnumType()); err != nil { + return nil, err + } + if err := validateMessageDeclarations(f.L1.Messages.List, fd.GetMessageType()); err != nil { + return nil, err + } + if err := validateExtensionDeclarations(f.L1.Extensions.List, fd.GetExtension()); err != nil { + return nil, err + } + + return f, nil +} + +type importSet map[string]bool + +func (is importSet) importPublic(imps protoreflect.FileImports) { + for i := 0; i < imps.Len(); i++ { + if imp := imps.Get(i); imp.IsPublic { + is[imp.Path()] = true + is.importPublic(imp.Imports()) + } + } +} + +// NewFiles creates a new protoregistry.Files from the provided +// FileDescriptorSet message. The descriptor set must include only +// valid files according to protobuf semantics. The returned descriptors +// are a deep copy of the input. +func (o FileOptions) NewFiles(fds *descriptorpb.FileDescriptorSet) (*protoregistry.Files, error) { + files := make(map[string]*descriptorpb.FileDescriptorProto) + for _, fd := range fds.File { + if _, ok := files[fd.GetName()]; ok { + return nil, errors.New("file appears multiple times: %q", fd.GetName()) + } + files[fd.GetName()] = fd + } + r := &protoregistry.Files{} + for _, fd := range files { + if err := o.addFileDeps(r, fd, files); err != nil { + return nil, err + } + } + return r, nil +} +func (o FileOptions) addFileDeps(r *protoregistry.Files, fd *descriptorpb.FileDescriptorProto, files map[string]*descriptorpb.FileDescriptorProto) error { + // Set the entry to nil while descending into a file's dependencies to detect cycles. + files[fd.GetName()] = nil + for _, dep := range fd.Dependency { + depfd, ok := files[dep] + if depfd == nil { + if ok { + return errors.New("import cycle in file: %q", dep) + } + continue + } + if err := o.addFileDeps(r, depfd, files); err != nil { + return err + } + } + // Delete the entry once dependencies are processed. + delete(files, fd.GetName()) + f, err := o.New(fd, r) + if err != nil { + return err + } + return r.RegisterFile(f) +} diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go new file mode 100644 index 000000000..673a230e7 --- /dev/null +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go @@ -0,0 +1,248 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package protodesc + +import ( + "google.golang.org/protobuf/internal/errors" + "google.golang.org/protobuf/internal/filedesc" + "google.golang.org/protobuf/internal/strs" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + "google.golang.org/protobuf/types/descriptorpb" +) + +type descsByName map[protoreflect.FullName]protoreflect.Descriptor + +func (r descsByName) initEnumDeclarations(eds []*descriptorpb.EnumDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (es []filedesc.Enum, err error) { + es = make([]filedesc.Enum, len(eds)) // allocate up-front to ensure stable pointers + for i, ed := range eds { + e := &es[i] + e.L2 = new(filedesc.EnumL2) + if e.L0, err = r.makeBase(e, parent, ed.GetName(), i, sb); err != nil { + return nil, err + } + if opts := ed.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.EnumOptions) + e.L2.Options = func() protoreflect.ProtoMessage { return opts } + } + for _, s := range ed.GetReservedName() { + e.L2.ReservedNames.List = append(e.L2.ReservedNames.List, protoreflect.Name(s)) + } + for _, rr := range ed.GetReservedRange() { + e.L2.ReservedRanges.List = append(e.L2.ReservedRanges.List, [2]protoreflect.EnumNumber{ + protoreflect.EnumNumber(rr.GetStart()), + protoreflect.EnumNumber(rr.GetEnd()), + }) + } + if e.L2.Values.List, err = r.initEnumValuesFromDescriptorProto(ed.GetValue(), e, sb); err != nil { + return nil, err + } + } + return es, nil +} + +func (r descsByName) initEnumValuesFromDescriptorProto(vds []*descriptorpb.EnumValueDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (vs []filedesc.EnumValue, err error) { + vs = make([]filedesc.EnumValue, len(vds)) // allocate up-front to ensure stable pointers + for i, vd := range vds { + v := &vs[i] + if v.L0, err = r.makeBase(v, parent, vd.GetName(), i, sb); err != nil { + return nil, err + } + if opts := vd.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.EnumValueOptions) + v.L1.Options = func() protoreflect.ProtoMessage { return opts } + } + v.L1.Number = protoreflect.EnumNumber(vd.GetNumber()) + } + return vs, nil +} + +func (r descsByName) initMessagesDeclarations(mds []*descriptorpb.DescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (ms []filedesc.Message, err error) { + ms = make([]filedesc.Message, len(mds)) // allocate up-front to ensure stable pointers + for i, md := range mds { + m := &ms[i] + m.L2 = new(filedesc.MessageL2) + if m.L0, err = r.makeBase(m, parent, md.GetName(), i, sb); err != nil { + return nil, err + } + if opts := md.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.MessageOptions) + m.L2.Options = func() protoreflect.ProtoMessage { return opts } + m.L1.IsMapEntry = opts.GetMapEntry() + m.L1.IsMessageSet = opts.GetMessageSetWireFormat() + } + for _, s := range md.GetReservedName() { + m.L2.ReservedNames.List = append(m.L2.ReservedNames.List, protoreflect.Name(s)) + } + for _, rr := range md.GetReservedRange() { + m.L2.ReservedRanges.List = append(m.L2.ReservedRanges.List, [2]protoreflect.FieldNumber{ + protoreflect.FieldNumber(rr.GetStart()), + protoreflect.FieldNumber(rr.GetEnd()), + }) + } + for _, xr := range md.GetExtensionRange() { + m.L2.ExtensionRanges.List = append(m.L2.ExtensionRanges.List, [2]protoreflect.FieldNumber{ + protoreflect.FieldNumber(xr.GetStart()), + protoreflect.FieldNumber(xr.GetEnd()), + }) + var optsFunc func() protoreflect.ProtoMessage + if opts := xr.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.ExtensionRangeOptions) + optsFunc = func() protoreflect.ProtoMessage { return opts } + } + m.L2.ExtensionRangeOptions = append(m.L2.ExtensionRangeOptions, optsFunc) + } + if m.L2.Fields.List, err = r.initFieldsFromDescriptorProto(md.GetField(), m, sb); err != nil { + return nil, err + } + if m.L2.Oneofs.List, err = r.initOneofsFromDescriptorProto(md.GetOneofDecl(), m, sb); err != nil { + return nil, err + } + if m.L1.Enums.List, err = r.initEnumDeclarations(md.GetEnumType(), m, sb); err != nil { + return nil, err + } + if m.L1.Messages.List, err = r.initMessagesDeclarations(md.GetNestedType(), m, sb); err != nil { + return nil, err + } + if m.L1.Extensions.List, err = r.initExtensionDeclarations(md.GetExtension(), m, sb); err != nil { + return nil, err + } + } + return ms, nil +} + +func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (fs []filedesc.Field, err error) { + fs = make([]filedesc.Field, len(fds)) // allocate up-front to ensure stable pointers + for i, fd := range fds { + f := &fs[i] + if f.L0, err = r.makeBase(f, parent, fd.GetName(), i, sb); err != nil { + return nil, err + } + f.L1.IsProto3Optional = fd.GetProto3Optional() + if opts := fd.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.FieldOptions) + f.L1.Options = func() protoreflect.ProtoMessage { return opts } + f.L1.IsWeak = opts.GetWeak() + f.L1.HasPacked = opts.Packed != nil + f.L1.IsPacked = opts.GetPacked() + } + f.L1.Number = protoreflect.FieldNumber(fd.GetNumber()) + f.L1.Cardinality = protoreflect.Cardinality(fd.GetLabel()) + if fd.Type != nil { + f.L1.Kind = protoreflect.Kind(fd.GetType()) + } + if fd.JsonName != nil { + f.L1.JSONName.Init(fd.GetJsonName()) + } + } + return fs, nil +} + +func (r descsByName) initOneofsFromDescriptorProto(ods []*descriptorpb.OneofDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (os []filedesc.Oneof, err error) { + os = make([]filedesc.Oneof, len(ods)) // allocate up-front to ensure stable pointers + for i, od := range ods { + o := &os[i] + if o.L0, err = r.makeBase(o, parent, od.GetName(), i, sb); err != nil { + return nil, err + } + if opts := od.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.OneofOptions) + o.L1.Options = func() protoreflect.ProtoMessage { return opts } + } + } + return os, nil +} + +func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (xs []filedesc.Extension, err error) { + xs = make([]filedesc.Extension, len(xds)) // allocate up-front to ensure stable pointers + for i, xd := range xds { + x := &xs[i] + x.L2 = new(filedesc.ExtensionL2) + if x.L0, err = r.makeBase(x, parent, xd.GetName(), i, sb); err != nil { + return nil, err + } + if opts := xd.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.FieldOptions) + x.L2.Options = func() protoreflect.ProtoMessage { return opts } + x.L2.IsPacked = opts.GetPacked() + } + x.L1.Number = protoreflect.FieldNumber(xd.GetNumber()) + x.L1.Cardinality = protoreflect.Cardinality(xd.GetLabel()) + if xd.Type != nil { + x.L1.Kind = protoreflect.Kind(xd.GetType()) + } + if xd.JsonName != nil { + x.L2.JSONName.Init(xd.GetJsonName()) + } + } + return xs, nil +} + +func (r descsByName) initServiceDeclarations(sds []*descriptorpb.ServiceDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (ss []filedesc.Service, err error) { + ss = make([]filedesc.Service, len(sds)) // allocate up-front to ensure stable pointers + for i, sd := range sds { + s := &ss[i] + s.L2 = new(filedesc.ServiceL2) + if s.L0, err = r.makeBase(s, parent, sd.GetName(), i, sb); err != nil { + return nil, err + } + if opts := sd.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.ServiceOptions) + s.L2.Options = func() protoreflect.ProtoMessage { return opts } + } + if s.L2.Methods.List, err = r.initMethodsFromDescriptorProto(sd.GetMethod(), s, sb); err != nil { + return nil, err + } + } + return ss, nil +} + +func (r descsByName) initMethodsFromDescriptorProto(mds []*descriptorpb.MethodDescriptorProto, parent protoreflect.Descriptor, sb *strs.Builder) (ms []filedesc.Method, err error) { + ms = make([]filedesc.Method, len(mds)) // allocate up-front to ensure stable pointers + for i, md := range mds { + m := &ms[i] + if m.L0, err = r.makeBase(m, parent, md.GetName(), i, sb); err != nil { + return nil, err + } + if opts := md.GetOptions(); opts != nil { + opts = proto.Clone(opts).(*descriptorpb.MethodOptions) + m.L1.Options = func() protoreflect.ProtoMessage { return opts } + } + m.L1.IsStreamingClient = md.GetClientStreaming() + m.L1.IsStreamingServer = md.GetServerStreaming() + } + return ms, nil +} + +func (r descsByName) makeBase(child, parent protoreflect.Descriptor, name string, idx int, sb *strs.Builder) (filedesc.BaseL0, error) { + if !protoreflect.Name(name).IsValid() { + return filedesc.BaseL0{}, errors.New("descriptor %q has an invalid nested name: %q", parent.FullName(), name) + } + + // Derive the full name of the child. + // Note that enum values are a sibling to the enum parent in the namespace. + var fullName protoreflect.FullName + if _, ok := parent.(protoreflect.EnumDescriptor); ok { + fullName = sb.AppendFullName(parent.FullName().Parent(), protoreflect.Name(name)) + } else { + fullName = sb.AppendFullName(parent.FullName(), protoreflect.Name(name)) + } + if _, ok := r[fullName]; ok { + return filedesc.BaseL0{}, errors.New("descriptor %q already declared", fullName) + } + r[fullName] = child + + // TODO: Verify that the full name does not already exist in the resolver? + // This is not as critical since most usages of NewFile will register + // the created file back into the registry, which will perform this check. + + return filedesc.BaseL0{ + FullName: fullName, + ParentFile: parent.ParentFile().(*filedesc.File), + Parent: parent, + Index: idx, + }, nil +} diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go new file mode 100644 index 000000000..cebb36cda --- /dev/null +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go @@ -0,0 +1,286 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package protodesc + +import ( + "google.golang.org/protobuf/internal/encoding/defval" + "google.golang.org/protobuf/internal/errors" + "google.golang.org/protobuf/internal/filedesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + + "google.golang.org/protobuf/types/descriptorpb" +) + +// resolver is a wrapper around a local registry of declarations within the file +// and the remote resolver. The remote resolver is restricted to only return +// descriptors that have been imported. +type resolver struct { + local descsByName + remote Resolver + imports importSet + + allowUnresolvable bool +} + +func (r *resolver) resolveMessageDependencies(ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) (err error) { + for i, md := range mds { + m := &ms[i] + for j, fd := range md.GetField() { + f := &m.L2.Fields.List[j] + if f.L1.Cardinality == protoreflect.Required { + m.L2.RequiredNumbers.List = append(m.L2.RequiredNumbers.List, f.L1.Number) + } + if fd.OneofIndex != nil { + k := int(fd.GetOneofIndex()) + if !(0 <= k && k < len(md.GetOneofDecl())) { + return errors.New("message field %q has an invalid oneof index: %d", f.FullName(), k) + } + o := &m.L2.Oneofs.List[k] + f.L1.ContainingOneof = o + o.L1.Fields.List = append(o.L1.Fields.List, f) + } + + if f.L1.Kind, f.L1.Enum, f.L1.Message, err = r.findTarget(f.Kind(), f.Parent().FullName(), partialName(fd.GetTypeName()), f.IsWeak()); err != nil { + return errors.New("message field %q cannot resolve type: %v", f.FullName(), err) + } + if fd.DefaultValue != nil { + v, ev, err := unmarshalDefault(fd.GetDefaultValue(), f, r.allowUnresolvable) + if err != nil { + return errors.New("message field %q has invalid default: %v", f.FullName(), err) + } + f.L1.Default = filedesc.DefaultValue(v, ev) + } + } + + if err := r.resolveMessageDependencies(m.L1.Messages.List, md.GetNestedType()); err != nil { + return err + } + if err := r.resolveExtensionDependencies(m.L1.Extensions.List, md.GetExtension()); err != nil { + return err + } + } + return nil +} + +func (r *resolver) resolveExtensionDependencies(xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) (err error) { + for i, xd := range xds { + x := &xs[i] + if x.L1.Extendee, err = r.findMessageDescriptor(x.Parent().FullName(), partialName(xd.GetExtendee()), false); err != nil { + return errors.New("extension field %q cannot resolve extendee: %v", x.FullName(), err) + } + if x.L1.Kind, x.L2.Enum, x.L2.Message, err = r.findTarget(x.Kind(), x.Parent().FullName(), partialName(xd.GetTypeName()), false); err != nil { + return errors.New("extension field %q cannot resolve type: %v", x.FullName(), err) + } + if xd.DefaultValue != nil { + v, ev, err := unmarshalDefault(xd.GetDefaultValue(), x, r.allowUnresolvable) + if err != nil { + return errors.New("extension field %q has invalid default: %v", x.FullName(), err) + } + x.L2.Default = filedesc.DefaultValue(v, ev) + } + } + return nil +} + +func (r *resolver) resolveServiceDependencies(ss []filedesc.Service, sds []*descriptorpb.ServiceDescriptorProto) (err error) { + for i, sd := range sds { + s := &ss[i] + for j, md := range sd.GetMethod() { + m := &s.L2.Methods.List[j] + m.L1.Input, err = r.findMessageDescriptor(m.Parent().FullName(), partialName(md.GetInputType()), false) + if err != nil { + return errors.New("service method %q cannot resolve input: %v", m.FullName(), err) + } + m.L1.Output, err = r.findMessageDescriptor(s.FullName(), partialName(md.GetOutputType()), false) + if err != nil { + return errors.New("service method %q cannot resolve output: %v", m.FullName(), err) + } + } + } + return nil +} + +// findTarget finds an enum or message descriptor if k is an enum, message, +// group, or unknown. If unknown, and the name could be resolved, the kind +// returned kind is set based on the type of the resolved descriptor. +func (r *resolver) findTarget(k protoreflect.Kind, scope protoreflect.FullName, ref partialName, isWeak bool) (protoreflect.Kind, protoreflect.EnumDescriptor, protoreflect.MessageDescriptor, error) { + switch k { + case protoreflect.EnumKind: + ed, err := r.findEnumDescriptor(scope, ref, isWeak) + if err != nil { + return 0, nil, nil, err + } + return k, ed, nil, nil + case protoreflect.MessageKind, protoreflect.GroupKind: + md, err := r.findMessageDescriptor(scope, ref, isWeak) + if err != nil { + return 0, nil, nil, err + } + return k, nil, md, nil + case 0: + // Handle unspecified kinds (possible with parsers that operate + // on a per-file basis without knowledge of dependencies). + d, err := r.findDescriptor(scope, ref) + if err == protoregistry.NotFound && (r.allowUnresolvable || isWeak) { + return k, filedesc.PlaceholderEnum(ref.FullName()), filedesc.PlaceholderMessage(ref.FullName()), nil + } else if err == protoregistry.NotFound { + return 0, nil, nil, errors.New("%q not found", ref.FullName()) + } else if err != nil { + return 0, nil, nil, err + } + switch d := d.(type) { + case protoreflect.EnumDescriptor: + return protoreflect.EnumKind, d, nil, nil + case protoreflect.MessageDescriptor: + return protoreflect.MessageKind, nil, d, nil + default: + return 0, nil, nil, errors.New("unknown kind") + } + default: + if ref != "" { + return 0, nil, nil, errors.New("target name cannot be specified for %v", k) + } + if !k.IsValid() { + return 0, nil, nil, errors.New("invalid kind: %d", k) + } + return k, nil, nil, nil + } +} + +// findDescriptor finds the descriptor by name, +// which may be a relative name within some scope. +// +// Suppose the scope was "fizz.buzz" and the reference was "Foo.Bar", +// then the following full names are searched: +// * fizz.buzz.Foo.Bar +// * fizz.Foo.Bar +// * Foo.Bar +func (r *resolver) findDescriptor(scope protoreflect.FullName, ref partialName) (protoreflect.Descriptor, error) { + if !ref.IsValid() { + return nil, errors.New("invalid name reference: %q", ref) + } + if ref.IsFull() { + scope, ref = "", ref[1:] + } + var foundButNotImported protoreflect.Descriptor + for { + // Derive the full name to search. + s := protoreflect.FullName(ref) + if scope != "" { + s = scope + "." + s + } + + // Check the current file for the descriptor. + if d, ok := r.local[s]; ok { + return d, nil + } + + // Check the remote registry for the descriptor. + d, err := r.remote.FindDescriptorByName(s) + if err == nil { + // Only allow descriptors covered by one of the imports. + if r.imports[d.ParentFile().Path()] { + return d, nil + } + foundButNotImported = d + } else if err != protoregistry.NotFound { + return nil, errors.Wrap(err, "%q", s) + } + + // Continue on at a higher level of scoping. + if scope == "" { + if d := foundButNotImported; d != nil { + return nil, errors.New("resolved %q, but %q is not imported", d.FullName(), d.ParentFile().Path()) + } + return nil, protoregistry.NotFound + } + scope = scope.Parent() + } +} + +func (r *resolver) findEnumDescriptor(scope protoreflect.FullName, ref partialName, isWeak bool) (protoreflect.EnumDescriptor, error) { + d, err := r.findDescriptor(scope, ref) + if err == protoregistry.NotFound && (r.allowUnresolvable || isWeak) { + return filedesc.PlaceholderEnum(ref.FullName()), nil + } else if err == protoregistry.NotFound { + return nil, errors.New("%q not found", ref.FullName()) + } else if err != nil { + return nil, err + } + ed, ok := d.(protoreflect.EnumDescriptor) + if !ok { + return nil, errors.New("resolved %q, but it is not an enum", d.FullName()) + } + return ed, nil +} + +func (r *resolver) findMessageDescriptor(scope protoreflect.FullName, ref partialName, isWeak bool) (protoreflect.MessageDescriptor, error) { + d, err := r.findDescriptor(scope, ref) + if err == protoregistry.NotFound && (r.allowUnresolvable || isWeak) { + return filedesc.PlaceholderMessage(ref.FullName()), nil + } else if err == protoregistry.NotFound { + return nil, errors.New("%q not found", ref.FullName()) + } else if err != nil { + return nil, err + } + md, ok := d.(protoreflect.MessageDescriptor) + if !ok { + return nil, errors.New("resolved %q, but it is not an message", d.FullName()) + } + return md, nil +} + +// partialName is the partial name. A leading dot means that the name is full, +// otherwise the name is relative to some current scope. +// See google.protobuf.FieldDescriptorProto.type_name. +type partialName string + +func (s partialName) IsFull() bool { + return len(s) > 0 && s[0] == '.' +} + +func (s partialName) IsValid() bool { + if s.IsFull() { + return protoreflect.FullName(s[1:]).IsValid() + } + return protoreflect.FullName(s).IsValid() +} + +const unknownPrefix = "*." + +// FullName converts the partial name to a full name on a best-effort basis. +// If relative, it creates an invalid full name, using a "*." prefix +// to indicate that the start of the full name is unknown. +func (s partialName) FullName() protoreflect.FullName { + if s.IsFull() { + return protoreflect.FullName(s[1:]) + } + return protoreflect.FullName(unknownPrefix + s) +} + +func unmarshalDefault(s string, fd protoreflect.FieldDescriptor, allowUnresolvable bool) (protoreflect.Value, protoreflect.EnumValueDescriptor, error) { + var evs protoreflect.EnumValueDescriptors + if fd.Enum() != nil { + evs = fd.Enum().Values() + } + v, ev, err := defval.Unmarshal(s, fd.Kind(), evs, defval.Descriptor) + if err != nil && allowUnresolvable && evs != nil && protoreflect.Name(s).IsValid() { + v = protoreflect.ValueOfEnum(0) + if evs.Len() > 0 { + v = protoreflect.ValueOfEnum(evs.Get(0).Number()) + } + ev = filedesc.PlaceholderEnumValue(fd.Enum().FullName().Parent().Append(protoreflect.Name(s))) + } else if err != nil { + return v, ev, err + } + if fd.Syntax() == protoreflect.Proto3 { + return v, ev, errors.New("cannot be specified under proto3 semantics") + } + if fd.Kind() == protoreflect.MessageKind || fd.Kind() == protoreflect.GroupKind || fd.Cardinality() == protoreflect.Repeated { + return v, ev, errors.New("cannot be specified on composite types") + } + return v, ev, nil +} diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go new file mode 100644 index 000000000..2d5fa9936 --- /dev/null +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go @@ -0,0 +1,371 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package protodesc + +import ( + "strings" + "unicode" + + "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/internal/errors" + "google.golang.org/protobuf/internal/filedesc" + "google.golang.org/protobuf/internal/flags" + "google.golang.org/protobuf/internal/genid" + "google.golang.org/protobuf/internal/strs" + "google.golang.org/protobuf/reflect/protoreflect" + + "google.golang.org/protobuf/types/descriptorpb" +) + +func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescriptorProto) error { + for i, ed := range eds { + e := &es[i] + if err := e.L2.ReservedNames.CheckValid(); err != nil { + return errors.New("enum %q reserved names has %v", e.FullName(), err) + } + if err := e.L2.ReservedRanges.CheckValid(); err != nil { + return errors.New("enum %q reserved ranges has %v", e.FullName(), err) + } + if len(ed.GetValue()) == 0 { + return errors.New("enum %q must contain at least one value declaration", e.FullName()) + } + allowAlias := ed.GetOptions().GetAllowAlias() + foundAlias := false + for i := 0; i < e.Values().Len(); i++ { + v1 := e.Values().Get(i) + if v2 := e.Values().ByNumber(v1.Number()); v1 != v2 { + foundAlias = true + if !allowAlias { + return errors.New("enum %q has conflicting non-aliased values on number %d: %q with %q", e.FullName(), v1.Number(), v1.Name(), v2.Name()) + } + } + } + if allowAlias && !foundAlias { + return errors.New("enum %q allows aliases, but none were found", e.FullName()) + } + if e.Syntax() == protoreflect.Proto3 { + if v := e.Values().Get(0); v.Number() != 0 { + return errors.New("enum %q using proto3 semantics must have zero number for the first value", v.FullName()) + } + // Verify that value names in proto3 do not conflict if the + // case-insensitive prefix is removed. + // See protoc v3.8.0: src/google/protobuf/descriptor.cc:4991-5055 + names := map[string]protoreflect.EnumValueDescriptor{} + prefix := strings.Replace(strings.ToLower(string(e.Name())), "_", "", -1) + for i := 0; i < e.Values().Len(); i++ { + v1 := e.Values().Get(i) + s := strs.EnumValueName(strs.TrimEnumPrefix(string(v1.Name()), prefix)) + if v2, ok := names[s]; ok && v1.Number() != v2.Number() { + return errors.New("enum %q using proto3 semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name()) + } + names[s] = v1 + } + } + + for j, vd := range ed.GetValue() { + v := &e.L2.Values.List[j] + if vd.Number == nil { + return errors.New("enum value %q must have a specified number", v.FullName()) + } + if e.L2.ReservedNames.Has(v.Name()) { + return errors.New("enum value %q must not use reserved name", v.FullName()) + } + if e.L2.ReservedRanges.Has(v.Number()) { + return errors.New("enum value %q must not use reserved number %d", v.FullName(), v.Number()) + } + } + } + return nil +} + +func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error { + for i, md := range mds { + m := &ms[i] + + // Handle the message descriptor itself. + isMessageSet := md.GetOptions().GetMessageSetWireFormat() + if err := m.L2.ReservedNames.CheckValid(); err != nil { + return errors.New("message %q reserved names has %v", m.FullName(), err) + } + if err := m.L2.ReservedRanges.CheckValid(isMessageSet); err != nil { + return errors.New("message %q reserved ranges has %v", m.FullName(), err) + } + if err := m.L2.ExtensionRanges.CheckValid(isMessageSet); err != nil { + return errors.New("message %q extension ranges has %v", m.FullName(), err) + } + if err := (*filedesc.FieldRanges).CheckOverlap(&m.L2.ReservedRanges, &m.L2.ExtensionRanges); err != nil { + return errors.New("message %q reserved and extension ranges has %v", m.FullName(), err) + } + for i := 0; i < m.Fields().Len(); i++ { + f1 := m.Fields().Get(i) + if f2 := m.Fields().ByNumber(f1.Number()); f1 != f2 { + return errors.New("message %q has conflicting fields: %q with %q", m.FullName(), f1.Name(), f2.Name()) + } + } + if isMessageSet && !flags.ProtoLegacy { + return errors.New("message %q is a MessageSet, which is a legacy proto1 feature that is no longer supported", m.FullName()) + } + if isMessageSet && (m.Syntax() != protoreflect.Proto2 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) { + return errors.New("message %q is an invalid proto1 MessageSet", m.FullName()) + } + if m.Syntax() == protoreflect.Proto3 { + if m.ExtensionRanges().Len() > 0 { + return errors.New("message %q using proto3 semantics cannot have extension ranges", m.FullName()) + } + // Verify that field names in proto3 do not conflict if lowercased + // with all underscores removed. + // See protoc v3.8.0: src/google/protobuf/descriptor.cc:5830-5847 + names := map[string]protoreflect.FieldDescriptor{} + for i := 0; i < m.Fields().Len(); i++ { + f1 := m.Fields().Get(i) + s := strings.Replace(strings.ToLower(string(f1.Name())), "_", "", -1) + if f2, ok := names[s]; ok { + return errors.New("message %q using proto3 semantics has conflict: %q with %q", m.FullName(), f1.Name(), f2.Name()) + } + names[s] = f1 + } + } + + for j, fd := range md.GetField() { + f := &m.L2.Fields.List[j] + if m.L2.ReservedNames.Has(f.Name()) { + return errors.New("message field %q must not use reserved name", f.FullName()) + } + if !f.Number().IsValid() { + return errors.New("message field %q has an invalid number: %d", f.FullName(), f.Number()) + } + if !f.Cardinality().IsValid() { + return errors.New("message field %q has an invalid cardinality: %d", f.FullName(), f.Cardinality()) + } + if m.L2.ReservedRanges.Has(f.Number()) { + return errors.New("message field %q must not use reserved number %d", f.FullName(), f.Number()) + } + if m.L2.ExtensionRanges.Has(f.Number()) { + return errors.New("message field %q with number %d in extension range", f.FullName(), f.Number()) + } + if fd.Extendee != nil { + return errors.New("message field %q may not have extendee: %q", f.FullName(), fd.GetExtendee()) + } + if f.L1.IsProto3Optional { + if f.Syntax() != protoreflect.Proto3 { + return errors.New("message field %q under proto3 optional semantics must be specified in the proto3 syntax", f.FullName()) + } + if f.Cardinality() != protoreflect.Optional { + return errors.New("message field %q under proto3 optional semantics must have optional cardinality", f.FullName()) + } + if f.ContainingOneof() != nil && f.ContainingOneof().Fields().Len() != 1 { + return errors.New("message field %q under proto3 optional semantics must be within a single element oneof", f.FullName()) + } + } + if f.IsWeak() && !flags.ProtoLegacy { + return errors.New("message field %q is a weak field, which is a legacy proto1 feature that is no longer supported", f.FullName()) + } + if f.IsWeak() && (f.Syntax() != protoreflect.Proto2 || !isOptionalMessage(f) || f.ContainingOneof() != nil) { + return errors.New("message field %q may only be weak for an optional message", f.FullName()) + } + if f.IsPacked() && !isPackable(f) { + return errors.New("message field %q is not packable", f.FullName()) + } + if err := checkValidGroup(f); err != nil { + return errors.New("message field %q is an invalid group: %v", f.FullName(), err) + } + if err := checkValidMap(f); err != nil { + return errors.New("message field %q is an invalid map: %v", f.FullName(), err) + } + if f.Syntax() == protoreflect.Proto3 { + if f.Cardinality() == protoreflect.Required { + return errors.New("message field %q using proto3 semantics cannot be required", f.FullName()) + } + if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().Syntax() != protoreflect.Proto3 { + return errors.New("message field %q using proto3 semantics may only depend on a proto3 enum", f.FullName()) + } + } + } + seenSynthetic := false // synthetic oneofs for proto3 optional must come after real oneofs + for j := range md.GetOneofDecl() { + o := &m.L2.Oneofs.List[j] + if o.Fields().Len() == 0 { + return errors.New("message oneof %q must contain at least one field declaration", o.FullName()) + } + if n := o.Fields().Len(); n-1 != (o.Fields().Get(n-1).Index() - o.Fields().Get(0).Index()) { + return errors.New("message oneof %q must have consecutively declared fields", o.FullName()) + } + + if o.IsSynthetic() { + seenSynthetic = true + continue + } + if !o.IsSynthetic() && seenSynthetic { + return errors.New("message oneof %q must be declared before synthetic oneofs", o.FullName()) + } + + for i := 0; i < o.Fields().Len(); i++ { + f := o.Fields().Get(i) + if f.Cardinality() != protoreflect.Optional { + return errors.New("message field %q belongs in a oneof and must be optional", f.FullName()) + } + if f.IsWeak() { + return errors.New("message field %q belongs in a oneof and must not be a weak reference", f.FullName()) + } + } + } + + if err := validateEnumDeclarations(m.L1.Enums.List, md.GetEnumType()); err != nil { + return err + } + if err := validateMessageDeclarations(m.L1.Messages.List, md.GetNestedType()); err != nil { + return err + } + if err := validateExtensionDeclarations(m.L1.Extensions.List, md.GetExtension()); err != nil { + return err + } + } + return nil +} + +func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error { + for i, xd := range xds { + x := &xs[i] + // NOTE: Avoid using the IsValid method since extensions to MessageSet + // may have a field number higher than normal. This check only verifies + // that the number is not negative or reserved. We check again later + // if we know that the extendee is definitely not a MessageSet. + if n := x.Number(); n < 0 || (protowire.FirstReservedNumber <= n && n <= protowire.LastReservedNumber) { + return errors.New("extension field %q has an invalid number: %d", x.FullName(), x.Number()) + } + if !x.Cardinality().IsValid() || x.Cardinality() == protoreflect.Required { + return errors.New("extension field %q has an invalid cardinality: %d", x.FullName(), x.Cardinality()) + } + if xd.JsonName != nil { + if xd.GetJsonName() != strs.JSONCamelCase(string(x.Name())) { + return errors.New("extension field %q may not have an explicitly set JSON name: %q", x.FullName(), xd.GetJsonName()) + } + } + if xd.OneofIndex != nil { + return errors.New("extension field %q may not be part of a oneof", x.FullName()) + } + if md := x.ContainingMessage(); !md.IsPlaceholder() { + if !md.ExtensionRanges().Has(x.Number()) { + return errors.New("extension field %q extends %q with non-extension field number: %d", x.FullName(), md.FullName(), x.Number()) + } + isMessageSet := md.Options().(*descriptorpb.MessageOptions).GetMessageSetWireFormat() + if isMessageSet && !isOptionalMessage(x) { + return errors.New("extension field %q extends MessageSet and must be an optional message", x.FullName()) + } + if !isMessageSet && !x.Number().IsValid() { + return errors.New("extension field %q has an invalid number: %d", x.FullName(), x.Number()) + } + } + if xd.GetOptions().GetWeak() { + return errors.New("extension field %q cannot be a weak reference", x.FullName()) + } + if x.IsPacked() && !isPackable(x) { + return errors.New("extension field %q is not packable", x.FullName()) + } + if err := checkValidGroup(x); err != nil { + return errors.New("extension field %q is an invalid group: %v", x.FullName(), err) + } + if md := x.Message(); md != nil && md.IsMapEntry() { + return errors.New("extension field %q cannot be a map entry", x.FullName()) + } + if x.Syntax() == protoreflect.Proto3 { + switch x.ContainingMessage().FullName() { + case (*descriptorpb.FileOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.EnumOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.EnumValueOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.MessageOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.FieldOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.OneofOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.ExtensionRangeOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.ServiceOptions)(nil).ProtoReflect().Descriptor().FullName(): + case (*descriptorpb.MethodOptions)(nil).ProtoReflect().Descriptor().FullName(): + default: + return errors.New("extension field %q cannot be declared in proto3 unless extended descriptor options", x.FullName()) + } + } + } + return nil +} + +// isOptionalMessage reports whether this is an optional message. +// If the kind is unknown, it is assumed to be a message. +func isOptionalMessage(fd protoreflect.FieldDescriptor) bool { + return (fd.Kind() == 0 || fd.Kind() == protoreflect.MessageKind) && fd.Cardinality() == protoreflect.Optional +} + +// isPackable checks whether the pack option can be specified. +func isPackable(fd protoreflect.FieldDescriptor) bool { + switch fd.Kind() { + case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind: + return false + } + return fd.IsList() +} + +// checkValidGroup reports whether fd is a valid group according to the same +// rules that protoc imposes. +func checkValidGroup(fd protoreflect.FieldDescriptor) error { + md := fd.Message() + switch { + case fd.Kind() != protoreflect.GroupKind: + return nil + case fd.Syntax() != protoreflect.Proto2: + return errors.New("invalid under proto2 semantics") + case md == nil || md.IsPlaceholder(): + return errors.New("message must be resolvable") + case fd.FullName().Parent() != md.FullName().Parent(): + return errors.New("message and field must be declared in the same scope") + case !unicode.IsUpper(rune(md.Name()[0])): + return errors.New("message name must start with an uppercase") + case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))): + return errors.New("field name must be lowercased form of the message name") + } + return nil +} + +// checkValidMap checks whether the field is a valid map according to the same +// rules that protoc imposes. +// See protoc v3.8.0: src/google/protobuf/descriptor.cc:6045-6115 +func checkValidMap(fd protoreflect.FieldDescriptor) error { + md := fd.Message() + switch { + case md == nil || !md.IsMapEntry(): + return nil + case fd.FullName().Parent() != md.FullName().Parent(): + return errors.New("message and field must be declared in the same scope") + case md.Name() != protoreflect.Name(strs.MapEntryName(string(fd.Name()))): + return errors.New("incorrect implicit map entry name") + case fd.Cardinality() != protoreflect.Repeated: + return errors.New("field must be repeated") + case md.Fields().Len() != 2: + return errors.New("message must have exactly two fields") + case md.ExtensionRanges().Len() > 0: + return errors.New("message must not have any extension ranges") + case md.Enums().Len()+md.Messages().Len()+md.Extensions().Len() > 0: + return errors.New("message must not have any nested declarations") + } + kf := md.Fields().Get(0) + vf := md.Fields().Get(1) + switch { + case kf.Name() != genid.MapEntry_Key_field_name || kf.Number() != genid.MapEntry_Key_field_number || kf.Cardinality() != protoreflect.Optional || kf.ContainingOneof() != nil || kf.HasDefault(): + return errors.New("invalid key field") + case vf.Name() != genid.MapEntry_Value_field_name || vf.Number() != genid.MapEntry_Value_field_number || vf.Cardinality() != protoreflect.Optional || vf.ContainingOneof() != nil || vf.HasDefault(): + return errors.New("invalid value field") + } + switch kf.Kind() { + case protoreflect.BoolKind: // bool + case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: // int32 + case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: // int64 + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: // uint32 + case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: // uint64 + case protoreflect.StringKind: // string + default: + return errors.New("invalid key kind: %v", kf.Kind()) + } + if e := vf.Enum(); e != nil && e.Values().Len() > 0 && e.Values().Get(0).Number() != 0 { + return errors.New("map enum value must have zero number for the first value") + } + return nil +} diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go b/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go new file mode 100644 index 000000000..00d35e02e --- /dev/null +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go @@ -0,0 +1,242 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package protodesc + +import ( + "fmt" + "strings" + + "google.golang.org/protobuf/internal/encoding/defval" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + "google.golang.org/protobuf/types/descriptorpb" +) + +// ToFileDescriptorProto copies a protoreflect.FileDescriptor into a +// google.protobuf.FileDescriptorProto message. +func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto { + p := &descriptorpb.FileDescriptorProto{ + Name: proto.String(file.Path()), + Package: proto.String(string(file.Package())), + Options: proto.Clone(file.Options()).(*descriptorpb.FileOptions), + } + for i, imports := 0, file.Imports(); i < imports.Len(); i++ { + imp := imports.Get(i) + p.Dependency = append(p.Dependency, imp.Path()) + if imp.IsPublic { + p.PublicDependency = append(p.PublicDependency, int32(i)) + } + if imp.IsWeak { + p.WeakDependency = append(p.WeakDependency, int32(i)) + } + } + for i, locs := 0, file.SourceLocations(); i < locs.Len(); i++ { + loc := locs.Get(i) + l := &descriptorpb.SourceCodeInfo_Location{} + l.Path = append(l.Path, loc.Path...) + if loc.StartLine == loc.EndLine { + l.Span = []int32{int32(loc.StartLine), int32(loc.StartColumn), int32(loc.EndColumn)} + } else { + l.Span = []int32{int32(loc.StartLine), int32(loc.StartColumn), int32(loc.EndLine), int32(loc.EndColumn)} + } + l.LeadingDetachedComments = append([]string(nil), loc.LeadingDetachedComments...) + if loc.LeadingComments != "" { + l.LeadingComments = proto.String(loc.LeadingComments) + } + if loc.TrailingComments != "" { + l.TrailingComments = proto.String(loc.TrailingComments) + } + if p.SourceCodeInfo == nil { + p.SourceCodeInfo = &descriptorpb.SourceCodeInfo{} + } + p.SourceCodeInfo.Location = append(p.SourceCodeInfo.Location, l) + + } + for i, messages := 0, file.Messages(); i < messages.Len(); i++ { + p.MessageType = append(p.MessageType, ToDescriptorProto(messages.Get(i))) + } + for i, enums := 0, file.Enums(); i < enums.Len(); i++ { + p.EnumType = append(p.EnumType, ToEnumDescriptorProto(enums.Get(i))) + } + for i, services := 0, file.Services(); i < services.Len(); i++ { + p.Service = append(p.Service, ToServiceDescriptorProto(services.Get(i))) + } + for i, exts := 0, file.Extensions(); i < exts.Len(); i++ { + p.Extension = append(p.Extension, ToFieldDescriptorProto(exts.Get(i))) + } + if syntax := file.Syntax(); syntax != protoreflect.Proto2 { + p.Syntax = proto.String(file.Syntax().String()) + } + return p +} + +// ToDescriptorProto copies a protoreflect.MessageDescriptor into a +// google.protobuf.DescriptorProto message. +func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.DescriptorProto { + p := &descriptorpb.DescriptorProto{ + Name: proto.String(string(message.Name())), + Options: proto.Clone(message.Options()).(*descriptorpb.MessageOptions), + } + for i, fields := 0, message.Fields(); i < fields.Len(); i++ { + p.Field = append(p.Field, ToFieldDescriptorProto(fields.Get(i))) + } + for i, exts := 0, message.Extensions(); i < exts.Len(); i++ { + p.Extension = append(p.Extension, ToFieldDescriptorProto(exts.Get(i))) + } + for i, messages := 0, message.Messages(); i < messages.Len(); i++ { + p.NestedType = append(p.NestedType, ToDescriptorProto(messages.Get(i))) + } + for i, enums := 0, message.Enums(); i < enums.Len(); i++ { + p.EnumType = append(p.EnumType, ToEnumDescriptorProto(enums.Get(i))) + } + for i, xranges := 0, message.ExtensionRanges(); i < xranges.Len(); i++ { + xrange := xranges.Get(i) + p.ExtensionRange = append(p.ExtensionRange, &descriptorpb.DescriptorProto_ExtensionRange{ + Start: proto.Int32(int32(xrange[0])), + End: proto.Int32(int32(xrange[1])), + Options: proto.Clone(message.ExtensionRangeOptions(i)).(*descriptorpb.ExtensionRangeOptions), + }) + } + for i, oneofs := 0, message.Oneofs(); i < oneofs.Len(); i++ { + p.OneofDecl = append(p.OneofDecl, ToOneofDescriptorProto(oneofs.Get(i))) + } + for i, ranges := 0, message.ReservedRanges(); i < ranges.Len(); i++ { + rrange := ranges.Get(i) + p.ReservedRange = append(p.ReservedRange, &descriptorpb.DescriptorProto_ReservedRange{ + Start: proto.Int32(int32(rrange[0])), + End: proto.Int32(int32(rrange[1])), + }) + } + for i, names := 0, message.ReservedNames(); i < names.Len(); i++ { + p.ReservedName = append(p.ReservedName, string(names.Get(i))) + } + return p +} + +// ToFieldDescriptorProto copies a protoreflect.FieldDescriptor into a +// google.protobuf.FieldDescriptorProto message. +func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.FieldDescriptorProto { + p := &descriptorpb.FieldDescriptorProto{ + Name: proto.String(string(field.Name())), + Number: proto.Int32(int32(field.Number())), + Label: descriptorpb.FieldDescriptorProto_Label(field.Cardinality()).Enum(), + Options: proto.Clone(field.Options()).(*descriptorpb.FieldOptions), + } + if field.IsExtension() { + p.Extendee = fullNameOf(field.ContainingMessage()) + } + if field.Kind().IsValid() { + p.Type = descriptorpb.FieldDescriptorProto_Type(field.Kind()).Enum() + } + if field.Enum() != nil { + p.TypeName = fullNameOf(field.Enum()) + } + if field.Message() != nil { + p.TypeName = fullNameOf(field.Message()) + } + if field.HasJSONName() { + p.JsonName = proto.String(field.JSONName()) + } + if field.Syntax() == protoreflect.Proto3 && field.HasOptionalKeyword() { + p.Proto3Optional = proto.Bool(true) + } + if field.HasDefault() { + def, err := defval.Marshal(field.Default(), field.DefaultEnumValue(), field.Kind(), defval.Descriptor) + if err != nil && field.DefaultEnumValue() != nil { + def = string(field.DefaultEnumValue().Name()) // occurs for unresolved enum values + } else if err != nil { + panic(fmt.Sprintf("%v: %v", field.FullName(), err)) + } + p.DefaultValue = proto.String(def) + } + if oneof := field.ContainingOneof(); oneof != nil { + p.OneofIndex = proto.Int32(int32(oneof.Index())) + } + return p +} + +// ToOneofDescriptorProto copies a protoreflect.OneofDescriptor into a +// google.protobuf.OneofDescriptorProto message. +func ToOneofDescriptorProto(oneof protoreflect.OneofDescriptor) *descriptorpb.OneofDescriptorProto { + return &descriptorpb.OneofDescriptorProto{ + Name: proto.String(string(oneof.Name())), + Options: proto.Clone(oneof.Options()).(*descriptorpb.OneofOptions), + } +} + +// ToEnumDescriptorProto copies a protoreflect.EnumDescriptor into a +// google.protobuf.EnumDescriptorProto message. +func ToEnumDescriptorProto(enum protoreflect.EnumDescriptor) *descriptorpb.EnumDescriptorProto { + p := &descriptorpb.EnumDescriptorProto{ + Name: proto.String(string(enum.Name())), + Options: proto.Clone(enum.Options()).(*descriptorpb.EnumOptions), + } + for i, values := 0, enum.Values(); i < values.Len(); i++ { + p.Value = append(p.Value, ToEnumValueDescriptorProto(values.Get(i))) + } + for i, ranges := 0, enum.ReservedRanges(); i < ranges.Len(); i++ { + rrange := ranges.Get(i) + p.ReservedRange = append(p.ReservedRange, &descriptorpb.EnumDescriptorProto_EnumReservedRange{ + Start: proto.Int32(int32(rrange[0])), + End: proto.Int32(int32(rrange[1])), + }) + } + for i, names := 0, enum.ReservedNames(); i < names.Len(); i++ { + p.ReservedName = append(p.ReservedName, string(names.Get(i))) + } + return p +} + +// ToEnumValueDescriptorProto copies a protoreflect.EnumValueDescriptor into a +// google.protobuf.EnumValueDescriptorProto message. +func ToEnumValueDescriptorProto(value protoreflect.EnumValueDescriptor) *descriptorpb.EnumValueDescriptorProto { + return &descriptorpb.EnumValueDescriptorProto{ + Name: proto.String(string(value.Name())), + Number: proto.Int32(int32(value.Number())), + Options: proto.Clone(value.Options()).(*descriptorpb.EnumValueOptions), + } +} + +// ToServiceDescriptorProto copies a protoreflect.ServiceDescriptor into a +// google.protobuf.ServiceDescriptorProto message. +func ToServiceDescriptorProto(service protoreflect.ServiceDescriptor) *descriptorpb.ServiceDescriptorProto { + p := &descriptorpb.ServiceDescriptorProto{ + Name: proto.String(string(service.Name())), + Options: proto.Clone(service.Options()).(*descriptorpb.ServiceOptions), + } + for i, methods := 0, service.Methods(); i < methods.Len(); i++ { + p.Method = append(p.Method, ToMethodDescriptorProto(methods.Get(i))) + } + return p +} + +// ToMethodDescriptorProto copies a protoreflect.MethodDescriptor into a +// google.protobuf.MethodDescriptorProto message. +func ToMethodDescriptorProto(method protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto { + p := &descriptorpb.MethodDescriptorProto{ + Name: proto.String(string(method.Name())), + InputType: fullNameOf(method.Input()), + OutputType: fullNameOf(method.Output()), + Options: proto.Clone(method.Options()).(*descriptorpb.MethodOptions), + } + if method.IsStreamingClient() { + p.ClientStreaming = proto.Bool(true) + } + if method.IsStreamingServer() { + p.ServerStreaming = proto.Bool(true) + } + return p +} + +func fullNameOf(d protoreflect.Descriptor) *string { + if d == nil { + return nil + } + if strings.HasPrefix(string(d.FullName()), unknownPrefix) { + return proto.String(string(d.FullName()[len(unknownPrefix):])) + } + return proto.String("." + string(d.FullName())) +} diff --git a/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go b/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go new file mode 100644 index 000000000..7db6e5598 --- /dev/null +++ b/vendor/google.golang.org/protobuf/types/dynamicpb/dynamic.go @@ -0,0 +1,701 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package dynamicpb creates protocol buffer messages using runtime type information. +package dynamicpb + +import ( + "math" + + "google.golang.org/protobuf/internal/errors" + pref "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/runtime/protoiface" + "google.golang.org/protobuf/runtime/protoimpl" +) + +// enum is a dynamic protoreflect.Enum. +type enum struct { + num pref.EnumNumber + typ pref.EnumType +} + +func (e enum) Descriptor() pref.EnumDescriptor { return e.typ.Descriptor() } +func (e enum) Type() pref.EnumType { return e.typ } +func (e enum) Number() pref.EnumNumber { return e.num } + +// enumType is a dynamic protoreflect.EnumType. +type enumType struct { + desc pref.EnumDescriptor +} + +// NewEnumType creates a new EnumType with the provided descriptor. +// +// EnumTypes created by this package are equal if their descriptors are equal. +// That is, if ed1 == ed2, then NewEnumType(ed1) == NewEnumType(ed2). +// +// Enum values created by the EnumType are equal if their numbers are equal. +func NewEnumType(desc pref.EnumDescriptor) pref.EnumType { + return enumType{desc} +} + +func (et enumType) New(n pref.EnumNumber) pref.Enum { return enum{n, et} } +func (et enumType) Descriptor() pref.EnumDescriptor { return et.desc } + +// extensionType is a dynamic protoreflect.ExtensionType. +type extensionType struct { + desc extensionTypeDescriptor +} + +// A Message is a dynamically constructed protocol buffer message. +// +// Message implements the proto.Message interface, and may be used with all +// standard proto package functions such as Marshal, Unmarshal, and so forth. +// +// Message also implements the protoreflect.Message interface. See the protoreflect +// package documentation for that interface for how to get and set fields and +// otherwise interact with the contents of a Message. +// +// Reflection API functions which construct messages, such as NewField, +// return new dynamic messages of the appropriate type. Functions which take +// messages, such as Set for a message-value field, will accept any message +// with a compatible type. +// +// Operations which modify a Message are not safe for concurrent use. +type Message struct { + typ messageType + known map[pref.FieldNumber]pref.Value + ext map[pref.FieldNumber]pref.FieldDescriptor + unknown pref.RawFields +} + +var ( + _ pref.Message = (*Message)(nil) + _ pref.ProtoMessage = (*Message)(nil) + _ protoiface.MessageV1 = (*Message)(nil) +) + +// NewMessage creates a new message with the provided descriptor. +func NewMessage(desc pref.MessageDescriptor) *Message { + return &Message{ + typ: messageType{desc}, + known: make(map[pref.FieldNumber]pref.Value), + ext: make(map[pref.FieldNumber]pref.FieldDescriptor), + } +} + +// ProtoMessage implements the legacy message interface. +func (m *Message) ProtoMessage() {} + +// ProtoReflect implements the protoreflect.ProtoMessage interface. +func (m *Message) ProtoReflect() pref.Message { + return m +} + +// String returns a string representation of a message. +func (m *Message) String() string { + return protoimpl.X.MessageStringOf(m) +} + +// Reset clears the message to be empty, but preserves the dynamic message type. +func (m *Message) Reset() { + m.known = make(map[pref.FieldNumber]pref.Value) + m.ext = make(map[pref.FieldNumber]pref.FieldDescriptor) + m.unknown = nil +} + +// Descriptor returns the message descriptor. +func (m *Message) Descriptor() pref.MessageDescriptor { + return m.typ.desc +} + +// Type returns the message type. +func (m *Message) Type() pref.MessageType { + return m.typ +} + +// New returns a newly allocated empty message with the same descriptor. +// See protoreflect.Message for details. +func (m *Message) New() pref.Message { + return m.Type().New() +} + +// Interface returns the message. +// See protoreflect.Message for details. +func (m *Message) Interface() pref.ProtoMessage { + return m +} + +// ProtoMethods is an internal detail of the protoreflect.Message interface. +// Users should never call this directly. +func (m *Message) ProtoMethods() *protoiface.Methods { + return nil +} + +// Range visits every populated field in undefined order. +// See protoreflect.Message for details. +func (m *Message) Range(f func(pref.FieldDescriptor, pref.Value) bool) { + for num, v := range m.known { + fd := m.ext[num] + if fd == nil { + fd = m.Descriptor().Fields().ByNumber(num) + } + if !isSet(fd, v) { + continue + } + if !f(fd, v) { + return + } + } +} + +// Has reports whether a field is populated. +// See protoreflect.Message for details. +func (m *Message) Has(fd pref.FieldDescriptor) bool { + m.checkField(fd) + if fd.IsExtension() && m.ext[fd.Number()] != fd { + return false + } + v, ok := m.known[fd.Number()] + if !ok { + return false + } + return isSet(fd, v) +} + +// Clear clears a field. +// See protoreflect.Message for details. +func (m *Message) Clear(fd pref.FieldDescriptor) { + m.checkField(fd) + num := fd.Number() + delete(m.known, num) + delete(m.ext, num) +} + +// Get returns the value of a field. +// See protoreflect.Message for details. +func (m *Message) Get(fd pref.FieldDescriptor) pref.Value { + m.checkField(fd) + num := fd.Number() + if fd.IsExtension() { + if fd != m.ext[num] { + return fd.(pref.ExtensionTypeDescriptor).Type().Zero() + } + return m.known[num] + } + if v, ok := m.known[num]; ok { + switch { + case fd.IsMap(): + if v.Map().Len() > 0 { + return v + } + case fd.IsList(): + if v.List().Len() > 0 { + return v + } + default: + return v + } + } + switch { + case fd.IsMap(): + return pref.ValueOfMap(&dynamicMap{desc: fd}) + case fd.IsList(): + return pref.ValueOfList(emptyList{desc: fd}) + case fd.Message() != nil: + return pref.ValueOfMessage(&Message{typ: messageType{fd.Message()}}) + case fd.Kind() == pref.BytesKind: + return pref.ValueOfBytes(append([]byte(nil), fd.Default().Bytes()...)) + default: + return fd.Default() + } +} + +// Mutable returns a mutable reference to a repeated, map, or message field. +// See protoreflect.Message for details. +func (m *Message) Mutable(fd pref.FieldDescriptor) pref.Value { + m.checkField(fd) + if !fd.IsMap() && !fd.IsList() && fd.Message() == nil { + panic(errors.New("%v: getting mutable reference to non-composite type", fd.FullName())) + } + if m.known == nil { + panic(errors.New("%v: modification of read-only message", fd.FullName())) + } + num := fd.Number() + if fd.IsExtension() { + if fd != m.ext[num] { + m.ext[num] = fd + m.known[num] = fd.(pref.ExtensionTypeDescriptor).Type().New() + } + return m.known[num] + } + if v, ok := m.known[num]; ok { + return v + } + m.clearOtherOneofFields(fd) + m.known[num] = m.NewField(fd) + if fd.IsExtension() { + m.ext[num] = fd + } + return m.known[num] +} + +// Set stores a value in a field. +// See protoreflect.Message for details. +func (m *Message) Set(fd pref.FieldDescriptor, v pref.Value) { + m.checkField(fd) + if m.known == nil { + panic(errors.New("%v: modification of read-only message", fd.FullName())) + } + if fd.IsExtension() { + isValid := true + switch { + case !fd.(pref.ExtensionTypeDescriptor).Type().IsValidValue(v): + isValid = false + case fd.IsList(): + isValid = v.List().IsValid() + case fd.IsMap(): + isValid = v.Map().IsValid() + case fd.Message() != nil: + isValid = v.Message().IsValid() + } + if !isValid { + panic(errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface())) + } + m.ext[fd.Number()] = fd + } else { + typecheck(fd, v) + } + m.clearOtherOneofFields(fd) + m.known[fd.Number()] = v +} + +func (m *Message) clearOtherOneofFields(fd pref.FieldDescriptor) { + od := fd.ContainingOneof() + if od == nil { + return + } + num := fd.Number() + for i := 0; i < od.Fields().Len(); i++ { + if n := od.Fields().Get(i).Number(); n != num { + delete(m.known, n) + } + } +} + +// NewField returns a new value for assignable to the field of a given descriptor. +// See protoreflect.Message for details. +func (m *Message) NewField(fd pref.FieldDescriptor) pref.Value { + m.checkField(fd) + switch { + case fd.IsExtension(): + return fd.(pref.ExtensionTypeDescriptor).Type().New() + case fd.IsMap(): + return pref.ValueOfMap(&dynamicMap{ + desc: fd, + mapv: make(map[interface{}]pref.Value), + }) + case fd.IsList(): + return pref.ValueOfList(&dynamicList{desc: fd}) + case fd.Message() != nil: + return pref.ValueOfMessage(NewMessage(fd.Message()).ProtoReflect()) + default: + return fd.Default() + } +} + +// WhichOneof reports which field in a oneof is populated, returning nil if none are populated. +// See protoreflect.Message for details. +func (m *Message) WhichOneof(od pref.OneofDescriptor) pref.FieldDescriptor { + for i := 0; i < od.Fields().Len(); i++ { + fd := od.Fields().Get(i) + if m.Has(fd) { + return fd + } + } + return nil +} + +// GetUnknown returns the raw unknown fields. +// See protoreflect.Message for details. +func (m *Message) GetUnknown() pref.RawFields { + return m.unknown +} + +// SetUnknown sets the raw unknown fields. +// See protoreflect.Message for details. +func (m *Message) SetUnknown(r pref.RawFields) { + if m.known == nil { + panic(errors.New("%v: modification of read-only message", m.typ.desc.FullName())) + } + m.unknown = r +} + +// IsValid reports whether the message is valid. +// See protoreflect.Message for details. +func (m *Message) IsValid() bool { + return m.known != nil +} + +func (m *Message) checkField(fd pref.FieldDescriptor) { + if fd.IsExtension() && fd.ContainingMessage().FullName() == m.Descriptor().FullName() { + if _, ok := fd.(pref.ExtensionTypeDescriptor); !ok { + panic(errors.New("%v: extension field descriptor does not implement ExtensionTypeDescriptor", fd.FullName())) + } + return + } + if fd.Parent() == m.Descriptor() { + return + } + fields := m.Descriptor().Fields() + index := fd.Index() + if index >= fields.Len() || fields.Get(index) != fd { + panic(errors.New("%v: field descriptor does not belong to this message", fd.FullName())) + } +} + +type messageType struct { + desc pref.MessageDescriptor +} + +// NewMessageType creates a new MessageType with the provided descriptor. +// +// MessageTypes created by this package are equal if their descriptors are equal. +// That is, if md1 == md2, then NewMessageType(md1) == NewMessageType(md2). +func NewMessageType(desc pref.MessageDescriptor) pref.MessageType { + return messageType{desc} +} + +func (mt messageType) New() pref.Message { return NewMessage(mt.desc) } +func (mt messageType) Zero() pref.Message { return &Message{typ: messageType{mt.desc}} } +func (mt messageType) Descriptor() pref.MessageDescriptor { return mt.desc } + +type emptyList struct { + desc pref.FieldDescriptor +} + +func (x emptyList) Len() int { return 0 } +func (x emptyList) Get(n int) pref.Value { panic(errors.New("out of range")) } +func (x emptyList) Set(n int, v pref.Value) { panic(errors.New("modification of immutable list")) } +func (x emptyList) Append(v pref.Value) { panic(errors.New("modification of immutable list")) } +func (x emptyList) AppendMutable() pref.Value { panic(errors.New("modification of immutable list")) } +func (x emptyList) Truncate(n int) { panic(errors.New("modification of immutable list")) } +func (x emptyList) NewElement() pref.Value { return newListEntry(x.desc) } +func (x emptyList) IsValid() bool { return false } + +type dynamicList struct { + desc pref.FieldDescriptor + list []pref.Value +} + +func (x *dynamicList) Len() int { + return len(x.list) +} + +func (x *dynamicList) Get(n int) pref.Value { + return x.list[n] +} + +func (x *dynamicList) Set(n int, v pref.Value) { + typecheckSingular(x.desc, v) + x.list[n] = v +} + +func (x *dynamicList) Append(v pref.Value) { + typecheckSingular(x.desc, v) + x.list = append(x.list, v) +} + +func (x *dynamicList) AppendMutable() pref.Value { + if x.desc.Message() == nil { + panic(errors.New("%v: invalid AppendMutable on list with non-message type", x.desc.FullName())) + } + v := x.NewElement() + x.Append(v) + return v +} + +func (x *dynamicList) Truncate(n int) { + // Zero truncated elements to avoid keeping data live. + for i := n; i < len(x.list); i++ { + x.list[i] = pref.Value{} + } + x.list = x.list[:n] +} + +func (x *dynamicList) NewElement() pref.Value { + return newListEntry(x.desc) +} + +func (x *dynamicList) IsValid() bool { + return true +} + +type dynamicMap struct { + desc pref.FieldDescriptor + mapv map[interface{}]pref.Value +} + +func (x *dynamicMap) Get(k pref.MapKey) pref.Value { return x.mapv[k.Interface()] } +func (x *dynamicMap) Set(k pref.MapKey, v pref.Value) { + typecheckSingular(x.desc.MapKey(), k.Value()) + typecheckSingular(x.desc.MapValue(), v) + x.mapv[k.Interface()] = v +} +func (x *dynamicMap) Has(k pref.MapKey) bool { return x.Get(k).IsValid() } +func (x *dynamicMap) Clear(k pref.MapKey) { delete(x.mapv, k.Interface()) } +func (x *dynamicMap) Mutable(k pref.MapKey) pref.Value { + if x.desc.MapValue().Message() == nil { + panic(errors.New("%v: invalid Mutable on map with non-message value type", x.desc.FullName())) + } + v := x.Get(k) + if !v.IsValid() { + v = x.NewValue() + x.Set(k, v) + } + return v +} +func (x *dynamicMap) Len() int { return len(x.mapv) } +func (x *dynamicMap) NewValue() pref.Value { + if md := x.desc.MapValue().Message(); md != nil { + return pref.ValueOfMessage(NewMessage(md).ProtoReflect()) + } + return x.desc.MapValue().Default() +} +func (x *dynamicMap) IsValid() bool { + return x.mapv != nil +} + +func (x *dynamicMap) Range(f func(pref.MapKey, pref.Value) bool) { + for k, v := range x.mapv { + if !f(pref.ValueOf(k).MapKey(), v) { + return + } + } +} + +func isSet(fd pref.FieldDescriptor, v pref.Value) bool { + switch { + case fd.IsMap(): + return v.Map().Len() > 0 + case fd.IsList(): + return v.List().Len() > 0 + case fd.ContainingOneof() != nil: + return true + case fd.Syntax() == pref.Proto3 && !fd.IsExtension(): + switch fd.Kind() { + case pref.BoolKind: + return v.Bool() + case pref.EnumKind: + return v.Enum() != 0 + case pref.Int32Kind, pref.Sint32Kind, pref.Int64Kind, pref.Sint64Kind, pref.Sfixed32Kind, pref.Sfixed64Kind: + return v.Int() != 0 + case pref.Uint32Kind, pref.Uint64Kind, pref.Fixed32Kind, pref.Fixed64Kind: + return v.Uint() != 0 + case pref.FloatKind, pref.DoubleKind: + return v.Float() != 0 || math.Signbit(v.Float()) + case pref.StringKind: + return v.String() != "" + case pref.BytesKind: + return len(v.Bytes()) > 0 + } + } + return true +} + +func typecheck(fd pref.FieldDescriptor, v pref.Value) { + if err := typeIsValid(fd, v); err != nil { + panic(err) + } +} + +func typeIsValid(fd pref.FieldDescriptor, v pref.Value) error { + switch { + case !v.IsValid(): + return errors.New("%v: assigning invalid value", fd.FullName()) + case fd.IsMap(): + if mapv, ok := v.Interface().(*dynamicMap); !ok || mapv.desc != fd || !mapv.IsValid() { + return errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface()) + } + return nil + case fd.IsList(): + switch list := v.Interface().(type) { + case *dynamicList: + if list.desc == fd && list.IsValid() { + return nil + } + case emptyList: + if list.desc == fd && list.IsValid() { + return nil + } + } + return errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface()) + default: + return singularTypeIsValid(fd, v) + } +} + +func typecheckSingular(fd pref.FieldDescriptor, v pref.Value) { + if err := singularTypeIsValid(fd, v); err != nil { + panic(err) + } +} + +func singularTypeIsValid(fd pref.FieldDescriptor, v pref.Value) error { + vi := v.Interface() + var ok bool + switch fd.Kind() { + case pref.BoolKind: + _, ok = vi.(bool) + case pref.EnumKind: + // We could check against the valid set of enum values, but do not. + _, ok = vi.(pref.EnumNumber) + case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind: + _, ok = vi.(int32) + case pref.Uint32Kind, pref.Fixed32Kind: + _, ok = vi.(uint32) + case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind: + _, ok = vi.(int64) + case pref.Uint64Kind, pref.Fixed64Kind: + _, ok = vi.(uint64) + case pref.FloatKind: + _, ok = vi.(float32) + case pref.DoubleKind: + _, ok = vi.(float64) + case pref.StringKind: + _, ok = vi.(string) + case pref.BytesKind: + _, ok = vi.([]byte) + case pref.MessageKind, pref.GroupKind: + var m pref.Message + m, ok = vi.(pref.Message) + if ok && m.Descriptor().FullName() != fd.Message().FullName() { + return errors.New("%v: assigning invalid message type %v", fd.FullName(), m.Descriptor().FullName()) + } + if dm, ok := vi.(*Message); ok && dm.known == nil { + return errors.New("%v: assigning invalid zero-value message", fd.FullName()) + } + } + if !ok { + return errors.New("%v: assigning invalid type %T", fd.FullName(), v.Interface()) + } + return nil +} + +func newListEntry(fd pref.FieldDescriptor) pref.Value { + switch fd.Kind() { + case pref.BoolKind: + return pref.ValueOfBool(false) + case pref.EnumKind: + return pref.ValueOfEnum(fd.Enum().Values().Get(0).Number()) + case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind: + return pref.ValueOfInt32(0) + case pref.Uint32Kind, pref.Fixed32Kind: + return pref.ValueOfUint32(0) + case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind: + return pref.ValueOfInt64(0) + case pref.Uint64Kind, pref.Fixed64Kind: + return pref.ValueOfUint64(0) + case pref.FloatKind: + return pref.ValueOfFloat32(0) + case pref.DoubleKind: + return pref.ValueOfFloat64(0) + case pref.StringKind: + return pref.ValueOfString("") + case pref.BytesKind: + return pref.ValueOfBytes(nil) + case pref.MessageKind, pref.GroupKind: + return pref.ValueOfMessage(NewMessage(fd.Message()).ProtoReflect()) + } + panic(errors.New("%v: unknown kind %v", fd.FullName(), fd.Kind())) +} + +// NewExtensionType creates a new ExtensionType with the provided descriptor. +// +// Dynamic ExtensionTypes with the same descriptor compare as equal. That is, +// if xd1 == xd2, then NewExtensionType(xd1) == NewExtensionType(xd2). +// +// The InterfaceOf and ValueOf methods of the extension type are defined as: +// +// func (xt extensionType) ValueOf(iv interface{}) protoreflect.Value { +// return protoreflect.ValueOf(iv) +// } +// +// func (xt extensionType) InterfaceOf(v protoreflect.Value) interface{} { +// return v.Interface() +// } +// +// The Go type used by the proto.GetExtension and proto.SetExtension functions +// is determined by these methods, and is therefore equivalent to the Go type +// used to represent a protoreflect.Value. See the protoreflect.Value +// documentation for more details. +func NewExtensionType(desc pref.ExtensionDescriptor) pref.ExtensionType { + if xt, ok := desc.(pref.ExtensionTypeDescriptor); ok { + desc = xt.Descriptor() + } + return extensionType{extensionTypeDescriptor{desc}} +} + +func (xt extensionType) New() pref.Value { + switch { + case xt.desc.IsMap(): + return pref.ValueOfMap(&dynamicMap{ + desc: xt.desc, + mapv: make(map[interface{}]pref.Value), + }) + case xt.desc.IsList(): + return pref.ValueOfList(&dynamicList{desc: xt.desc}) + case xt.desc.Message() != nil: + return pref.ValueOfMessage(NewMessage(xt.desc.Message())) + default: + return xt.desc.Default() + } +} + +func (xt extensionType) Zero() pref.Value { + switch { + case xt.desc.IsMap(): + return pref.ValueOfMap(&dynamicMap{desc: xt.desc}) + case xt.desc.Cardinality() == pref.Repeated: + return pref.ValueOfList(emptyList{desc: xt.desc}) + case xt.desc.Message() != nil: + return pref.ValueOfMessage(&Message{typ: messageType{xt.desc.Message()}}) + default: + return xt.desc.Default() + } +} + +func (xt extensionType) TypeDescriptor() pref.ExtensionTypeDescriptor { + return xt.desc +} + +func (xt extensionType) ValueOf(iv interface{}) pref.Value { + v := pref.ValueOf(iv) + typecheck(xt.desc, v) + return v +} + +func (xt extensionType) InterfaceOf(v pref.Value) interface{} { + typecheck(xt.desc, v) + return v.Interface() +} + +func (xt extensionType) IsValidInterface(iv interface{}) bool { + return typeIsValid(xt.desc, pref.ValueOf(iv)) == nil +} + +func (xt extensionType) IsValidValue(v pref.Value) bool { + return typeIsValid(xt.desc, v) == nil +} + +type extensionTypeDescriptor struct { + pref.ExtensionDescriptor +} + +func (xt extensionTypeDescriptor) Type() pref.ExtensionType { + return extensionType{xt} +} + +func (xt extensionTypeDescriptor) Descriptor() pref.ExtensionDescriptor { + return xt.ExtensionDescriptor +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 9caac9002..86cef49a5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -274,11 +274,13 @@ google.golang.org/protobuf/internal/set google.golang.org/protobuf/internal/strs google.golang.org/protobuf/internal/version google.golang.org/protobuf/proto +google.golang.org/protobuf/reflect/protodesc google.golang.org/protobuf/reflect/protoreflect google.golang.org/protobuf/reflect/protoregistry google.golang.org/protobuf/runtime/protoiface google.golang.org/protobuf/runtime/protoimpl google.golang.org/protobuf/types/descriptorpb +google.golang.org/protobuf/types/dynamicpb google.golang.org/protobuf/types/known/anypb google.golang.org/protobuf/types/known/durationpb google.golang.org/protobuf/types/known/emptypb