Repository: tsloughter/grpcbox Branch: main Commit: 5a57125e76ea Files: 78 Total size: 1.1 MB Directory structure: gitextract_caytn9d6/ ├── .github/ │ └── workflows/ │ └── main.yml ├── .gitignore ├── LICENSE ├── README.md ├── benchmark/ │ ├── README.md │ ├── config/ │ │ ├── sys.config │ │ └── test.config │ ├── proto/ │ │ └── benchmark_service.proto │ ├── src/ │ │ ├── benchmark_service_pb.erl │ │ ├── grpc_testing_benchmark_service.erl │ │ ├── grpc_testing_benchmark_service_bhvr.erl │ │ └── grpc_testing_benchmark_service_client.erl │ └── test/ │ └── grpcbox_benchmark_client_SUITE.erl ├── config/ │ └── test.config ├── elvis.config ├── include/ │ └── grpcbox.hrl ├── interop/ │ ├── config/ │ │ └── sys.config │ ├── include/ │ │ └── grpcbox_interop_tests.hrl │ ├── proto/ │ │ ├── empty.proto │ │ ├── messages.proto │ │ └── test.proto │ ├── run_server_tests.sh │ ├── src/ │ │ ├── empty_pb.erl │ │ ├── grpc_testing_reconnect_service_bhvr.erl │ │ ├── grpc_testing_reconnect_service_client.erl │ │ ├── grpc_testing_test_service.erl │ │ ├── grpc_testing_test_service_bhvr.erl │ │ ├── grpc_testing_test_service_client.erl │ │ ├── grpc_testing_unimplemented_service_bhvr.erl │ │ ├── grpc_testing_unimplemented_service_client.erl │ │ ├── messages_pb.erl │ │ └── test_pb.erl │ └── test/ │ └── grpcbox_interop_client_SUITE.erl ├── proto/ │ ├── health.proto │ └── reflection.proto ├── rebar.config ├── src/ │ ├── grpcbox.app.src │ ├── grpcbox.erl │ ├── grpcbox_acceptor.erl │ ├── grpcbox_app.erl │ ├── grpcbox_chain_interceptor.erl │ ├── grpcbox_channel.erl │ ├── grpcbox_channel_sup.erl │ ├── grpcbox_client.erl │ ├── grpcbox_client_stream.erl │ ├── grpcbox_frame.erl │ ├── grpcbox_health_bhvr.erl │ ├── grpcbox_health_client.erl │ ├── grpcbox_health_pb.erl │ ├── grpcbox_health_service.erl │ ├── grpcbox_metadata.erl │ ├── grpcbox_name_resolver.erl │ ├── grpcbox_oc_stats.erl │ ├── grpcbox_oc_stats_handler.erl │ ├── grpcbox_pool.erl │ ├── grpcbox_reflection_bhvr.erl │ ├── grpcbox_reflection_client.erl │ ├── grpcbox_reflection_pb.erl │ ├── grpcbox_reflection_service.erl │ ├── grpcbox_services_simple_sup.erl │ ├── grpcbox_services_sup.erl │ ├── grpcbox_socket.erl │ ├── grpcbox_stream.erl │ ├── grpcbox_subchannel.erl │ ├── grpcbox_sup.erl │ ├── grpcbox_trace.erl │ └── grpcbox_utils.erl └── test/ ├── grpcbox_SUITE.erl ├── grpcbox_SUITE_data/ │ ├── certificates/ │ │ ├── ca.pem │ │ ├── server1.key │ │ └── server1.pem │ ├── route_guide.proto │ └── route_guide_db.json ├── route_guide_pb.erl ├── routeguide_route_guide.erl ├── routeguide_route_guide_bhvr.erl ├── routeguide_route_guide_client.erl └── test_stats_handler.erl ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/main.yml ================================================ name: Common Test on: pull_request: branches: - 'main' push: branches: - 'main' jobs: build: name: Test on OTP ${{ matrix.otp_version }} and ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: otp_version: ['26.0', '25.2.3', '24.1.2', '23.3'] rebar3_version: ['3.20.0'] os: [ubuntu-20.04] env: OTP_VERSION: ${{ matrix.otp_version }} steps: - uses: actions/checkout@v2 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} rebar3-version: ${{ matrix.rebar3_version }} - name: Compile run: rebar3 compile - name: Tests run: rebar3 ct --cover - name: Covertool run: rebar3 covertool generate - uses: codecov/codecov-action@v2 if: ${{ always() }} with: file: _build/test/covertool/grpcbox.covertool.xml env_vars: OTP_VERSION - name: Setup Go 1.21.4 uses: actions/setup-go@v4 with: # Semantic version range syntax or exact version of Go go-version: '1.21.4' - uses: actions/checkout@v4 with: repository: 'grpc/grpc-go' path: 'grpc-go' - name: Install grpc-go interop client run: | cd grpc-go go build -o ./go-grpc-interop-client ./interop/client - name: Run interop tests run: | rebar3 as interop release _build/interop/rel/grpc_interop/bin/grpc_interop daemon PATH=grpc-go/:$PATH interop/run_server_tests.sh dialyzer: name: Dialyze on OTP ${{ matrix.otp_version }} and ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: otp_version: ['26.0'] rebar3_version: ['3.22.1'] os: [ubuntu-20.04] steps: - uses: actions/checkout@v2 - uses: erlef/setup-beam@v1 with: otp-version: ${{ matrix.otp_version }} rebar3-version: ${{ matrix.rebar3_version }} version-type: 'strict' - uses: actions/cache@v2 name: Cache with: path: | _build key: ${{ runner.os }}-build-${{ matrix.otp_version }}-${{ hashFiles('rebar.lock') }}-5 restore-keys: | ${{ runner.os }}-dialyzer-${{ matrix.otp_version }}-5- - name: Compile run: rebar3 compile - name: Dialyzer run: rebar3 as dialyzer dialyzer ================================================ FILE: .gitignore ================================================ .rebar3 _* .eunit *.o *.beam *.plt *.swp *.swo .erlang.cookie ebin log erl_crash.dump .rebar logs _build .idea *.iml rebar3.crashdump ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Copyright 2017, Tristan Sloughter . Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ grpcbox ===== ![Tests](https://github.com/tsloughter/grpcbox/workflows/Common%20Test/badge.svg) [![codecov](https://codecov.io/gh/tsloughter/grpcbox/branch/main/graph/badge.svg)](https://codecov.io/gh/tsloughter/grpcbox) [![Hex.pm](https://img.shields.io/hexpm/v/grpcbox.svg?maxAge=2592000)](https://hex.pm/packages/grpcbox) [![Hex.pm](https://img.shields.io/hexpm/dt/grpcbox.svg?maxAge=2592000)](https://hex.pm/packages/grpcbox) Library for creating [grpc](https://grpc.io) services (client and server) in Erlang, based on the [chatterbox](https://github.com/joedevivo/chatterbox) http2 library. Features --- * Unary, client stream, server stream and bidirectional rpcs * Client load balancing * Interceptors * Health check service * Reflection service * [OpenCensus](https://opencensus.io) interceptors for stats and tracing * [Plugin](https://github.com/tsloughter/grpcbox_plugin) for generating clients and behaviour type specs for service server implementation Implementing a Service Server ---- The quickest way to play around is with the test service and client that is used by `grpcbox`. Simply pull up a shell with, `rebar3 as test shell` and the route guide service will start on port 8080 and you'll have the client, `routeguide_route_guide_client`, in the path. The easiest way to get started on your own project is using the plugin, [grpcbox_plugin](https://github.com/tsloughter/grpcbox_plugin): ```erlang {deps, [grpcbox]}. {grpc, [{protos, "protos"}, {gpb_opts, [{module_name_suffix, "_pb"}]}]}. {plugins, [grpcbox_plugin]}. ``` Currently `grpcbox` and the plugin are a bit picky and the `gpb` options will always include `[use_packages, maps, {i, "."}, {o, "src"}]`. Assuming the `protos` directory of your application has the `route_guide.proto` found in this repo, `protos/route_guide.proto`, the output from running the plugin will be: ```shell $ rebar3 grpc gen ===> Writing src/route_guide_pb.erl ===> Writing src/grpcbox_route_guide_bhvr.erl ``` A behaviour is used because it provides a way to generate the interface and types without being where the actual implementation is also done. This way if a change happens to the proto you can regenerate the interface without any issues with the implementation of the service, simply then update the implementation callbacks to match the changed interface. Runtime configuration for `grpcbox` can be done in `sys.config`, specifying the compiled proto modules to use for finding the services available, which services to actually enable for requests and what module implements them, acceptor pool and http server settings. See `interop/config/sys.config` for a working example. In the interop config the portion for defining services to handle requests for is: ``` erlrang {grpcbox, [{servers, [#{grpc_opts => #{service_protos => [test_pb], services => #{'grpc.testing.TestService' => grpc_testing_test_service}}}]}, ... ``` `test_pb` is the `gpb` generated module that exports `get_service_names/0`. The results of that function are used to construct the metadata needed for handling requests. The `services` map gives the module to call for handling methods of a service. If a service is not defined in that map it will result in the grpc error code 12, `Unimplemented`. The services will be started when the application starts assuming the services are all configured in the `sys.config` and it is loaded. To manually start a service use either `grpcbox:start_server/1` which will start a `grpcbox_service_sup` supervisor under the `grpcbox_services_simple_sup` simple one for one supervisor, or get a child spec `grpcbox:server_child_spec(ServerOpts, GrpcOpts, ListenOpts, PoolOpts, TransportOpts)` to include the service supervisor in your own supervision tree. #### Unary RPC Unary RPCs receive a single request and return a single response. The RPC `GetFeature` takes a single `Point` and returns the `Feature` at that point: ```protobuf rpc GetFeature(Point) returns (Feature) {} ``` The callback generated by the `grpcbox_plugin` will look like: ```erlang -callback get_feature(ctx:ctx(), route_guide_pb:point()) -> {ok, route_guide_pb:feature(), ctx:ctx(} | grpcbox_stream:grpc_error_response(). ``` And the implementation is as simple as an Erlang function that takes the arguments `Ctx`, the context of this current request, and a `Point` map, returning a `Feature` map: ```erlang get_feature(Ctx, Point) -> Feature = #{name => find_point(Point, data()), location => Point}, {ok, Feature, Ctx}. ``` #### Streaming Output Instead of returning a single feature the server can stream a response of multiple features by defining the RPC to have a `stream Feature` return: ```protobuf rpc ListFeatures(Rectangle) returns (stream Feature) {} ``` In this case the callback still receives a map argument but also a `grpcbox_stream` argument: ```erlang -callback list_features(route_guide_pb:rectangle(), grpcbox_stream:t()) -> ok | {error, term()}. ``` The `GrpcStream` variable is passed to `grpcbox_stream:send/2` for returning an individual feature over the stream to the client. The stream is ended by the server when the function completes. ```erlang list_features(_Message, GrpcStream) -> grpcbox_stream:send(#{name => <<"Tour Eiffel">>, location => #{latitude => 3, longitude => 5}}, GrpcStream), grpcbox_stream:send(#{name => <<"Louvre">>, location => #{latitude => 4, longitude => 5}}, GrpcStream), ok. ``` #### Streaming Input The client can also stream a sequence of messages: ```protobuf rpc RecordRoute(stream Point) returns (RouteSummary) {} ``` In this case the callback receives a `reference()` instead of a direct value from the client: ```erlang -callback record_route(reference(), grpcbox_stream:t()) -> {ok, route_guide_pb:route_summary()} | {error, term()}. ``` The process the callback is running in will receive the individual messages on the stream as tuples `{reference(), route_guide_pb:point()}`. The end of the stream is sent as the message `{reference(), eos}` at which point the function can return the response: ```erlang record_route(Ref, GrpcStream) -> record_route(Ref, #{t_start => erlang:system_time(1), acc => []}, GrpcStream). record_route(Ref, Data=#{t_start := T0, acc := Points}, GrpcStream) -> receive {Ref, eos} -> {ok, #{elapsed_time => erlang:system_time(1) - T0, point_count => length(Points), feature_count => count_features(Points), distance => distance(Points)}, GrpcStream}; {Ref, Point} -> record_route(Ref, Data#{acc => [Point | Points]}, GrpcStream) end. ``` #### Streaming In and Out A bidrectional streaming RPC is defined when both input and output are streams: ```protobuf rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} ``` ```erlang -callback route_chat(reference(), grpcbox_stream:t()) -> ok | {error, term()}. ``` The sequence of input messages will again be sent to the callback's process as Erlang messages and any output messages are sent to the client with `grpcbox_stream`: ```erlang route_chat(Ref, GrpcStream) -> route_chat(Ref, [], GrpcStream). route_chat(Ref, Data, GrpcStream) -> receive {Ref, eos} -> ok; {Ref, #{location := Location} = P} -> Messages = proplists:get_all_values(Location, Data), [grpcbox_stream:send(Message, GrpcStream) || Message <- Messages], route_chat(Ref, [{Location, P} | Data], GrpcStream) end. ``` #### Interceptors ##### Unary Interceptor A unary interceptor can be any function that accepts a context, decoded request body, server info map and the method function: ```erlang some_unary_interceptor(Ctx, Request, ServerInfo, Fun) -> %% do some interception stuff Fun(Ctx, Request). ``` The interceptor is configured in the `grpc_opts` set in the environment or passed to the supervisor `start_child` function. An example from the test suite sets `grpc_opts` in the application environment: ```erlang #{service_protos => [route_guide_pb], unary_interceptor => fun(Ctx, Req, _, Method) -> Method(Ctx, #{latitude => 30, longitude => 90}) end} ``` ##### Streaming Interceptor ##### Middleware There is a provided interceptor `grpcbox_chain_interceptor` which accepts a list of interceptors to apply in order, with the final interceptor calling the method handler. An example from the test suite adds a trailer in each interceptor to show the chain working: ```erlang #{service_protos => [route_guide_pb], unary_interceptor => grpcbox_chain_interceptor:unary([fun ?MODULE:one/4, fun ?MODULE:two/4, fun ?MODULE:three/4])} ``` #### Tracing The provided interceptor `grpcbox_trace` supports the [OpenCensus](http://opencensus.io/) wire protocol using [opencensus-erlang](https://github.com/census-instrumentation/opencensus-erlang). It will use the `trace_id`, `span_id` and any options or tags from the trace context. Configure as an interceptor: ```erlang #{service_protos => [route_guide_pb], unary_interceptor => {grpcbox_trace, unary}} ``` Or as a middleware in the chain interceptor: ```erlang #{service_protos => [route_guide_pb], unary_interceptor => grpcbox_chain_interceptor:unary([..., fun grpcbox_trace:unary/4, ...])} ``` See [opencensus-erlang](https://github.com/census-instrumentation/opencensus-erlang) for details on configuring reporters. #### Statistics Statistics are collected by implementing a stats handler module. A handler for OpenCensus stats (be sure to include [OpenCensus](https://hex.pm/packages/opencensus) as a dependency and make sure it starts on boot) is provided and can be enabled for the server with a config option: ``` erlang {grpcbox, [{servers, [#{grpc_opts => #{stats_handler => grpcbox_oc_stats_handler ...}}]}]} ``` For the client the stats handler is a per-channel configuration, see the Defining Channels section below. You can verify it is working by enabling the stdout exporter: ``` erlang {opencensus, [{stat, [{exporters, [{oc_stat_exporter_stdout, []}]}]}]} ``` For actual use, an [exporter for Prometheus](https://github.com/opencensus-beam/prometheus) is available. Details on all the metrics that are collected can be found in the [OpenCensus gRPC Stats specification](https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/gRPC.md). #### Metadata Metadata is sent in headers and trailers. Using a Service Client ---- For each service in the protos passed to `rebar3 gprc gen` it will generate a `_client` module containing a function for each method in the service. #### Defining Channels Channels maintain connections to grpc servers and offer client side load balancing between servers with various methods, round robin, random, hash. If no channel is specified in the options to a rpc call the `default_channel` is used. Setting the default to connect to localhost on port 8080 in your `sys.config` would look like: ``` {client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}} ``` Unix sockets (UDS) may also be used with the same notation that is defined in `gen_tcp`. Considerations: * for UDS, only the `http` scheme is permitted * the port must strictly be `0` * only available on POSIX operating systems * abstract UDS are only available on Linux, and such sockets' names must start with a zero byte ``` {client, #{channels => [{default_channel, [{http, {local, "/path/to/unix/socket_name"}, 0, []}], #{}}]}} %% or to use an abstract Unix socket: %% {client, #{channels => [{default_channel, [{http, {local, [0 | "socket_name"]}, 0, []}], #{}}]}} ``` The empty map at the end can contain configuration for the load balancing algorithm, interceptors, statistics handling and compression: ``` #{balancer => round_robin | random | hash | direct | claim, encoding => identity | gzip | deflate | snappy | atom(), stats_handler => grpcbox_oc_stats_handler, unary_interceptor => term(), stream_interceptor => term()} ``` The default balancer is round robin and encoding is identity (no compression). Encoding can also be passed in the options map to individual requests. #### Calling Unary Client RPC The `RouteGuide` service has a single unary method, `GetFeature`, in the client we have a function `get_feature/2`: ```erlang Point = #{latitude => 409146138, longitude => -746188906}, {ok, Feature, HeadersAndTrailers} = routeguide_route_guide_client:get_feature(Point). ``` #### Client Streaming RPC ```erlang {ok, S} = routeguide_route_guide_client:record_route(), ok = grpcbox_client:send(S, #{latitude => 409146138, longitude => -746188906}), ok = grpcbox_client:send(S, #{latitude => 234818903, longitude => -823423910}), ok = grpcbox_client:close_send(S), {ok, #{point_count := 2} = grpcbox_client:recv_data(S)). ``` #### Client with Server Streaming RPC ```erlang Rectangle = #{hi => #{latitude => 1, longitude => 2}, lo => #{latitude => 3, longitude => 5}}, {ok, S} = routeguide_route_guide_client:list_features(Rectangle), {ok, #{<<":status">> := <<"200">>}} = grpcbox_client:recv_headers(S), {ok, #{name := _} = grpcbox_client:recv_data(S), {ok, #{name := _}} = grpcbox_client:recv_data(S), {ok, _} = grpcbox_client:recv_trailers(S). ``` #### Bidirectional RPC ```erlrang {ok, S} = routeguide_route_guide_client:route_chat(), ok = grpcbox_client:send(S, #{location => #{latitude => 1, longitude => 1}, message => <<"hello there">>}), ok = grpcbox_client:send(S, #{location => #{latitude => 1, longitude => 1}, message => <<"hello there">>}), {ok, #{message := <<"hello there">>}} = grpcbox_client:recv_data(S)), ok = grpcbox_client:send(S, #{location => #{latitude => 1, longitude => 1}, message => <<"hello there">>}), {ok, #{message := <<"hello there">>}}, grpcbox_client:close_and_recv(S)). ``` #### Context Client calls optionally accept a [context](https://hex.pm/packages/ctx) as the first argument. Contexts are used to set and propagate deadlines and [OpenCensus](https://hex.pm/packages/opencensus) tags. ```erlang Ctx = ctx:with_deadline_after(300, seconds), Point = #{latitude => 409146138, longitude => -746188906}, {ok, Feature, HeadersAndTrailers} = routeguide_route_guide_client:get_feature(Ctx, Point). ``` CT Tests --- To run the Common Test suite: ``` $ rebar3 ct ``` Interop Tests --- The `interop` rebar3 profile builds with an implementation of the `test.proto` for grpc interop testing: For testing grpcbox's server: ``` $ rebar3 as interop shell ``` With the shell running the tests can then be run from a script: ``` $ interop/run_server_tests.sh ``` The script by default uses the Go test client that can be installed with the following: ``` $ go get -u github.com/grpc/grpc-go/interop $ go build -o $GOPATH/bin/go-grpc-interop-client github.com/grpc/grpc-go/interop/client ``` For testing the grpcbox client you can use the Go test server. But first, add `_ "google.golang.org/grpc/encoding/gzip"` to `server.go` imports or else the gzip tests will fail. Then simply build and run it: ``` $ go build -o $GOPATH/bin/go-grpc-interop-server github.com/grpc/grpc-go/interop/server $ $GOPATH/bin/go-grpc-interop-server -port 8080 ``` And run the interop client test suite: ``` rebar3 as interop ct ``` ================================================ FILE: benchmark/README.md ================================================ Benchmark ========= Utilities for benchmarking grpcbox. The used protocol is compatible with the one defined in [grpc](https://github.com/grpc/grpc/blob/master/src/proto/grpc/testing/benchmark_service.proto) and for example the Go benchmark client and server can be used against grpcbox. Grpcbox benchmark server ------------------------ To run the grpcbox benchmark server: ``` $ rebar3 as benchmark shell ``` Server options can be changed in `benchmark/config/sys.config` Grpcbox benchmark client ------------------------ The benchmark client is implemented as a Common Test. First set test parameters in `benchmark/config/test.config`. The available parameters are described in the file. Also the chatterbox client options can be set. After setting test parameters and starting a server to test against, run the grpcbox benchmark client: ``` $ rebar3 as benchmark ct --verbose ``` The --verbose option needs to be set for the measurements to be printed out. Go benchmark client and server ------------------------------ Grpcbox benchmark is compatible with the Go benchmark client and server. To build the Go client and server: ``` $ go build -o $GOPATH/bin/go-grpc-benchmark-client /benchmark/client $ go build -o $GOPATH/bin/go-grpc-benchmark-server /benchmark/server ``` Example of running the Go benchmark server: ``` $ go-grpc-benchmark-server -port 8080 -test_name mytest ``` Example of running the Go benchmark client: ``` $ go-grpc-benchmark-client -port 8080 -test_name mytest -d 10 -w 1 -r 100 -c 1 -rpc_type unary -req 1 -resp 1 ``` ================================================ FILE: benchmark/config/sys.config ================================================ [ {grpcbox, [%% {client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}}, {servers, [#{grpc_opts => #{service_protos => [benchmark_service_pb], services => #{'grpc.testing.BenchmarkService' => grpc_testing_benchmark_service}, client_cert_dir => "test/grpcbox_SUITE_data/certificates/"}, transport_opts => #{ssl => false, keyfile => "test/grpcbox_SUITE_data/certificates/server1.key", certfile => "test/grpcbox_SUITE_data/certificates/server1.pem", cacertfile => "test/grpcbox_SUITE_data/certificates/ca.pem"}, listen_opts => #{port => 8080, ip => {0,0,0,0}}, pool_opts => #{size => 10}, server_opts => #{server_header_table_size => 4096, server_enable_push => 1, server_max_concurrent_streams => unlimited, server_initial_window_size => 100000000, server_max_frame_size => 16384, server_max_header_list_size => unlimited}}]}]}, {opencensus, [{sampler, {oc_sampler_always, []}}, {reporters, [{oc_reporter_stdout, []}]}, {stat, [{exporters, [{oc_stat_exporter_stdout, []}]}]}]}, {kernel, [ {logger, [ {handler, default, logger_std_h, #{filters => [{progress, {fun logger_filters:progress/2, stop}}], formatter => {logger_formatter, #{single_line => true}}}}]}]} ]. ================================================ FILE: benchmark/config/test.config ================================================ %% Test options {server_addr, "localhost"}. %% Server address to connect to {server_port, 8080}. %% Server port to connect to {num_rpc, 100}. %% The number of concurrent RPCs on each connection {num_conn, 1}. %% The number of parallel connections {warmup_dur, 1}. %% Warm-up duration in seconds {duration, 10}. %% Benchmark duration in seconds {rq_size, 1}. %% Request message size in bytes {rsp_size, 1}. %% Response message size in bytes {rpc_type, unary}. %% RPC type, unary or streaming %% Client options {chatterbox, [ {client_header_table_size,4096}, {client_enable_push,1}, {client_max_concurrent_streams,unlimited}, {client_initial_window_size,100000000}, {client_max_frame_size,16384}, {client_max_header_list_size,unlimited}, {client_flow_control,auto} ] }. ================================================ FILE: benchmark/proto/benchmark_service.proto ================================================ // Copyright 2015 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // An integration test service that covers all the method signature permutations // of unary/streaming requests/responses. syntax = "proto3"; import "interop/proto/messages.proto"; package grpc.testing; service BenchmarkService { // One request followed by one response. // The server returns the client payload as-is. rpc UnaryCall(SimpleRequest) returns (SimpleResponse); // Repeated sequence of one request followed by one response. // Should be called streaming ping-pong // The server returns the client payload as-is on each response rpc StreamingCall(stream SimpleRequest) returns (stream SimpleResponse); // Single-sided unbounded streaming from client to server // The server returns the client payload as-is once the client does WritesDone rpc StreamingFromClient(stream SimpleRequest) returns (SimpleResponse); // Single-sided unbounded streaming from server to client // The server repeatedly returns the client payload as-is rpc StreamingFromServer(SimpleRequest) returns (stream SimpleResponse); // Two-sided unbounded streaming between server to client // Both sides send the content of their own choice to the other rpc StreamingBothWays(stream SimpleRequest) returns (stream SimpleResponse); } ================================================ FILE: benchmark/src/benchmark_service_pb.erl ================================================ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit %% Generated by gpb_compile version 4.7.3 -module(benchmark_service_pb). -export([encode_msg/2, encode_msg/3]). -export([decode_msg/2, decode_msg/3]). -export([merge_msgs/3, merge_msgs/4]). -export([verify_msg/2, verify_msg/3]). -export([get_msg_defs/0]). -export([get_msg_names/0]). -export([get_group_names/0]). -export([get_msg_or_group_names/0]). -export([get_enum_names/0]). -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). -export(['enum_symbol_by_value_grpc.testing.PayloadType'/1, 'enum_value_by_symbol_grpc.testing.PayloadType'/1]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). -export([find_rpc_def/2, fetch_rpc_def/2]). -export([fqbin_to_service_name/1]). -export([service_name_to_fqbin/1]). -export([fqbins_to_service_and_rpc_name/2]). -export([service_and_rpc_name_to_fqbins/2]). -export([fqbin_to_msg_name/1]). -export([msg_name_to_fqbin/1]). -export([fqbin_to_enum_name/1]). -export([enum_name_to_fqbin/1]). -export([get_package_name/0]). -export([uses_packages/0]). -export([source_basename/0]). -export([get_all_source_basenames/0]). -export([get_all_proto_names/0]). -export([get_msg_containment/1]). -export([get_pkg_containment/1]). -export([get_service_containment/1]). -export([get_rpc_containment/1]). -export([get_enum_containment/1]). -export([get_proto_by_msg_name_as_fqbin/1]). -export([get_proto_by_service_name_as_fqbin/1]). -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([descriptor/0, descriptor/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). %% enumerated types -type 'grpc.testing.PayloadType'() :: 'COMPRESSABLE'. -export_type(['grpc.testing.PayloadType'/0]). %% message types -type bool_value() :: #{value => boolean() | 0 | 1 % = 1 }. -type payload() :: #{type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType body => iodata() % = 2 }. -type echo_status() :: #{code => integer(), % = 1, 32 bits message => iodata() % = 2 }. -type simple_request() :: #{response_type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType response_size => integer(), % = 2, 32 bits payload => payload(), % = 3 fill_username => boolean() | 0 | 1, % = 4 fill_oauth_scope => boolean() | 0 | 1, % = 5 response_compressed => bool_value(), % = 6 response_status => echo_status(), % = 7 expect_compressed => bool_value() % = 8 }. -type simple_response() :: #{payload => payload(), % = 1 username => iodata(), % = 2 oauth_scope => iodata() % = 3 }. -type streaming_input_call_request() :: #{payload => payload(), % = 1 expect_compressed => bool_value() % = 2 }. -type streaming_input_call_response() :: #{aggregated_payload_size => integer() % = 1, 32 bits }. -type response_parameters() :: #{size => integer(), % = 1, 32 bits interval_us => integer(), % = 2, 32 bits compressed => bool_value() % = 3 }. -type streaming_output_call_request() :: #{response_type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType response_parameters => [response_parameters()], % = 2 payload => payload(), % = 3 response_status => echo_status() % = 7 }. -type streaming_output_call_response() :: #{payload => payload() % = 1 }. -type reconnect_params() :: #{max_reconnect_backoff_ms => integer() % = 1, 32 bits }. -type reconnect_info() :: #{passed => boolean() | 0 | 1, % = 1 backoff_ms => [integer()] % = 2, 32 bits }. -export_type(['bool_value'/0, 'payload'/0, 'echo_status'/0, 'simple_request'/0, 'simple_response'/0, 'streaming_input_call_request'/0, 'streaming_input_call_response'/0, 'response_parameters'/0, 'streaming_output_call_request'/0, 'streaming_output_call_response'/0, 'reconnect_params'/0, 'reconnect_info'/0]). -spec encode_msg(bool_value() | payload() | echo_status() | simple_request() | simple_response() | streaming_input_call_request() | streaming_input_call_response() | response_parameters() | streaming_output_call_request() | streaming_output_call_response() | reconnect_params() | reconnect_info(), atom()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). -spec encode_msg(bool_value() | payload() | echo_status() | simple_request() | simple_response() | streaming_input_call_request() | streaming_input_call_response() | response_parameters() | streaming_output_call_request() | streaming_output_call_response() | reconnect_params() | reconnect_info(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> case proplists:get_bool(verify, Opts) of true -> verify_msg(Msg, MsgName, Opts); false -> ok end, TrUserData = proplists:get_value(user_data, Opts), case MsgName of bool_value -> encode_msg_bool_value(id(Msg, TrUserData), TrUserData); payload -> encode_msg_payload(id(Msg, TrUserData), TrUserData); echo_status -> encode_msg_echo_status(id(Msg, TrUserData), TrUserData); simple_request -> encode_msg_simple_request(id(Msg, TrUserData), TrUserData); simple_response -> encode_msg_simple_response(id(Msg, TrUserData), TrUserData); streaming_input_call_request -> encode_msg_streaming_input_call_request(id(Msg, TrUserData), TrUserData); streaming_input_call_response -> encode_msg_streaming_input_call_response(id(Msg, TrUserData), TrUserData); response_parameters -> encode_msg_response_parameters(id(Msg, TrUserData), TrUserData); streaming_output_call_request -> encode_msg_streaming_output_call_request(id(Msg, TrUserData), TrUserData); streaming_output_call_response -> encode_msg_streaming_output_call_response(id(Msg, TrUserData), TrUserData); reconnect_params -> encode_msg_reconnect_params(id(Msg, TrUserData), TrUserData); reconnect_info -> encode_msg_reconnect_info(id(Msg, TrUserData), TrUserData) end. encode_msg_bool_value(Msg, TrUserData) -> encode_msg_bool_value(Msg, <<>>, TrUserData). encode_msg_bool_value(#{} = M, Bin, TrUserData) -> case M of #{value := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= false -> Bin; true -> e_type_bool(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_payload(Msg, TrUserData) -> encode_msg_payload(Msg, <<>>, TrUserData). encode_msg_payload(#{} = M, Bin, TrUserData) -> B1 = case M of #{type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{body := F2} -> begin TrF2 = id(F2, TrUserData), case iolist_size(TrF2) of 0 -> B1; _ -> e_type_bytes(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_echo_status(Msg, TrUserData) -> encode_msg_echo_status(Msg, <<>>, TrUserData). encode_msg_echo_status(#{} = M, Bin, TrUserData) -> B1 = case M of #{code := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{message := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_simple_request(Msg, TrUserData) -> encode_msg_simple_request(Msg, <<>>, TrUserData). encode_msg_simple_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{response_type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{response_size := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end, B3 = case M of #{payload := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_simple_request_payload(TrF3, <>, TrUserData) end end; _ -> B2 end, B4 = case M of #{fill_username := F4} -> begin TrF4 = id(F4, TrUserData), if TrF4 =:= false -> B3; true -> e_type_bool(TrF4, <>, TrUserData) end end; _ -> B3 end, B5 = case M of #{fill_oauth_scope := F5} -> begin TrF5 = id(F5, TrUserData), if TrF5 =:= false -> B4; true -> e_type_bool(TrF5, <>, TrUserData) end end; _ -> B4 end, B6 = case M of #{response_compressed := F6} -> begin TrF6 = id(F6, TrUserData), if TrF6 =:= undefined -> B5; true -> e_mfield_simple_request_response_compressed(TrF6, <>, TrUserData) end end; _ -> B5 end, B7 = case M of #{response_status := F7} -> begin TrF7 = id(F7, TrUserData), if TrF7 =:= undefined -> B6; true -> e_mfield_simple_request_response_status(TrF7, <>, TrUserData) end end; _ -> B6 end, case M of #{expect_compressed := F8} -> begin TrF8 = id(F8, TrUserData), if TrF8 =:= undefined -> B7; true -> e_mfield_simple_request_expect_compressed(TrF8, <>, TrUserData) end end; _ -> B7 end. encode_msg_simple_response(Msg, TrUserData) -> encode_msg_simple_response(Msg, <<>>, TrUserData). encode_msg_simple_response(#{} = M, Bin, TrUserData) -> B1 = case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_simple_response_payload(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{username := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end, case M of #{oauth_scope := F3} -> begin TrF3 = id(F3, TrUserData), case is_empty_string(TrF3) of true -> B2; false -> e_type_string(TrF3, <>, TrUserData) end end; _ -> B2 end. encode_msg_streaming_input_call_request(Msg, TrUserData) -> encode_msg_streaming_input_call_request(Msg, <<>>, TrUserData). encode_msg_streaming_input_call_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_streaming_input_call_request_payload(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{expect_compressed := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= undefined -> B1; true -> e_mfield_streaming_input_call_request_expect_compressed(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_streaming_input_call_response(Msg, TrUserData) -> encode_msg_streaming_input_call_response(Msg, <<>>, TrUserData). encode_msg_streaming_input_call_response(#{} = M, Bin, TrUserData) -> case M of #{aggregated_payload_size := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_response_parameters(Msg, TrUserData) -> encode_msg_response_parameters(Msg, <<>>, TrUserData). encode_msg_response_parameters(#{} = M, Bin, TrUserData) -> B1 = case M of #{size := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{interval_us := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end, case M of #{compressed := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_response_parameters_compressed(TrF3, <>, TrUserData) end end; _ -> B2 end. encode_msg_streaming_output_call_request(Msg, TrUserData) -> encode_msg_streaming_output_call_request(Msg, <<>>, TrUserData). encode_msg_streaming_output_call_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{response_type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{response_parameters := F2} -> TrF2 = id(F2, TrUserData), if TrF2 == [] -> B1; true -> e_field_streaming_output_call_request_response_parameters(TrF2, B1, TrUserData) end; _ -> B1 end, B3 = case M of #{payload := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_streaming_output_call_request_payload(TrF3, <>, TrUserData) end end; _ -> B2 end, case M of #{response_status := F4} -> begin TrF4 = id(F4, TrUserData), if TrF4 =:= undefined -> B3; true -> e_mfield_streaming_output_call_request_response_status(TrF4, <>, TrUserData) end end; _ -> B3 end. encode_msg_streaming_output_call_response(Msg, TrUserData) -> encode_msg_streaming_output_call_response(Msg, <<>>, TrUserData). encode_msg_streaming_output_call_response(#{} = M, Bin, TrUserData) -> case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_streaming_output_call_response_payload(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_reconnect_params(Msg, TrUserData) -> encode_msg_reconnect_params(Msg, <<>>, TrUserData). encode_msg_reconnect_params(#{} = M, Bin, TrUserData) -> case M of #{max_reconnect_backoff_ms := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_reconnect_info(Msg, TrUserData) -> encode_msg_reconnect_info(Msg, <<>>, TrUserData). encode_msg_reconnect_info(#{} = M, Bin, TrUserData) -> B1 = case M of #{passed := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= false -> Bin; true -> e_type_bool(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{backoff_ms := F2} -> TrF2 = id(F2, TrUserData), if TrF2 == [] -> B1; true -> e_field_reconnect_info_backoff_ms(TrF2, B1, TrUserData) end; _ -> B1 end. e_mfield_simple_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_response_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_response_status(Msg, Bin, TrUserData) -> SubBin = encode_msg_echo_status(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_expect_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_response_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_input_call_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_input_call_request_expect_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_response_parameters_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_request_response_parameters(Msg, Bin, TrUserData) -> SubBin = encode_msg_response_parameters(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_streaming_output_call_request_response_parameters([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, Bin3 = e_mfield_streaming_output_call_request_response_parameters(id(Elem, TrUserData), Bin2, TrUserData), e_field_streaming_output_call_request_response_parameters(Rest, Bin3, TrUserData); e_field_streaming_output_call_request_response_parameters([], Bin, _TrUserData) -> Bin. e_mfield_streaming_output_call_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_request_response_status(Msg, Bin, TrUserData) -> SubBin = encode_msg_echo_status(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_response_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_reconnect_info_backoff_ms(Elems, Bin, TrUserData) when Elems =/= [] -> SubBin = e_pfield_reconnect_info_backoff_ms(Elems, <<>>, TrUserData), Bin2 = <>, Bin3 = e_varint(byte_size(SubBin), Bin2), <>; e_field_reconnect_info_backoff_ms([], Bin, _TrUserData) -> Bin. e_pfield_reconnect_info_backoff_ms([Value | Rest], Bin, TrUserData) -> Bin2 = e_type_int32(id(Value, TrUserData), Bin, TrUserData), e_pfield_reconnect_info_backoff_ms(Rest, Bin2, TrUserData); e_pfield_reconnect_info_backoff_ms([], Bin, _TrUserData) -> Bin. 'e_enum_grpc.testing.PayloadType'('COMPRESSABLE', Bin, _TrUserData) -> <>; 'e_enum_grpc.testing.PayloadType'(V, Bin, _TrUserData) -> e_varint(V, Bin). -compile({nowarn_unused_function,e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). e_type_bool(true, Bin, _TrUserData) -> <>; e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_string/3}). e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -compile({nowarn_unused_function,e_type_bytes/3}). e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). e_type_float(V, Bin, _) when is_number(V) -> <>; e_type_float(infinity, Bin, _) -> <>; e_type_float('-infinity', Bin, _) -> <>; e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). e_type_double(V, Bin, _) when is_number(V) -> <>; e_type_double(infinity, Bin, _) -> <>; e_type_double('-infinity', Bin, _) -> <>; e_type_double(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). -compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, e_varint(N bsr 7, Bin2). is_empty_string("") -> true; is_empty_string(<<>>) -> true; is_empty_string(L) when is_list(L) -> not string_has_chars(L); is_empty_string(B) when is_binary(B) -> false. string_has_chars([C | _]) when is_integer(C) -> true; string_has_chars([H | T]) -> case string_has_chars(H) of true -> true; false -> string_has_chars(T) end; string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; string_has_chars(C) when is_integer(C) -> true; string_has_chars(<<>>) -> false; string_has_chars([]) -> false. decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), decode_msg_1_catch(Bin, MsgName, TrUserData). -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason -> StackTrace = erlang:get_stacktrace(), error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. decode_msg_2_doit(bool_value, Bin, TrUserData) -> id(decode_msg_bool_value(Bin, TrUserData), TrUserData); decode_msg_2_doit(payload, Bin, TrUserData) -> id(decode_msg_payload(Bin, TrUserData), TrUserData); decode_msg_2_doit(echo_status, Bin, TrUserData) -> id(decode_msg_echo_status(Bin, TrUserData), TrUserData); decode_msg_2_doit(simple_request, Bin, TrUserData) -> id(decode_msg_simple_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(simple_response, Bin, TrUserData) -> id(decode_msg_simple_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_input_call_request, Bin, TrUserData) -> id(decode_msg_streaming_input_call_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_input_call_response, Bin, TrUserData) -> id(decode_msg_streaming_input_call_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(response_parameters, Bin, TrUserData) -> id(decode_msg_response_parameters(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_output_call_request, Bin, TrUserData) -> id(decode_msg_streaming_output_call_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_output_call_response, Bin, TrUserData) -> id(decode_msg_streaming_output_call_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(reconnect_params, Bin, TrUserData) -> id(decode_msg_reconnect_params(Bin, TrUserData), TrUserData); decode_msg_2_doit(reconnect_info, Bin, TrUserData) -> id(decode_msg_reconnect_info(Bin, TrUserData), TrUserData). decode_msg_bool_value(Bin, TrUserData) -> dfp_read_field_def_bool_value(Bin, 0, 0, id(false, TrUserData), TrUserData). dfp_read_field_def_bool_value(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_bool_value_value(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_bool_value(<<>>, 0, 0, F@_1, _) -> #{value => F@_1}; dfp_read_field_def_bool_value(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_bool_value(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_bool_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_bool_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_bool_value(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_bool_value_value(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_bool_value(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_bool_value(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_bool_value(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_bool_value(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_bool_value(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_bool_value(<<>>, 0, 0, F@_1, _) -> #{value => F@_1}. d_field_bool_value_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_bool_value_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_bool_value_value(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_bool_value(RestF, 0, 0, NewFValue, TrUserData). skip_varint_bool_value(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_bool_value(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_bool_value(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_bool_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_bool_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_bool_value(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_bool_value(Rest2, 0, 0, F@_1, TrUserData). skip_group_bool_value(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_bool_value(Rest, 0, Z2, F@_1, TrUserData). skip_32_bool_value(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). skip_64_bool_value(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_payload(Bin, TrUserData) -> dfp_read_field_def_payload(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_payload(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_payload_type(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_payload(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_payload_body(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_payload(<<>>, 0, 0, F@_1, F@_2, _) -> #{type => F@_1, body => F@_2}; dfp_read_field_def_payload(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_payload(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_payload_type(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_payload_body(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_payload(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_payload(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_payload(<<>>, 0, 0, F@_1, F@_2, _) -> #{type => F@_1, body => F@_2}. d_field_payload_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_payload_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_payload_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_payload(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_payload_body(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_payload_body(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_payload_body(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_payload(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_payload(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_payload(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_payload(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_payload(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_payload(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_payload(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_payload(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_echo_status(Bin, TrUserData) -> dfp_read_field_def_echo_status(Bin, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_echo_status(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_echo_status_code(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_echo_status(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_echo_status_message(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_echo_status(<<>>, 0, 0, F@_1, F@_2, _) -> #{code => F@_1, message => F@_2}; dfp_read_field_def_echo_status(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_echo_status(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_echo_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_echo_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_echo_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_echo_status_code(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_echo_status_message(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_echo_status(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_echo_status(<<>>, 0, 0, F@_1, F@_2, _) -> #{code => F@_1, message => F@_2}. d_field_echo_status_code(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_echo_status_code(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_echo_status_code(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_echo_status(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_echo_status_message(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_echo_status_message(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_echo_status_message(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_echo_status(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_echo_status(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_echo_status(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_echo_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_echo_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_echo_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_echo_status(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_echo_status(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_echo_status(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_echo_status(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_echo_status(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_simple_request(Bin, TrUserData) -> dfp_read_field_def_simple_request(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id(0, TrUserData), id('$undef', TrUserData), id(false, TrUserData), id(false, TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_simple_request(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_type(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_size(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_fill_username(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<40, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_fill_oauth_scope(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<50, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_status(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<66, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_expect_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> S1 = #{response_type => F@_1, response_size => F@_2, fill_username => F@_4, fill_oauth_scope => F@_5}, S2 = if F@_3 == '$undef' -> S1; true -> S1#{payload => F@_3} end, S3 = if F@_6 == '$undef' -> S2; true -> S2#{response_compressed => F@_6} end, S4 = if F@_7 == '$undef' -> S3; true -> S3#{response_status => F@_7} end, if F@_8 == '$undef' -> S4; true -> S4#{expect_compressed => F@_8} end; dfp_read_field_def_simple_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dg_read_field_def_simple_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). dg_read_field_def_simple_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 32 - 7 -> dg_read_field_def_simple_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dg_read_field_def_simple_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_simple_request_response_type(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 16 -> d_field_simple_request_response_size(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 26 -> d_field_simple_request_payload(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 32 -> d_field_simple_request_fill_username(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 40 -> d_field_simple_request_fill_oauth_scope(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 50 -> d_field_simple_request_response_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 58 -> d_field_simple_request_response_status(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 66 -> d_field_simple_request_expect_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 1 -> skip_64_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 2 -> skip_length_delimited_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 3 -> skip_group_simple_request(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 5 -> skip_32_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) end end; dg_read_field_def_simple_request(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> S1 = #{response_type => F@_1, response_size => F@_2, fill_username => F@_4, fill_oauth_scope => F@_5}, S2 = if F@_3 == '$undef' -> S1; true -> S1#{payload => F@_3} end, S3 = if F@_6 == '$undef' -> S2; true -> S2#{response_compressed => F@_6} end, S4 = if F@_7 == '$undef' -> S3; true -> S3#{response_status => F@_7} end, if F@_8 == '$undef' -> S4; true -> S4#{expect_compressed => F@_8} end. d_field_simple_request_response_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_response_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_size(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_size(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_fill_username(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_fill_username(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_fill_username(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_fill_oauth_scope(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_fill_oauth_scope(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_fill_oauth_scope(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_response_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, Prev, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, F@_7, F@_8, TrUserData). d_field_simple_request_response_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, Prev, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_echo_status(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, if Prev == '$undef' -> NewFValue; true -> merge_msg_echo_status(Prev, NewFValue, TrUserData) end, F@_8, TrUserData). d_field_simple_request_expect_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_expect_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_expect_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_simple_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> skip_varint_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); skip_varint_simple_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_length_delimited_simple_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> skip_length_delimited_simple_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); skip_length_delimited_simple_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_simple_request(Rest2, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_group_simple_request(Bin, FNum, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_simple_request(Rest, 0, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_32_simple_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_64_simple_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). decode_msg_simple_response(Bin, TrUserData) -> dfp_read_field_def_simple_response(Bin, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_simple_response(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_username(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_oauth_scope(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{username => F@_2, oauth_scope => F@_3}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end; dfp_read_field_def_simple_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_simple_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). dg_read_field_def_simple_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_simple_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_simple_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_simple_response_payload(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 18 -> d_field_simple_response_username(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_simple_response_oauth_scope(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_simple_response(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, TrUserData); 5 -> skip_32_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData) end end; dg_read_field_def_simple_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{username => F@_2, oauth_scope => F@_3}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end. d_field_simple_response_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_2, F@_3, TrUserData). d_field_simple_response_username(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_username(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_username(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, F@_1, NewFValue, F@_3, TrUserData). d_field_simple_response_oauth_scope(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_oauth_scope(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_oauth_scope(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, F@_1, F@_2, NewFValue, TrUserData). skip_varint_simple_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); skip_varint_simple_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_length_delimited_simple_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_simple_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_simple_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_simple_response(Rest2, 0, 0, F@_1, F@_2, F@_3, TrUserData). skip_group_simple_response(Bin, FNum, Z2, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_simple_response(Rest, 0, Z2, F@_1, F@_2, F@_3, TrUserData). skip_32_simple_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_64_simple_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). decode_msg_streaming_input_call_request(Bin, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Bin, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_input_call_request(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_streaming_input_call_request_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_streaming_input_call_request(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_streaming_input_call_request_expect_compressed(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_streaming_input_call_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{expect_compressed => F@_2} end; dfp_read_field_def_streaming_input_call_request(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_streaming_input_call_request(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_streaming_input_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_input_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_streaming_input_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_streaming_input_call_request_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_streaming_input_call_request_expect_compressed(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_streaming_input_call_request(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_streaming_input_call_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{expect_compressed => F@_2} end. d_field_streaming_input_call_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_streaming_input_call_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_streaming_input_call_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_input_call_request(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_2, TrUserData). d_field_streaming_input_call_request_expect_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_streaming_input_call_request_expect_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_streaming_input_call_request_expect_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_input_call_request(RestF, 0, 0, F@_1, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_input_call_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_streaming_input_call_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_streaming_input_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_streaming_input_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_streaming_input_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_input_call_request(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_streaming_input_call_request(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_input_call_request(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_streaming_input_call_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_streaming_input_call_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_streaming_input_call_response(Bin, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Bin, 0, 0, id(0, TrUserData), TrUserData). dfp_read_field_def_streaming_input_call_response(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_streaming_input_call_response(<<>>, 0, 0, F@_1, _) -> #{aggregated_payload_size => F@_1}; dfp_read_field_def_streaming_input_call_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_streaming_input_call_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_streaming_input_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_input_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_streaming_input_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_streaming_input_call_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_streaming_input_call_response(<<>>, 0, 0, F@_1, _) -> #{aggregated_payload_size => F@_1}. d_field_streaming_input_call_response_aggregated_payload_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_streaming_input_call_response_aggregated_payload_size(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_streaming_input_call_response(RestF, 0, 0, NewFValue, TrUserData). skip_varint_streaming_input_call_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_streaming_input_call_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_streaming_input_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_streaming_input_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_streaming_input_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_input_call_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_streaming_input_call_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_input_call_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_streaming_input_call_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_streaming_input_call_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_response_parameters(Bin, TrUserData) -> dfp_read_field_def_response_parameters(Bin, 0, 0, id(0, TrUserData), id(0, TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_response_parameters(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_size(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_interval_us(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{size => F@_1, interval_us => F@_2}, if F@_3 == '$undef' -> S1; true -> S1#{compressed => F@_3} end; dfp_read_field_def_response_parameters(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_response_parameters(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). dg_read_field_def_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_response_parameters_size(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 16 -> d_field_response_parameters_interval_us(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_response_parameters_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_response_parameters(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, TrUserData); 5 -> skip_32_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData) end end; dg_read_field_def_response_parameters(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{size => F@_1, interval_us => F@_2}, if F@_3 == '$undef' -> S1; true -> S1#{compressed => F@_3} end. d_field_response_parameters_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_size(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_size(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_response_parameters(RestF, 0, 0, NewFValue, F@_2, F@_3, TrUserData). d_field_response_parameters_interval_us(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_interval_us(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_interval_us(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_response_parameters(RestF, 0, 0, F@_1, NewFValue, F@_3, TrUserData). d_field_response_parameters_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_response_parameters(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_response_parameters(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); skip_varint_response_parameters(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_length_delimited_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_response_parameters(Rest2, 0, 0, F@_1, F@_2, F@_3, TrUserData). skip_group_response_parameters(Bin, FNum, Z2, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_response_parameters(Rest, 0, Z2, F@_1, F@_2, F@_3, TrUserData). skip_32_response_parameters(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_64_response_parameters(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). decode_msg_streaming_output_call_request(Bin, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_output_call_request(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_type(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_status(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<>>, 0, 0, F@_1, R1, F@_3, F@_4, TrUserData) -> S1 = #{response_type => F@_1}, S2 = if R1 == '$undef' -> S1; true -> S1#{response_parameters => lists_reverse(R1, TrUserData)} end, S3 = if F@_3 == '$undef' -> S2; true -> S2#{payload => F@_3} end, if F@_4 == '$undef' -> S3; true -> S3#{response_status => F@_4} end; dfp_read_field_def_streaming_output_call_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_streaming_output_call_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). dg_read_field_def_streaming_output_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_output_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); dg_read_field_def_streaming_output_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_streaming_output_call_request_response_type(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 18 -> d_field_streaming_output_call_request_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 26 -> d_field_streaming_output_call_request_payload(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 58 -> d_field_streaming_output_call_request_response_status(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 1 -> skip_64_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 2 -> skip_length_delimited_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 3 -> skip_group_streaming_output_call_request(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 5 -> skip_32_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData) end end; dg_read_field_def_streaming_output_call_request(<<>>, 0, 0, F@_1, R1, F@_3, F@_4, TrUserData) -> S1 = #{response_type => F@_1}, S2 = if R1 == '$undef' -> S1; true -> S1#{response_parameters => lists_reverse(R1, TrUserData)} end, S3 = if F@_3 == '$undef' -> S2; true -> S2#{payload => F@_3} end, if F@_4 == '$undef' -> S3; true -> S3#{response_status => F@_4} end. d_field_streaming_output_call_request_response_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, TrUserData). d_field_streaming_output_call_request_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_response_parameters(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, cons(NewFValue, Prev, TrUserData), F@_3, F@_4, TrUserData). d_field_streaming_output_call_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, F@_4, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_4, TrUserData). d_field_streaming_output_call_request_response_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_echo_status(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, F@_2, F@_3, if Prev == '$undef' -> NewFValue; true -> merge_msg_echo_status(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_output_call_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_varint_streaming_output_call_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_length_delimited_streaming_output_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_streaming_output_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_length_delimited_streaming_output_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_output_call_request(Rest2, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_group_streaming_output_call_request(Bin, FNum, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_output_call_request(Rest, 0, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_32_streaming_output_call_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_64_streaming_output_call_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). decode_msg_streaming_output_call_response(Bin, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Bin, 0, 0, id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_output_call_response(<<10, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_streaming_output_call_response_payload(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_streaming_output_call_response(<<>>, 0, 0, F@_1, _) -> S1 = #{}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end; dfp_read_field_def_streaming_output_call_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_streaming_output_call_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_streaming_output_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_output_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_streaming_output_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_streaming_output_call_response_payload(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_streaming_output_call_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_streaming_output_call_response(<<>>, 0, 0, F@_1, _) -> S1 = #{}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end. d_field_streaming_output_call_response_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_streaming_output_call_response_payload(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_streaming_output_call_response_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_response(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_output_call_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_streaming_output_call_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_streaming_output_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_streaming_output_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_streaming_output_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_output_call_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_streaming_output_call_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_output_call_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_streaming_output_call_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_streaming_output_call_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_reconnect_params(Bin, TrUserData) -> dfp_read_field_def_reconnect_params(Bin, 0, 0, id(0, TrUserData), TrUserData). dfp_read_field_def_reconnect_params(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_reconnect_params(<<>>, 0, 0, F@_1, _) -> #{max_reconnect_backoff_ms => F@_1}; dfp_read_field_def_reconnect_params(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_reconnect_params(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_reconnect_params(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_reconnect_params(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_reconnect_params(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_reconnect_params(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_reconnect_params(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_reconnect_params(<<>>, 0, 0, F@_1, _) -> #{max_reconnect_backoff_ms => F@_1}. d_field_reconnect_params_max_reconnect_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_reconnect_params_max_reconnect_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_reconnect_params(RestF, 0, 0, NewFValue, TrUserData). skip_varint_reconnect_params(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_reconnect_params(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_reconnect_params(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_reconnect_params(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_reconnect_params(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_reconnect_params(Rest2, 0, 0, F@_1, TrUserData). skip_group_reconnect_params(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_reconnect_params(Rest, 0, Z2, F@_1, TrUserData). skip_32_reconnect_params(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). skip_64_reconnect_params(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_reconnect_info(Bin, TrUserData) -> dfp_read_field_def_reconnect_info(Bin, 0, 0, id(false, TrUserData), id([], TrUserData), TrUserData). dfp_read_field_def_reconnect_info(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_reconnect_info_passed(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_pfield_reconnect_info_backoff_ms(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_reconnect_info_backoff_ms(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{passed => F@_1, backoff_ms => lists_reverse(R1, TrUserData)}; dfp_read_field_def_reconnect_info(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_reconnect_info(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_reconnect_info(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_reconnect_info(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_reconnect_info(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_reconnect_info_passed(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_pfield_reconnect_info_backoff_ms(Rest, 0, 0, F@_1, F@_2, TrUserData); 16 -> d_field_reconnect_info_backoff_ms(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_reconnect_info(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_reconnect_info(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{passed => F@_1, backoff_ms => lists_reverse(R1, TrUserData)}. d_field_reconnect_info_passed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_reconnect_info_passed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_reconnect_info_passed(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_reconnect_info(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_reconnect_info(RestF, 0, 0, F@_1, cons(NewFValue, Prev, TrUserData), TrUserData). d_pfield_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_pfield_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_pfield_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, E, TrUserData) -> Len = X bsl N + Acc, <> = Rest, NewSeq = d_packed_field_reconnect_info_backoff_ms(PackedBytes, 0, 0, E, TrUserData), dfp_read_field_def_reconnect_info(Rest2, 0, 0, F@_1, NewSeq, TrUserData). d_packed_field_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) when N < 57 -> d_packed_field_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, AccSeq, TrUserData); d_packed_field_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, d_packed_field_reconnect_info_backoff_ms(RestF, 0, 0, [NewFValue | AccSeq], TrUserData); d_packed_field_reconnect_info_backoff_ms(<<>>, 0, 0, AccSeq, _) -> AccSeq. skip_varint_reconnect_info(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_reconnect_info(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_reconnect_info(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_reconnect_info(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_reconnect_info(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_reconnect_info(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_reconnect_info(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_reconnect_info(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_reconnect_info(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_reconnect_info(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). 'd_enum_grpc.testing.PayloadType'(0) -> 'COMPRESSABLE'; 'd_enum_grpc.testing.PayloadType'(V) -> V. read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, {Group, Rest}. %% Like skipping over fields, but record the total length, %% Each field is <(FieldNum bsl 3) bor FieldType> ++ %% Record the length because varints may be non-optimally encoded. %% %% Groups can be nested, but assume the same FieldNum cannot be nested %% because group field numbers are shared with the rest of the fields %% numbers. Thus we can search just for an group-end with the same %% field number. %% %% (The only time the same group field number could occur would %% be in a nested sub message, but then it would be inside a %% length-delimited entry, which we skip-read by length.) read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) when N < (32-7) -> read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) -> Key = X bsl N + Acc, TagLen1 = TagLen + 1, case {Key bsr 3, Key band 7} of {FieldNum, 4} -> % 4 = group_end {NumBytes, TagLen1}; {_, 0} -> % 0 = varint read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); {_, 1} -> % 1 = bits64 <<_:64, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); {_, 2} -> % 2 = length_delimited read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); {_, 3} -> % 3 = group_start read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 4} -> % 4 = group_end read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 5} -> % 5 = bits32 <<_:32, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) end. read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) when N < (64-7) -> read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) when N < (64-7) -> read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> Len = X bsl N + Acc, NumBytes1 = NumBytes + 1, <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of bool_value -> merge_msg_bool_value(Prev, New, TrUserData); payload -> merge_msg_payload(Prev, New, TrUserData); echo_status -> merge_msg_echo_status(Prev, New, TrUserData); simple_request -> merge_msg_simple_request(Prev, New, TrUserData); simple_response -> merge_msg_simple_response(Prev, New, TrUserData); streaming_input_call_request -> merge_msg_streaming_input_call_request(Prev, New, TrUserData); streaming_input_call_response -> merge_msg_streaming_input_call_response(Prev, New, TrUserData); response_parameters -> merge_msg_response_parameters(Prev, New, TrUserData); streaming_output_call_request -> merge_msg_streaming_output_call_request(Prev, New, TrUserData); streaming_output_call_response -> merge_msg_streaming_output_call_response(Prev, New, TrUserData); reconnect_params -> merge_msg_reconnect_params(Prev, New, TrUserData); reconnect_info -> merge_msg_reconnect_info(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_bool_value/3}). merge_msg_bool_value(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{value := NFvalue}} -> S1#{value => NFvalue}; {#{value := PFvalue}, _} -> S1#{value => PFvalue}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_payload/3}). merge_msg_payload(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{type := NFtype}} -> S1#{type => NFtype}; {#{type := PFtype}, _} -> S1#{type => PFtype}; _ -> S1 end, case {PMsg, NMsg} of {_, #{body := NFbody}} -> S2#{body => NFbody}; {#{body := PFbody}, _} -> S2#{body => PFbody}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_echo_status/3}). merge_msg_echo_status(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{code := NFcode}} -> S1#{code => NFcode}; {#{code := PFcode}, _} -> S1#{code => PFcode}; _ -> S1 end, case {PMsg, NMsg} of {_, #{message := NFmessage}} -> S2#{message => NFmessage}; {#{message := PFmessage}, _} -> S2#{message => PFmessage}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_simple_request/3}). merge_msg_simple_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{response_type := NFresponse_type}} -> S1#{response_type => NFresponse_type}; {#{response_type := PFresponse_type}, _} -> S1#{response_type => PFresponse_type}; _ -> S1 end, S3 = case {PMsg, NMsg} of {_, #{response_size := NFresponse_size}} -> S2#{response_size => NFresponse_size}; {#{response_size := PFresponse_size}, _} -> S2#{response_size => PFresponse_size}; _ -> S2 end, S4 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S3#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S3#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S3#{payload => PFpayload}; {_, _} -> S3 end, S5 = case {PMsg, NMsg} of {_, #{fill_username := NFfill_username}} -> S4#{fill_username => NFfill_username}; {#{fill_username := PFfill_username}, _} -> S4#{fill_username => PFfill_username}; _ -> S4 end, S6 = case {PMsg, NMsg} of {_, #{fill_oauth_scope := NFfill_oauth_scope}} -> S5#{fill_oauth_scope => NFfill_oauth_scope}; {#{fill_oauth_scope := PFfill_oauth_scope}, _} -> S5#{fill_oauth_scope => PFfill_oauth_scope}; _ -> S5 end, S7 = case {PMsg, NMsg} of {#{response_compressed := PFresponse_compressed}, #{response_compressed := NFresponse_compressed}} -> S6#{response_compressed => merge_msg_bool_value(PFresponse_compressed, NFresponse_compressed, TrUserData)}; {_, #{response_compressed := NFresponse_compressed}} -> S6#{response_compressed => NFresponse_compressed}; {#{response_compressed := PFresponse_compressed}, _} -> S6#{response_compressed => PFresponse_compressed}; {_, _} -> S6 end, S8 = case {PMsg, NMsg} of {#{response_status := PFresponse_status}, #{response_status := NFresponse_status}} -> S7#{response_status => merge_msg_echo_status(PFresponse_status, NFresponse_status, TrUserData)}; {_, #{response_status := NFresponse_status}} -> S7#{response_status => NFresponse_status}; {#{response_status := PFresponse_status}, _} -> S7#{response_status => PFresponse_status}; {_, _} -> S7 end, case {PMsg, NMsg} of {#{expect_compressed := PFexpect_compressed}, #{expect_compressed := NFexpect_compressed}} -> S8#{expect_compressed => merge_msg_bool_value(PFexpect_compressed, NFexpect_compressed, TrUserData)}; {_, #{expect_compressed := NFexpect_compressed}} -> S8#{expect_compressed => NFexpect_compressed}; {#{expect_compressed := PFexpect_compressed}, _} -> S8#{expect_compressed => PFexpect_compressed}; {_, _} -> S8 end. -compile({nowarn_unused_function,merge_msg_simple_response/3}). merge_msg_simple_response(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end, S3 = case {PMsg, NMsg} of {_, #{username := NFusername}} -> S2#{username => NFusername}; {#{username := PFusername}, _} -> S2#{username => PFusername}; _ -> S2 end, case {PMsg, NMsg} of {_, #{oauth_scope := NFoauth_scope}} -> S3#{oauth_scope => NFoauth_scope}; {#{oauth_scope := PFoauth_scope}, _} -> S3#{oauth_scope => PFoauth_scope}; _ -> S3 end. -compile({nowarn_unused_function,merge_msg_streaming_input_call_request/3}). merge_msg_streaming_input_call_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end, case {PMsg, NMsg} of {#{expect_compressed := PFexpect_compressed}, #{expect_compressed := NFexpect_compressed}} -> S2#{expect_compressed => merge_msg_bool_value(PFexpect_compressed, NFexpect_compressed, TrUserData)}; {_, #{expect_compressed := NFexpect_compressed}} -> S2#{expect_compressed => NFexpect_compressed}; {#{expect_compressed := PFexpect_compressed}, _} -> S2#{expect_compressed => PFexpect_compressed}; {_, _} -> S2 end. -compile({nowarn_unused_function,merge_msg_streaming_input_call_response/3}). merge_msg_streaming_input_call_response(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{aggregated_payload_size := NFaggregated_payload_size}} -> S1#{aggregated_payload_size => NFaggregated_payload_size}; {#{aggregated_payload_size := PFaggregated_payload_size}, _} -> S1#{aggregated_payload_size => PFaggregated_payload_size}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_response_parameters/3}). merge_msg_response_parameters(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{size := NFsize}} -> S1#{size => NFsize}; {#{size := PFsize}, _} -> S1#{size => PFsize}; _ -> S1 end, S3 = case {PMsg, NMsg} of {_, #{interval_us := NFinterval_us}} -> S2#{interval_us => NFinterval_us}; {#{interval_us := PFinterval_us}, _} -> S2#{interval_us => PFinterval_us}; _ -> S2 end, case {PMsg, NMsg} of {#{compressed := PFcompressed}, #{compressed := NFcompressed}} -> S3#{compressed => merge_msg_bool_value(PFcompressed, NFcompressed, TrUserData)}; {_, #{compressed := NFcompressed}} -> S3#{compressed => NFcompressed}; {#{compressed := PFcompressed}, _} -> S3#{compressed => PFcompressed}; {_, _} -> S3 end. -compile({nowarn_unused_function,merge_msg_streaming_output_call_request/3}). merge_msg_streaming_output_call_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{response_type := NFresponse_type}} -> S1#{response_type => NFresponse_type}; {#{response_type := PFresponse_type}, _} -> S1#{response_type => PFresponse_type}; _ -> S1 end, S3 = case {PMsg, NMsg} of {#{response_parameters := PFresponse_parameters}, #{response_parameters := NFresponse_parameters}} -> S2#{response_parameters => 'erlang_++'(PFresponse_parameters, NFresponse_parameters, TrUserData)}; {_, #{response_parameters := NFresponse_parameters}} -> S2#{response_parameters => NFresponse_parameters}; {#{response_parameters := PFresponse_parameters}, _} -> S2#{response_parameters => PFresponse_parameters}; {_, _} -> S2 end, S4 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S3#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S3#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S3#{payload => PFpayload}; {_, _} -> S3 end, case {PMsg, NMsg} of {#{response_status := PFresponse_status}, #{response_status := NFresponse_status}} -> S4#{response_status => merge_msg_echo_status(PFresponse_status, NFresponse_status, TrUserData)}; {_, #{response_status := NFresponse_status}} -> S4#{response_status => NFresponse_status}; {#{response_status := PFresponse_status}, _} -> S4#{response_status => PFresponse_status}; {_, _} -> S4 end. -compile({nowarn_unused_function,merge_msg_streaming_output_call_response/3}). merge_msg_streaming_output_call_response(PMsg, NMsg, TrUserData) -> S1 = #{}, case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_reconnect_params/3}). merge_msg_reconnect_params(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{max_reconnect_backoff_ms := NFmax_reconnect_backoff_ms}} -> S1#{max_reconnect_backoff_ms => NFmax_reconnect_backoff_ms}; {#{max_reconnect_backoff_ms := PFmax_reconnect_backoff_ms}, _} -> S1#{max_reconnect_backoff_ms => PFmax_reconnect_backoff_ms}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_reconnect_info/3}). merge_msg_reconnect_info(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{passed := NFpassed}} -> S1#{passed => NFpassed}; {#{passed := PFpassed}, _} -> S1#{passed => PFpassed}; _ -> S1 end, case {PMsg, NMsg} of {#{backoff_ms := PFbackoff_ms}, #{backoff_ms := NFbackoff_ms}} -> S2#{backoff_ms => 'erlang_++'(PFbackoff_ms, NFbackoff_ms, TrUserData)}; {_, #{backoff_ms := NFbackoff_ms}} -> S2#{backoff_ms => NFbackoff_ms}; {#{backoff_ms := PFbackoff_ms}, _} -> S2#{backoff_ms => PFbackoff_ms}; {_, _} -> S2 end. verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of bool_value -> v_msg_bool_value(Msg, [MsgName], TrUserData); payload -> v_msg_payload(Msg, [MsgName], TrUserData); echo_status -> v_msg_echo_status(Msg, [MsgName], TrUserData); simple_request -> v_msg_simple_request(Msg, [MsgName], TrUserData); simple_response -> v_msg_simple_response(Msg, [MsgName], TrUserData); streaming_input_call_request -> v_msg_streaming_input_call_request(Msg, [MsgName], TrUserData); streaming_input_call_response -> v_msg_streaming_input_call_response(Msg, [MsgName], TrUserData); response_parameters -> v_msg_response_parameters(Msg, [MsgName], TrUserData); streaming_output_call_request -> v_msg_streaming_output_call_request(Msg, [MsgName], TrUserData); streaming_output_call_response -> v_msg_streaming_output_call_response(Msg, [MsgName], TrUserData); reconnect_params -> v_msg_reconnect_params(Msg, [MsgName], TrUserData); reconnect_info -> v_msg_reconnect_info(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_bool_value/3}). -dialyzer({nowarn_function,v_msg_bool_value/3}). v_msg_bool_value(#{} = M, Path, TrUserData) -> case M of #{value := F1} -> v_type_bool(F1, [value | Path], TrUserData); _ -> ok end, lists:foreach(fun (value) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_bool_value(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), bool_value}, M, Path); v_msg_bool_value(X, Path, _TrUserData) -> mk_type_error({expected_msg, bool_value}, X, Path). -compile({nowarn_unused_function,v_msg_payload/3}). -dialyzer({nowarn_function,v_msg_payload/3}). v_msg_payload(#{} = M, Path, TrUserData) -> case M of #{type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [type | Path], TrUserData); _ -> ok end, case M of #{body := F2} -> v_type_bytes(F2, [body | Path], TrUserData); _ -> ok end, lists:foreach(fun (type) -> ok; (body) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_payload(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), payload}, M, Path); v_msg_payload(X, Path, _TrUserData) -> mk_type_error({expected_msg, payload}, X, Path). -compile({nowarn_unused_function,v_msg_echo_status/3}). -dialyzer({nowarn_function,v_msg_echo_status/3}). v_msg_echo_status(#{} = M, Path, TrUserData) -> case M of #{code := F1} -> v_type_int32(F1, [code | Path], TrUserData); _ -> ok end, case M of #{message := F2} -> v_type_string(F2, [message | Path], TrUserData); _ -> ok end, lists:foreach(fun (code) -> ok; (message) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_echo_status(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), echo_status}, M, Path); v_msg_echo_status(X, Path, _TrUserData) -> mk_type_error({expected_msg, echo_status}, X, Path). -compile({nowarn_unused_function,v_msg_simple_request/3}). -dialyzer({nowarn_function,v_msg_simple_request/3}). v_msg_simple_request(#{} = M, Path, TrUserData) -> case M of #{response_type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [response_type | Path], TrUserData); _ -> ok end, case M of #{response_size := F2} -> v_type_int32(F2, [response_size | Path], TrUserData); _ -> ok end, case M of #{payload := F3} -> v_msg_payload(F3, [payload | Path], TrUserData); _ -> ok end, case M of #{fill_username := F4} -> v_type_bool(F4, [fill_username | Path], TrUserData); _ -> ok end, case M of #{fill_oauth_scope := F5} -> v_type_bool(F5, [fill_oauth_scope | Path], TrUserData); _ -> ok end, case M of #{response_compressed := F6} -> v_msg_bool_value(F6, [response_compressed | Path], TrUserData); _ -> ok end, case M of #{response_status := F7} -> v_msg_echo_status(F7, [response_status | Path], TrUserData); _ -> ok end, case M of #{expect_compressed := F8} -> v_msg_bool_value(F8, [expect_compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (response_type) -> ok; (response_size) -> ok; (payload) -> ok; (fill_username) -> ok; (fill_oauth_scope) -> ok; (response_compressed) -> ok; (response_status) -> ok; (expect_compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_simple_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), simple_request}, M, Path); v_msg_simple_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, simple_request}, X, Path). -compile({nowarn_unused_function,v_msg_simple_response/3}). -dialyzer({nowarn_function,v_msg_simple_response/3}). v_msg_simple_response(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, case M of #{username := F2} -> v_type_string(F2, [username | Path], TrUserData); _ -> ok end, case M of #{oauth_scope := F3} -> v_type_string(F3, [oauth_scope | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (username) -> ok; (oauth_scope) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_simple_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), simple_response}, M, Path); v_msg_simple_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, simple_response}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_input_call_request/3}). -dialyzer({nowarn_function,v_msg_streaming_input_call_request/3}). v_msg_streaming_input_call_request(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, case M of #{expect_compressed := F2} -> v_msg_bool_value(F2, [expect_compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (expect_compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_input_call_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_input_call_request}, M, Path); v_msg_streaming_input_call_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_input_call_request}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_input_call_response/3}). -dialyzer({nowarn_function,v_msg_streaming_input_call_response/3}). v_msg_streaming_input_call_response(#{} = M, Path, TrUserData) -> case M of #{aggregated_payload_size := F1} -> v_type_int32(F1, [aggregated_payload_size | Path], TrUserData); _ -> ok end, lists:foreach(fun (aggregated_payload_size) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_input_call_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_input_call_response}, M, Path); v_msg_streaming_input_call_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_input_call_response}, X, Path). -compile({nowarn_unused_function,v_msg_response_parameters/3}). -dialyzer({nowarn_function,v_msg_response_parameters/3}). v_msg_response_parameters(#{} = M, Path, TrUserData) -> case M of #{size := F1} -> v_type_int32(F1, [size | Path], TrUserData); _ -> ok end, case M of #{interval_us := F2} -> v_type_int32(F2, [interval_us | Path], TrUserData); _ -> ok end, case M of #{compressed := F3} -> v_msg_bool_value(F3, [compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (size) -> ok; (interval_us) -> ok; (compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_response_parameters(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), response_parameters}, M, Path); v_msg_response_parameters(X, Path, _TrUserData) -> mk_type_error({expected_msg, response_parameters}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_output_call_request/3}). -dialyzer({nowarn_function,v_msg_streaming_output_call_request/3}). v_msg_streaming_output_call_request(#{} = M, Path, TrUserData) -> case M of #{response_type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [response_type | Path], TrUserData); _ -> ok end, case M of #{response_parameters := F2} -> if is_list(F2) -> _ = [v_msg_response_parameters(Elem, [response_parameters | Path], TrUserData) || Elem <- F2], ok; true -> mk_type_error({invalid_list_of, {msg, response_parameters}}, F2, [response_parameters | Path]) end; _ -> ok end, case M of #{payload := F3} -> v_msg_payload(F3, [payload | Path], TrUserData); _ -> ok end, case M of #{response_status := F4} -> v_msg_echo_status(F4, [response_status | Path], TrUserData); _ -> ok end, lists:foreach(fun (response_type) -> ok; (response_parameters) -> ok; (payload) -> ok; (response_status) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_output_call_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_output_call_request}, M, Path); v_msg_streaming_output_call_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_output_call_request}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_output_call_response/3}). -dialyzer({nowarn_function,v_msg_streaming_output_call_response/3}). v_msg_streaming_output_call_response(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_output_call_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_output_call_response}, M, Path); v_msg_streaming_output_call_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_output_call_response}, X, Path). -compile({nowarn_unused_function,v_msg_reconnect_params/3}). -dialyzer({nowarn_function,v_msg_reconnect_params/3}). v_msg_reconnect_params(#{} = M, Path, TrUserData) -> case M of #{max_reconnect_backoff_ms := F1} -> v_type_int32(F1, [max_reconnect_backoff_ms | Path], TrUserData); _ -> ok end, lists:foreach(fun (max_reconnect_backoff_ms) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_reconnect_params(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), reconnect_params}, M, Path); v_msg_reconnect_params(X, Path, _TrUserData) -> mk_type_error({expected_msg, reconnect_params}, X, Path). -compile({nowarn_unused_function,v_msg_reconnect_info/3}). -dialyzer({nowarn_function,v_msg_reconnect_info/3}). v_msg_reconnect_info(#{} = M, Path, TrUserData) -> case M of #{passed := F1} -> v_type_bool(F1, [passed | Path], TrUserData); _ -> ok end, case M of #{backoff_ms := F2} -> if is_list(F2) -> _ = [v_type_int32(Elem, [backoff_ms | Path], TrUserData) || Elem <- F2], ok; true -> mk_type_error({invalid_list_of, int32}, F2, [backoff_ms | Path]) end; _ -> ok end, lists:foreach(fun (passed) -> ok; (backoff_ms) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_reconnect_info(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), reconnect_info}, M, Path); v_msg_reconnect_info(X, Path, _TrUserData) -> mk_type_error({expected_msg, reconnect_info}, X, Path). -compile({nowarn_unused_function,'v_enum_grpc.testing.PayloadType'/3}). -dialyzer({nowarn_function,'v_enum_grpc.testing.PayloadType'/3}). 'v_enum_grpc.testing.PayloadType'('COMPRESSABLE', _Path, _TrUserData) -> ok; 'v_enum_grpc.testing.PayloadType'(V, Path, TrUserData) when is_integer(V) -> v_type_sint32(V, Path, TrUserData); 'v_enum_grpc.testing.PayloadType'(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'grpc.testing.PayloadType'}, X, Path). -compile({nowarn_unused_function,v_type_sint32/3}). -dialyzer({nowarn_function,v_type_sint32/3}). v_type_sint32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_sint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, sint32, signed, 32}, N, Path); v_type_sint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, sint32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -dialyzer({nowarn_function,v_type_int32/3}). v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_bool/3}). -dialyzer({nowarn_function,v_type_bool/3}). v_type_bool(false, _Path, _TrUserData) -> ok; v_type_bool(true, _Path, _TrUserData) -> ok; v_type_bool(0, _Path, _TrUserData) -> ok; v_type_bool(1, _Path, _TrUserData) -> ok; v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,v_type_bytes/3}). -dialyzer({nowarn_function,v_type_bytes/3}). v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; prettify_path(PathR) -> list_to_atom(lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR))))). -compile({nowarn_unused_function,id/2}). -compile({inline,id/2}). id(X, _TrUserData) -> X. -compile({nowarn_unused_function,v_ok/3}). -compile({inline,v_ok/3}). v_ok(_Value, _Path, _TrUserData) -> ok. -compile({nowarn_unused_function,m_overwrite/3}). -compile({inline,m_overwrite/3}). m_overwrite(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. -compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). -compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. get_msg_defs() -> [{{enum, 'grpc.testing.PayloadType'}, [{'COMPRESSABLE', 0}]}, {{msg, bool_value}, [#{name => value, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}]}, {{msg, payload}, [#{name => type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => body, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]}, {{msg, echo_status}, [#{name => code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, {{msg, simple_request}, [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_size, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => fill_username, fnum => 4, rnum => 5, type => bool, occurrence => optional, opts => []}, #{name => fill_oauth_scope, fnum => 5, rnum => 6, type => bool, occurrence => optional, opts => []}, #{name => response_compressed, fnum => 6, rnum => 7, type => {msg, bool_value}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 8, type => {msg, echo_status}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 8, rnum => 9, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, simple_response}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => username, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => oauth_scope, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, {{msg, streaming_input_call_request}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 2, rnum => 3, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, streaming_input_call_response}, [#{name => aggregated_payload_size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]}, {{msg, response_parameters}, [#{name => size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => interval_us, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => compressed, fnum => 3, rnum => 4, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, streaming_output_call_request}, [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_parameters, fnum => 2, rnum => 3, type => {msg, response_parameters}, occurrence => repeated, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 5, type => {msg, echo_status}, occurrence => optional, opts => []}]}, {{msg, streaming_output_call_response}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}]}, {{msg, reconnect_params}, [#{name => max_reconnect_backoff_ms, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]}, {{msg, reconnect_info}, [#{name => passed, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}, #{name => backoff_ms, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]}]. get_msg_names() -> [bool_value, payload, echo_status, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, response_parameters, streaming_output_call_request, streaming_output_call_response, reconnect_params, reconnect_info]. get_group_names() -> []. get_msg_or_group_names() -> [bool_value, payload, echo_status, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, response_parameters, streaming_output_call_request, streaming_output_call_response, reconnect_params, reconnect_info]. get_enum_names() -> ['grpc.testing.PayloadType']. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of Fs when is_list(Fs) -> Fs; error -> erlang:error({no_such_msg, MsgName}) end. fetch_enum_def(EnumName) -> case find_enum_def(EnumName) of Es when is_list(Es) -> Es; error -> erlang:error({no_such_enum, EnumName}) end. find_msg_def(bool_value) -> [#{name => value, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}]; find_msg_def(payload) -> [#{name => type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => body, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]; find_msg_def(echo_status) -> [#{name => code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; find_msg_def(simple_request) -> [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_size, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => fill_username, fnum => 4, rnum => 5, type => bool, occurrence => optional, opts => []}, #{name => fill_oauth_scope, fnum => 5, rnum => 6, type => bool, occurrence => optional, opts => []}, #{name => response_compressed, fnum => 6, rnum => 7, type => {msg, bool_value}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 8, type => {msg, echo_status}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 8, rnum => 9, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(simple_response) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => username, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => oauth_scope, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; find_msg_def(streaming_input_call_request) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 2, rnum => 3, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(streaming_input_call_response) -> [#{name => aggregated_payload_size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]; find_msg_def(response_parameters) -> [#{name => size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => interval_us, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => compressed, fnum => 3, rnum => 4, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(streaming_output_call_request) -> [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_parameters, fnum => 2, rnum => 3, type => {msg, response_parameters}, occurrence => repeated, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 5, type => {msg, echo_status}, occurrence => optional, opts => []}]; find_msg_def(streaming_output_call_response) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}]; find_msg_def(reconnect_params) -> [#{name => max_reconnect_backoff_ms, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]; find_msg_def(reconnect_info) -> [#{name => passed, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}, #{name => backoff_ms, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]; find_msg_def(_) -> error. find_enum_def('grpc.testing.PayloadType') -> [{'COMPRESSABLE', 0}]; find_enum_def(_) -> error. enum_symbol_by_value('grpc.testing.PayloadType', Value) -> 'enum_symbol_by_value_grpc.testing.PayloadType'(Value). enum_value_by_symbol('grpc.testing.PayloadType', Sym) -> 'enum_value_by_symbol_grpc.testing.PayloadType'(Sym). 'enum_symbol_by_value_grpc.testing.PayloadType'(0) -> 'COMPRESSABLE'. 'enum_value_by_symbol_grpc.testing.PayloadType'('COMPRESSABLE') -> 0. get_service_names() -> ['grpc.testing.BenchmarkService']. get_service_def('grpc.testing.BenchmarkService') -> {{service, 'grpc.testing.BenchmarkService'}, [#{name => 'UnaryCall', input => simple_request, output => simple_response, input_stream => false, output_stream => false, opts => []}, #{name => 'StreamingCall', input => simple_request, output => simple_response, input_stream => true, output_stream => true, opts => []}, #{name => 'StreamingFromClient', input => simple_request, output => simple_response, input_stream => true, output_stream => false, opts => []}, #{name => 'StreamingFromServer', input => simple_request, output => simple_response, input_stream => false, output_stream => true, opts => []}, #{name => 'StreamingBothWays', input => simple_request, output => simple_response, input_stream => true, output_stream => true, opts => []}]}; get_service_def(_) -> error. get_rpc_names('grpc.testing.BenchmarkService') -> ['UnaryCall', 'StreamingCall', 'StreamingFromClient', 'StreamingFromServer', 'StreamingBothWays']; get_rpc_names(_) -> error. find_rpc_def('grpc.testing.BenchmarkService', RpcName) -> 'find_rpc_def_grpc.testing.BenchmarkService'(RpcName); find_rpc_def(_, _) -> error. 'find_rpc_def_grpc.testing.BenchmarkService'('UnaryCall') -> #{name => 'UnaryCall', input => simple_request, output => simple_response, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.BenchmarkService'('StreamingCall') -> #{name => 'StreamingCall', input => simple_request, output => simple_response, input_stream => true, output_stream => true, opts => []}; 'find_rpc_def_grpc.testing.BenchmarkService'('StreamingFromClient') -> #{name => 'StreamingFromClient', input => simple_request, output => simple_response, input_stream => true, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.BenchmarkService'('StreamingFromServer') -> #{name => 'StreamingFromServer', input => simple_request, output => simple_response, input_stream => false, output_stream => true, opts => []}; 'find_rpc_def_grpc.testing.BenchmarkService'('StreamingBothWays') -> #{name => 'StreamingBothWays', input => simple_request, output => simple_response, input_stream => true, output_stream => true, opts => []}; 'find_rpc_def_grpc.testing.BenchmarkService'(_) -> error. fetch_rpc_def(ServiceName, RpcName) -> case find_rpc_def(ServiceName, RpcName) of Def when is_map(Def) -> Def; error -> erlang:error({no_such_rpc, ServiceName, RpcName}) end. %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. fqbin_to_service_name(<<"grpc.testing.BenchmarkService">>) -> 'grpc.testing.BenchmarkService'; fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. service_name_to_fqbin('grpc.testing.BenchmarkService') -> <<"grpc.testing.BenchmarkService">>; service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. fqbins_to_service_and_rpc_name(<<"grpc.testing.BenchmarkService">>, <<"UnaryCall">>) -> {'grpc.testing.BenchmarkService', 'UnaryCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.BenchmarkService">>, <<"StreamingCall">>) -> {'grpc.testing.BenchmarkService', 'StreamingCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.BenchmarkService">>, <<"StreamingFromClient">>) -> {'grpc.testing.BenchmarkService', 'StreamingFromClient'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.BenchmarkService">>, <<"StreamingFromServer">>) -> {'grpc.testing.BenchmarkService', 'StreamingFromServer'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.BenchmarkService">>, <<"StreamingBothWays">>) -> {'grpc.testing.BenchmarkService', 'StreamingBothWays'}; fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. service_and_rpc_name_to_fqbins('grpc.testing.BenchmarkService', 'UnaryCall') -> {<<"grpc.testing.BenchmarkService">>, <<"UnaryCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.BenchmarkService', 'StreamingCall') -> {<<"grpc.testing.BenchmarkService">>, <<"StreamingCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.BenchmarkService', 'StreamingFromClient') -> {<<"grpc.testing.BenchmarkService">>, <<"StreamingFromClient">>}; service_and_rpc_name_to_fqbins('grpc.testing.BenchmarkService', 'StreamingFromServer') -> {<<"grpc.testing.BenchmarkService">>, <<"StreamingFromServer">>}; service_and_rpc_name_to_fqbins('grpc.testing.BenchmarkService', 'StreamingBothWays') -> {<<"grpc.testing.BenchmarkService">>, <<"StreamingBothWays">>}; service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"grpc.testing.BoolValue">>) -> bool_value; fqbin_to_msg_name(<<"grpc.testing.Payload">>) -> payload; fqbin_to_msg_name(<<"grpc.testing.EchoStatus">>) -> echo_status; fqbin_to_msg_name(<<"grpc.testing.SimpleRequest">>) -> simple_request; fqbin_to_msg_name(<<"grpc.testing.SimpleResponse">>) -> simple_response; fqbin_to_msg_name(<<"grpc.testing.StreamingInputCallRequest">>) -> streaming_input_call_request; fqbin_to_msg_name(<<"grpc.testing.StreamingInputCallResponse">>) -> streaming_input_call_response; fqbin_to_msg_name(<<"grpc.testing.ResponseParameters">>) -> response_parameters; fqbin_to_msg_name(<<"grpc.testing.StreamingOutputCallRequest">>) -> streaming_output_call_request; fqbin_to_msg_name(<<"grpc.testing.StreamingOutputCallResponse">>) -> streaming_output_call_response; fqbin_to_msg_name(<<"grpc.testing.ReconnectParams">>) -> reconnect_params; fqbin_to_msg_name(<<"grpc.testing.ReconnectInfo">>) -> reconnect_info; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin(bool_value) -> <<"grpc.testing.BoolValue">>; msg_name_to_fqbin(payload) -> <<"grpc.testing.Payload">>; msg_name_to_fqbin(echo_status) -> <<"grpc.testing.EchoStatus">>; msg_name_to_fqbin(simple_request) -> <<"grpc.testing.SimpleRequest">>; msg_name_to_fqbin(simple_response) -> <<"grpc.testing.SimpleResponse">>; msg_name_to_fqbin(streaming_input_call_request) -> <<"grpc.testing.StreamingInputCallRequest">>; msg_name_to_fqbin(streaming_input_call_response) -> <<"grpc.testing.StreamingInputCallResponse">>; msg_name_to_fqbin(response_parameters) -> <<"grpc.testing.ResponseParameters">>; msg_name_to_fqbin(streaming_output_call_request) -> <<"grpc.testing.StreamingOutputCallRequest">>; msg_name_to_fqbin(streaming_output_call_response) -> <<"grpc.testing.StreamingOutputCallResponse">>; msg_name_to_fqbin(reconnect_params) -> <<"grpc.testing.ReconnectParams">>; msg_name_to_fqbin(reconnect_info) -> <<"grpc.testing.ReconnectInfo">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). fqbin_to_enum_name(<<"grpc.testing.PayloadType">>) -> 'grpc.testing.PayloadType'; fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). enum_name_to_fqbin('grpc.testing.PayloadType') -> <<"grpc.testing.PayloadType">>; enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'grpc.testing'. %% Whether or not the message names %% are prepended with package name or not. uses_packages() -> true. source_basename() -> "benchmark_service.proto". %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension get_all_source_basenames() -> ["benchmark_service.proto", "messages.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. get_all_proto_names() -> ["benchmark_service", "messages"]. get_msg_containment("benchmark_service") -> []; get_msg_containment("messages") -> [bool_value, echo_status, payload, reconnect_info, reconnect_params, response_parameters, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, streaming_output_call_request, streaming_output_call_response]; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("benchmark_service") -> 'grpc.testing'; get_pkg_containment("messages") -> 'grpc.testing'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("benchmark_service") -> ['grpc.testing.BenchmarkService']; get_service_containment("messages") -> []; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("benchmark_service") -> [{'grpc.testing.BenchmarkService', 'UnaryCall'}, {'grpc.testing.BenchmarkService', 'StreamingCall'}, {'grpc.testing.BenchmarkService', 'StreamingFromClient'}, {'grpc.testing.BenchmarkService', 'StreamingFromServer'}, {'grpc.testing.BenchmarkService', 'StreamingBothWays'}]; get_rpc_containment("messages") -> []; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("benchmark_service") -> []; get_enum_containment("messages") -> ['grpc.testing.PayloadType']; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ResponseParameters">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ReconnectParams">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.EchoStatus">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingOutputCallRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingInputCallRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.SimpleRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.Payload">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingOutputCallResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingInputCallResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.SimpleResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.BoolValue">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ReconnectInfo">>) -> "messages"; get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). get_proto_by_service_name_as_fqbin(<<"grpc.testing.BenchmarkService">>) -> "benchmark_service"; get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). get_proto_by_enum_name_as_fqbin(<<"grpc.testing.PayloadType">>) -> "messages"; get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). get_protos_by_pkg_name_as_fqbin(<<"grpc.testing">>) -> ["benchmark_service", "messages"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). descriptor() -> <<10, 237, 3, 10, 36, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 98, 101, 110, 99, 104, 109, 97, 114, 107, 95, 115, 101, 114, 118, 105, 99, 101, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 50, 174, 3, 10, 16, 66, 101, 110, 99, 104, 109, 97, 114, 107, 83, 101, 114, 118, 105, 99, 101, 18, 74, 10, 9, 85, 110, 97, 114, 121, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 78, 10, 13, 83, 116, 114, 101, 97, 109, 105, 110, 103, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 84, 10, 19, 83, 116, 114, 101, 97, 109, 105, 110, 103, 70, 114, 111, 109, 67, 108, 105, 101, 110, 116, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 84, 10, 19, 83, 116, 114, 101, 97, 109, 105, 110, 103, 70, 114, 111, 109, 83, 101, 114, 118, 101, 114, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 82, 10, 17, 83, 116, 114, 101, 97, 109, 105, 110, 103, 66, 111, 116, 104, 87, 97, 121, 115, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51, 10, 215, 10, 10, 27, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 109, 101, 115, 115, 97, 103, 101, 115, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 26, 10, 9, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 13, 10, 5, 118, 97, 108, 117, 101, 24, 1, 32, 1, 40, 8, 34, 43, 10, 10, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 12, 10, 4, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 64, 10, 7, 80, 97, 121, 108, 111, 97, 100, 18, 39, 10, 4, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 12, 10, 4, 98, 111, 100, 121, 24, 2, 32, 1, 40, 12, 34, 63, 10, 13, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 18, 14, 10, 6, 112, 97, 115, 115, 101, 100, 24, 1, 32, 1, 40, 8, 18, 30, 10, 10, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 51, 10, 15, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 18, 32, 10, 24, 109, 97, 120, 95, 114, 101, 99, 111, 110, 110, 101, 99, 116, 95, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 1, 32, 1, 40, 5, 34, 100, 10, 18, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 12, 10, 4, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 18, 19, 10, 11, 105, 110, 116, 101, 114, 118, 97, 108, 95, 117, 115, 24, 2, 32, 1, 40, 5, 18, 43, 10, 10, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 3, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 206, 2, 10, 13, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 21, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 105, 122, 101, 24, 2, 32, 1, 40, 5, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 21, 10, 13, 102, 105, 108, 108, 95, 117, 115, 101, 114, 110, 97, 109, 101, 24, 4, 32, 1, 40, 8, 18, 24, 10, 16, 102, 105, 108, 108, 95, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 5, 32, 1, 40, 8, 18, 52, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 6, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 8, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 95, 10, 14, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 16, 10, 8, 117, 115, 101, 114, 110, 97, 109, 101, 24, 2, 32, 1, 40, 9, 18, 19, 10, 11, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 3, 32, 1, 40, 9, 34, 119, 10, 25, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 2, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 61, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 31, 10, 23, 97, 103, 103, 114, 101, 103, 97, 116, 101, 100, 95, 112, 97, 121, 108, 111, 97, 100, 95, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 34, 232, 1, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 61, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 24, 2, 32, 3, 40, 11, 50, 32, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 34, 69, 10, 27, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 42, 31, 10, 11, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 16, 10, 12, 67, 79, 77, 80, 82, 69, 83, 83, 65, 66, 76, 69, 16, 0, 98, 6, 112, 114, 111, 116, 111, 51>>. descriptor("benchmark_service") -> <<10, 36, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 98, 101, 110, 99, 104, 109, 97, 114, 107, 95, 115, 101, 114, 118, 105, 99, 101, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 50, 174, 3, 10, 16, 66, 101, 110, 99, 104, 109, 97, 114, 107, 83, 101, 114, 118, 105, 99, 101, 18, 74, 10, 9, 85, 110, 97, 114, 121, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 78, 10, 13, 83, 116, 114, 101, 97, 109, 105, 110, 103, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 84, 10, 19, 83, 116, 114, 101, 97, 109, 105, 110, 103, 70, 114, 111, 109, 67, 108, 105, 101, 110, 116, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 84, 10, 19, 83, 116, 114, 101, 97, 109, 105, 110, 103, 70, 114, 111, 109, 83, 101, 114, 118, 101, 114, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 82, 10, 17, 83, 116, 114, 101, 97, 109, 105, 110, 103, 66, 111, 116, 104, 87, 97, 121, 115, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor("messages") -> <<10, 27, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 109, 101, 115, 115, 97, 103, 101, 115, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 26, 10, 9, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 13, 10, 5, 118, 97, 108, 117, 101, 24, 1, 32, 1, 40, 8, 34, 43, 10, 10, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 12, 10, 4, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 64, 10, 7, 80, 97, 121, 108, 111, 97, 100, 18, 39, 10, 4, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 12, 10, 4, 98, 111, 100, 121, 24, 2, 32, 1, 40, 12, 34, 63, 10, 13, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 18, 14, 10, 6, 112, 97, 115, 115, 101, 100, 24, 1, 32, 1, 40, 8, 18, 30, 10, 10, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 51, 10, 15, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 18, 32, 10, 24, 109, 97, 120, 95, 114, 101, 99, 111, 110, 110, 101, 99, 116, 95, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 1, 32, 1, 40, 5, 34, 100, 10, 18, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 12, 10, 4, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 18, 19, 10, 11, 105, 110, 116, 101, 114, 118, 97, 108, 95, 117, 115, 24, 2, 32, 1, 40, 5, 18, 43, 10, 10, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 3, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 206, 2, 10, 13, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 21, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 105, 122, 101, 24, 2, 32, 1, 40, 5, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 21, 10, 13, 102, 105, 108, 108, 95, 117, 115, 101, 114, 110, 97, 109, 101, 24, 4, 32, 1, 40, 8, 18, 24, 10, 16, 102, 105, 108, 108, 95, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 5, 32, 1, 40, 8, 18, 52, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 6, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 8, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 95, 10, 14, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 16, 10, 8, 117, 115, 101, 114, 110, 97, 109, 101, 24, 2, 32, 1, 40, 9, 18, 19, 10, 11, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 3, 32, 1, 40, 9, 34, 119, 10, 25, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 2, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 61, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 31, 10, 23, 97, 103, 103, 114, 101, 103, 97, 116, 101, 100, 95, 112, 97, 121, 108, 111, 97, 100, 95, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 34, 232, 1, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 61, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 24, 2, 32, 3, 40, 11, 50, 32, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 34, 69, 10, 27, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 42, 31, 10, 11, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 16, 10, 12, 67, 79, 77, 80, 82, 69, 83, 83, 65, 66, 76, 69, 16, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor(X) -> error({gpb_error, {badname, X}}). gpb_version_as_string() -> "4.7.3". gpb_version_as_list() -> [4,7,3]. ================================================ FILE: benchmark/src/grpc_testing_benchmark_service.erl ================================================ -module(grpc_testing_benchmark_service). -behaviour(grpc_testing_benchmark_service_bhvr). -export([unary_call/2, streaming_call/2, streaming_from_client/2, streaming_from_server/2, streaming_both_ways/2]). -spec unary_call(ctx:ctx(), benchmark_service_pb:simple_request()) -> {ok, benchmark_service_pb:simple_response()} | grpcbox_stream:grpc_error_response(). unary_call(Ctx, #{response_size := Size}) -> Body = << <<0>> || _ <- lists:seq(1, Size) >>, {ok, #{payload => #{type => 'COMPRESSABLE', body => Body } }, Ctx}. -spec streaming_call(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). streaming_call(Ref, Stream) -> receive {Ref, eos} -> ok; {Ref, #{response_status := #{code := Code, message := Message}}} -> grpcbox_stream:error(grpcbox_stream:code_to_status(Code), Message); {Ref, #{response_type := ResponseType, response_size := ResponseSize }} -> Body = << <<0>> || _ <- lists:seq(1, ResponseSize) >>, grpcbox_stream:send(#{payload => #{type => ResponseType, body => Body}}, Stream), streaming_call(Ref, Stream) end. -spec streaming_from_client(reference(), grpcbox_stream:t()) -> {ok, benchmark_service_pb:simple_response(), ctx:ctx()} | grpcbox_stream:grpc_error_response(). streaming_from_client(_Ref, _Stream) -> ok. -spec streaming_from_server(benchmark_service_pb:simple_request(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). streaming_from_server(_Ref, _Stream) -> ok. -spec streaming_both_ways(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). streaming_both_ways(_Ref, _Stream) -> ok. ================================================ FILE: benchmark/src/grpc_testing_benchmark_service_bhvr.erl ================================================ %%%------------------------------------------------------------------- %% @doc Behaviour to implement for grpc service grpc.testing.BenchmarkService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2021-12-29T09:28:22+00:00 and should not be modified manually -module(grpc_testing_benchmark_service_bhvr). %% @doc Unary RPC -callback unary_call(ctx:ctx(), benchmark_service_pb:simple_request()) -> {ok, benchmark_service_pb:simple_response(), ctx:ctx()} | grpcbox_stream:grpc_error_response(). %% @doc -callback streaming_call(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). %% @doc -callback streaming_from_client(reference(), grpcbox_stream:t()) -> {ok, benchmark_service_pb:simple_response(), ctx:ctx()} | grpcbox_stream:grpc_error_response(). %% @doc -callback streaming_from_server(benchmark_service_pb:simple_request(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). %% @doc -callback streaming_both_ways(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). ================================================ FILE: benchmark/src/grpc_testing_benchmark_service_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc Client module for grpc service grpc.testing.BenchmarkService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2021-12-29T09:28:22+00:00 and should not be modified manually -module(grpc_testing_benchmark_service_client). -compile(export_all). -compile(nowarn_export_all). -include_lib("grpcbox/include/grpcbox.hrl"). -define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). -define(SERVICE, 'grpc.testing.BenchmarkService'). -define(PROTO_MODULE, 'benchmark_service_pb'). -define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). -define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). -define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, message_type=MessageType, marshal_fun=?MARSHAL_FUN(Input), unmarshal_fun=?UNMARSHAL_FUN(Output)}). %% @doc Unary RPC -spec unary_call(benchmark_service_pb:simple_request()) -> {ok, benchmark_service_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unary_call(Input) -> unary_call(ctx:new(), Input, #{}). -spec unary_call(ctx:t() | benchmark_service_pb:simple_request(), benchmark_service_pb:simple_request() | grpcbox_client:options()) -> {ok, benchmark_service_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unary_call(Ctx, Input) when ?is_ctx(Ctx) -> unary_call(Ctx, Input, #{}); unary_call(Input, Options) -> unary_call(ctx:new(), Input, Options). -spec unary_call(ctx:t(), benchmark_service_pb:simple_request(), grpcbox_client:options()) -> {ok, benchmark_service_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unary_call(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.BenchmarkService/UnaryCall">>, Input, ?DEF(simple_request, simple_response, <<"grpc.testing.SimpleRequest">>), Options). %% @doc -spec streaming_call() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_call() -> streaming_call(ctx:new(), #{}). -spec streaming_call(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_call(Ctx) when ?is_ctx(Ctx) -> streaming_call(Ctx, #{}); streaming_call(Options) -> streaming_call(ctx:new(), Options). -spec streaming_call(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_call(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.BenchmarkService/StreamingCall">>, ?DEF(simple_request, simple_response, <<"grpc.testing.SimpleRequest">>), Options). %% @doc -spec streaming_from_client() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_from_client() -> streaming_from_client(ctx:new(), #{}). -spec streaming_from_client(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_from_client(Ctx) when ?is_ctx(Ctx) -> streaming_from_client(Ctx, #{}); streaming_from_client(Options) -> streaming_from_client(ctx:new(), Options). -spec streaming_from_client(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_from_client(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.BenchmarkService/StreamingFromClient">>, ?DEF(simple_request, simple_response, <<"grpc.testing.SimpleRequest">>), Options). %% @doc -spec streaming_from_server(benchmark_service_pb:simple_request()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_from_server(Input) -> streaming_from_server(ctx:new(), Input, #{}). -spec streaming_from_server(ctx:t() | benchmark_service_pb:simple_request(), benchmark_service_pb:simple_request() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_from_server(Ctx, Input) when ?is_ctx(Ctx) -> streaming_from_server(Ctx, Input, #{}); streaming_from_server(Input, Options) -> streaming_from_server(ctx:new(), Input, Options). -spec streaming_from_server(ctx:t(), benchmark_service_pb:simple_request(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_from_server(Ctx, Input, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.BenchmarkService/StreamingFromServer">>, Input, ?DEF(simple_request, simple_response, <<"grpc.testing.SimpleRequest">>), Options). %% @doc -spec streaming_both_ways() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_both_ways() -> streaming_both_ways(ctx:new(), #{}). -spec streaming_both_ways(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_both_ways(Ctx) when ?is_ctx(Ctx) -> streaming_both_ways(Ctx, #{}); streaming_both_ways(Options) -> streaming_both_ways(ctx:new(), Options). -spec streaming_both_ways(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_both_ways(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.BenchmarkService/StreamingBothWays">>, ?DEF(simple_request, simple_response, <<"grpc.testing.SimpleRequest">>), Options). ================================================ FILE: benchmark/test/grpcbox_benchmark_client_SUITE.erl ================================================ -module(grpcbox_benchmark_client_SUITE). -compile([export_all]). -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). -include("grpcbox.hrl"). -define(COUNTER_SUM_REQS, 1). -define(COUNTER_SUM_LATENCY, 2). all() -> [{group, identity} % {group, gzip} ]. groups() -> Cases = case ct:get_config(rpc_type, unary) of unary -> [unary_call]; stream -> [streaming_call] end, [{identity, Cases} % {gzip, Cases} ]. init_per_group(Encoding, Config) -> application:load(grpcbox), NrConns = lists:seq(1, ct:get_config(num_conn, 1)), ChannelEndpoints = [{http, ct:get_config(server_addr, "localhost"), ct:get_config(server_port, 8080), [{nr, Nr}]} || Nr <- NrConns], application:set_env(grpcbox, client, #{channels => [{default_channel, ChannelEndpoints, #{encoding => Encoding}}]}), {ok, _} = application:ensure_all_started(grpcbox), application:set_env([{chatterbox, ct:get_config(chatterbox)}]), Config. end_per_group(_Encoding, _Config) -> application:stop(grpcbox), ok. unary_call(_Config) -> start_calls(unary). streaming_call(_Config) -> start_calls(streaming). start_calls(CallType) -> log_settings(), NumRpc = lists:seq(1, ct:get_config(num_rpc, 1)), Payload = client_payload(ct:get_config(rq_size, 1)), SimpleRequest = #{payload => Payload, response_size => ct:get_config(rsp_size, 1)}, CounterRefs = [counters:new(2, [atomics]) || _ <- NumRpc], StartTime = erlang:system_time(millisecond), WarmupEndTime = StartTime + (ct:get_config(warmup_dur, 10) * 1000), EndTime = WarmupEndTime + (ct:get_config(duration, 60) * 1000), ParentPid = self(), Pids = [spawn_link(fun() -> {ok, Stream} = get_stream(CallType), run_calls(Nr, Stream, SimpleRequest, lists:nth(Nr, CounterRefs), StartTime, WarmupEndTime, EndTime), ParentPid ! self() end) || Nr <- NumRpc], wait_for_processes(Pids), aggregate_counters(CounterRefs, WarmupEndTime, EndTime), ok. wait_for_processes([]) -> ok; wait_for_processes(Pids) -> receive Pid -> NewPids = lists:delete(Pid, Pids), wait_for_processes(NewPids) end. get_stream(unary) -> {ok, undefined}; get_stream(streaming) -> grpc_testing_benchmark_service_client:streaming_call(ctx:new()). run_calls(ProcNr, Stream, SimpleRequest, CounterRef, StartTime, WarmupEndTime, EndTime) -> CallStart = erlang:system_time(millisecond), case CallStart > EndTime of true -> ok; false -> run_call(Stream, SimpleRequest), CallEnd = erlang:system_time(millisecond), case CallStart >= WarmupEndTime of true -> update_counters(CounterRef, CallEnd - CallStart); false -> ok end, run_calls(ProcNr, Stream, SimpleRequest, CounterRef, StartTime, WarmupEndTime, EndTime) end. run_call(undefined, SimpleRequest) -> grpc_testing_benchmark_service_client:unary_call(ctx:new(), SimpleRequest); run_call(Stream, SimpleRequest) -> ok = grpcbox_client:send(Stream, SimpleRequest), {ok, _} = grpcbox_client:recv_data(Stream). update_counters(CounterRef, Latency) -> counters:add(CounterRef, ?COUNTER_SUM_REQS, 1), counters:add(CounterRef, ?COUNTER_SUM_LATENCY, Latency). log_counter(ProcNr, CounterRef, StartTime, CurrTime) -> Reqs = counters:get(CounterRef, ?COUNTER_SUM_REQS), SumLatency = counters:get(CounterRef, ?COUNTER_SUM_LATENCY), ct:log("ProcNr: ~p, Total reqs: ~p, Reqs/s: ~p, Avg latency: ~p", [ProcNr, Reqs, Reqs/((CurrTime-StartTime)/1000.0), SumLatency/Reqs]). aggregate_counters(CounterRefs, StartTime, EndTime) -> lists:foldl(fun(CounterRef, Ix) -> log_counter(Ix, CounterRef, StartTime, EndTime), Ix+1 end, 1, CounterRefs), Reqs = lists:foldl(fun(CounterRef, Sum) -> counters:get(CounterRef, ?COUNTER_SUM_REQS) + Sum end, 0, CounterRefs), SumLatency = lists:foldl(fun(CounterRef, Sum) -> counters:get(CounterRef, ?COUNTER_SUM_LATENCY) + Sum end, 0, CounterRefs), ct:log("Total reqs: ~p, Reqs/s: ~p, Avg latency: ~p", [Reqs, Reqs/((EndTime-StartTime)/1000.0), SumLatency/Reqs]), ct:print("Total reqs: ~p, Reqs/s: ~p, Avg latency: ~p", [Reqs, Reqs/((EndTime-StartTime)/1000.0), SumLatency/Reqs]). client_payload(NumBytes) -> Body = << <<0:8>> || _ <- lists:seq(1, NumBytes)>>, #{type => 0, body => Body}. log_settings() -> log_ct_parameter(server_addr), log_ct_parameter(server_port), log_ct_parameter(num_rpc), log_ct_parameter(num_conn), log_ct_parameter(warmup_dur), log_ct_parameter(duration), log_ct_parameter(rq_size), log_ct_parameter(rsp_size), log_ct_parameter(rpc_type), log_ct_parameter(chatterbox). log_ct_parameter(Param) -> ct:log("~p: ~p" , [Param, ct:get_config(Param)]). ================================================ FILE: config/test.config ================================================ [ {grpcbox, [{client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{%% stats_handler => grpcbox_oc_stats_handler }}]}}, {servers, [#{grpc_opts => #{service_protos => [route_guide_pb, grpcbox_health_pb, grpcbox_reflection_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide, 'grpc.health.v1.Health' => grpcbox_health_service, 'grpc.reflection.v1alpha.ServerReflection' => grpcbox_reflection_service}, %% stats_handler => grpcbox_oc_stats_handler, client_cert_dir => "test/grpcbox_SUITE_data/certificates/"}, transport_opts => #{ssl => false, keyfile => "test/grpcbox_SUITE_data/certificates/server1.key", certfile => "test/grpcbox_SUITE_data/certificates/server1.pem", cacertfile => "test/grpcbox_SUITE_data/certificates/ca.pem"}, listen_opts => #{port => 8080, ip => {0,0,0,0}}, pool_opts => #{size => 10}, server_opts => #{header_table_size => 4096, enable_push => 1, max_concurrent_streams => unlimited, initial_window_size => 65535, max_frame_size => 16384, max_header_list_size => unlimited}}]}] }, {opencensus, [{sampler, {oc_sampler_always, []}}, {reporters, [{oc_reporter_stdout, []}]}, {stat, [{exporters, [{oc_stat_exporter_stdout, []}]}]}]} ]. ================================================ FILE: elvis.config ================================================ [ { elvis, [ {config, [#{dirs => ["src"], filter => "*.erl", ignore => [], rules => [{elvis_style, god_modules, #{ignore => []}}, {elvis_style, no_debug_call, #{ignore => []}}, {elvis_style, nesting_level, #{ignore => []}}, {elvis_style, dont_repeat_yourself, #{min_complexity => 20}}, {elvis_style, line_length, #{limit => 120}}, {elvis_style, state_record_and_type, disable}, {elvis_style, macro_names, disable}, {elvis_style, function_naming_convention, #{regex => "^_{0,2}([a-z][a-z0-9]*_?)*_{0,2}$"}}, {elvis_style, invalid_dynamic_call, #{ignore => [grpcbox_stream, grpcbox_chain_interceptor, grpcbox_services_sup]}}], ruleset => erl_files }, #{dirs => ["."], filter => "rebar.config", rules => [{elvis_project, no_deps_master_rebar, disable}], ruleset => rebar_config }, #{dirs => ["."], filter => "elvis.config", ruleset => elvis_config } ] } ] } ]. ================================================ FILE: include/grpcbox.hrl ================================================ -record(method, {key :: {unicode:chardata() | '$1', unicode:chardata() | '_'} | '_', proto :: module() | '$1' | '_', module :: module() | '_', function :: atom() | '_', input :: {term(), boolean()} | '_', output :: {term(), boolean()} | '_', opts :: [term()] | '_'}). %% service definition -record(grpcbox_def, {service :: atom(), message_type = <<>> :: binary(), marshal_fun :: fun((map()) -> binary()), unmarshal_fun :: fun((binary()) -> map())}). -define(CHANNELS_TAB, channels_table). -define(GRPC_STATUS_OK, <<"0">>). -define(GRPC_STATUS_CANCELLED, <<"1">>). -define(GRPC_STATUS_UNKNOWN, <<"2">>). -define(GRPC_STATUS_INVALID_ARGUMENT, <<"3">>). -define(GRPC_STATUS_DEADLINE_EXCEEDED, <<"4">>). -define(GRPC_STATUS_NOT_FOUND, <<"5">>). -define(GRPC_STATUS_ALREADY_EXISTS , <<"6">>). -define(GRPC_STATUS_PERMISSION_DENIED, <<"7">>). -define(GRPC_STATUS_RESOURCE_EXHAUSTED, <<"8">>). -define(GRPC_STATUS_FAILED_PRECONDITION, <<"9">>). -define(GRPC_STATUS_ABORTED, <<"10">>). -define(GRPC_STATUS_OUT_OF_RANGE, <<"11">>). -define(GRPC_STATUS_UNIMPLEMENTED, <<"12">>). -define(GRPC_STATUS_INTERNAL, <<"13">>). -define(GRPC_STATUS_UNAVAILABLE, <<"14">>). -define(GRPC_STATUS_DATA_LOSS, <<"15">>). -define(GRPC_STATUS_UNAUTHENTICATED, <<"16">>). -define(GRPC_ERROR(Status, Message), {grpc_error, {Status, Message}}). -define(THROW(Status, Message), throw(?GRPC_ERROR(Status, Message))). ================================================ FILE: interop/config/sys.config ================================================ [ {grpcbox, [%% {client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}}, {servers, [#{grpc_opts => #{service_protos => [test_pb, grpcbox_health_pb, grpcbox_reflection_pb], services => #{'grpc.testing.TestService' => grpc_testing_test_service, 'grpc.health.v1.Health' => grpcbox_health_service, 'grpc.reflection.v1alpha.ServerReflection' => grpcbox_reflection_service}, client_cert_dir => "test/grpcbox_SUITE_data/certificates/"}, transport_opts => #{ssl => false, keyfile => "test/grpcbox_SUITE_data/certificates/server1.key", certfile => "test/grpcbox_SUITE_data/certificates/server1.pem", cacertfile => "test/grpcbox_SUITE_data/certificates/ca.pem"}, listen_opts => #{port => 8080, ip => {0,0,0,0}}, pool_opts => #{size => 10}, server_opts => #{header_table_size => 4096, enable_push => 1, max_concurrent_streams => unlimited, initial_window_size => 65535, max_frame_size => 16384, max_header_list_size => unlimited}}]}]}, {opencensus, [{sampler, {oc_sampler_always, []}}, {reporters, [{oc_reporter_stdout, []}]}, {stat, [{exporters, [{oc_stat_exporter_stdout, []}]}]}]}, {kernel, [ {logger, [ {handler, default, logger_std_h, #{filters => [{progress, {fun logger_filters:progress/2, stop}}], formatter => {logger_formatter, #{single_line => true}}}}]}]} ]. ================================================ FILE: interop/include/grpcbox_interop_tests.hrl ================================================ -define(INITIAL_METADATA_KEY, <<"x-grpc-test-echo-initial">>). -define(TRAILING_METADATA_KEY, <<"x-grpc-test-echo-trailing-bin">>). -define(INITIAL_METADATA_VALUE, <<"test_initial_metadata_value">>). -define(TRAILING_METADATA_VALUE, <<"\x0a\x0b\x0a\x0b\x0a\x0b">>). ================================================ FILE: interop/proto/empty.proto ================================================ // Copyright 2015 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. syntax = "proto3"; package grpc.testing; // An empty message that you can re-use to avoid defining duplicated empty // messages in your project. A typical example is to use it as argument or the // return value of a service API. For instance: // // service Foo { // rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { }; // }; // message Empty {} ================================================ FILE: interop/proto/messages.proto ================================================ // Copyright 2015-2016 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Message definitions to be used by integration test service definitions. syntax = "proto3"; package grpc.testing; // TODO(dgq): Go back to using well-known types once // https://github.com/grpc/grpc/issues/6980 has been fixed. // import "google/protobuf/wrappers.proto"; message BoolValue { // The bool value. bool value = 1; } // DEPRECATED, don't use. To be removed shortly. // The type of payload that should be returned. enum PayloadType { // Compressible text format. COMPRESSABLE = 0; } // A block of data, to simply increase gRPC message size. message Payload { // DEPRECATED, don't use. To be removed shortly. // The type of data in body. PayloadType type = 1; // Primary contents of payload. bytes body = 2; } // A protobuf representation for grpc status. This is used by test // clients to specify a status that the server should attempt to return. message EchoStatus { int32 code = 1; string message = 2; } // Unary request. message SimpleRequest { // DEPRECATED, don't use. To be removed shortly. // Desired payload type in the response from the server. // If response_type is RANDOM, server randomly chooses one from other formats. PayloadType response_type = 1; // Desired payload size in the response from the server. int32 response_size = 2; // Optional input payload sent along with the request. Payload payload = 3; // Whether SimpleResponse should include username. bool fill_username = 4; // Whether SimpleResponse should include OAuth scope. bool fill_oauth_scope = 5; // Whether to request the server to compress the response. This field is // "nullable" in order to interoperate seamlessly with clients not able to // implement the full compression tests by introspecting the call to verify // the response's compression status. BoolValue response_compressed = 6; // Whether server should return a given status EchoStatus response_status = 7; // Whether the server should expect this request to be compressed. BoolValue expect_compressed = 8; } // Unary response, as configured by the request. message SimpleResponse { // Payload to increase message size. Payload payload = 1; // The user the request came from, for verifying authentication was // successful when the client expected it. string username = 2; // OAuth scope. string oauth_scope = 3; } // Client-streaming request. message StreamingInputCallRequest { // Optional input payload sent along with the request. Payload payload = 1; // Whether the server should expect this request to be compressed. This field // is "nullable" in order to interoperate seamlessly with servers not able to // implement the full compression tests by introspecting the call to verify // the request's compression status. BoolValue expect_compressed = 2; // Not expecting any payload from the response. } // Client-streaming response. message StreamingInputCallResponse { // Aggregated size of payloads received from the client. int32 aggregated_payload_size = 1; } // Configuration for a particular response. message ResponseParameters { // Desired payload sizes in responses from the server. int32 size = 1; // Desired interval between consecutive responses in the response stream in // microseconds. int32 interval_us = 2; // Whether to request the server to compress the response. This field is // "nullable" in order to interoperate seamlessly with clients not able to // implement the full compression tests by introspecting the call to verify // the response's compression status. BoolValue compressed = 3; } // Server-streaming request. message StreamingOutputCallRequest { // DEPRECATED, don't use. To be removed shortly. // Desired payload type in the response from the server. // If response_type is RANDOM, the payload from each response in the stream // might be of different types. This is to simulate a mixed type of payload // stream. PayloadType response_type = 1; // Configuration for each expected response message. repeated ResponseParameters response_parameters = 2; // Optional input payload sent along with the request. Payload payload = 3; // Whether server should return a given status EchoStatus response_status = 7; } // Server-streaming response, as configured by the request and parameters. message StreamingOutputCallResponse { // Payload to increase response size. Payload payload = 1; } // For reconnect interop test only. // Client tells server what reconnection parameters it used. message ReconnectParams { int32 max_reconnect_backoff_ms = 1; } // For reconnect interop test only. // Server tells client whether its reconnects are following the spec and the // reconnect backoffs it saw. message ReconnectInfo { bool passed = 1; repeated int32 backoff_ms = 2; } ================================================ FILE: interop/proto/test.proto ================================================ // Copyright 2015-2016 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // An integration test service that covers all the method signature permutations // of unary/streaming requests/responses. syntax = "proto3"; import "interop/proto/empty.proto"; import "interop/proto/messages.proto"; package grpc.testing; // A simple service to test the various types of RPCs and experiment with // performance with various types of payload. service TestService { // One empty request followed by one empty response. rpc EmptyCall(grpc.testing.Empty) returns (grpc.testing.Empty); // One request followed by one response. rpc UnaryCall(SimpleRequest) returns (SimpleResponse); // One request followed by one response. Response has cache control // headers set such that a caching HTTP proxy (such as GFE) can // satisfy subsequent requests. rpc CacheableUnaryCall(SimpleRequest) returns (SimpleResponse); // One request followed by a sequence of responses (streamed download). // The server returns the payload with client desired type and sizes. rpc StreamingOutputCall(StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse); // A sequence of requests followed by one response (streamed upload). // The server returns the aggregated size of client payload as the result. rpc StreamingInputCall(stream StreamingInputCallRequest) returns (StreamingInputCallResponse); // A sequence of requests with each request served by the server immediately. // As one request could lead to multiple responses, this interface // demonstrates the idea of full duplexing. rpc FullDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse); // A sequence of requests followed by a sequence of responses. // The server buffers all the client requests and then serves them in order. A // stream of responses are returned to the client when the server starts with // first request. rpc HalfDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse); // The test server will not implement this method. It will be used // to test the behavior when clients call unimplemented methods. rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty); } // A simple service NOT implemented at servers so clients can test for // that case. service UnimplementedService { // A call that no server should implement rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty); } // A service used to control reconnect server. service ReconnectService { rpc Start(grpc.testing.ReconnectParams) returns (grpc.testing.Empty); rpc Stop(grpc.testing.Empty) returns (grpc.testing.ReconnectInfo); } ================================================ FILE: interop/run_server_tests.sh ================================================ #!/bin/bash PORT=8080 TLS=false tests=( empty_unary large_unary client_streaming server_streaming ping_pong empty_stream status_code_and_message custom_metadata unimplemented_method unimplemented_service ## TODO # compute_engine_creds # service_account_creds # jwt_token_creds # per_rpc_creds # oauth2_auth_token ## tests that do pass but shouldn't ## # timeout_on_sleeping_server # cancel_after_begin # cancel_after_first_response ) for test in "${tests[@]}"; do echo -n "Running ${test}... " go-grpc-interop-client -use_tls=$TLS -test_case=$test -server_port=$PORT if [[ $? -ne 0 ]]; then echo "Failed!" exit 1 fi echo "Passed" done echo "----" echo "YAY! All enabled tests passed." ================================================ FILE: interop/src/empty_pb.erl ================================================ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit %% Generated by gpb_compile version 4.7.1 -module(empty_pb). -export([encode_msg/2, encode_msg/3]). -export([decode_msg/2, decode_msg/3]). -export([merge_msgs/3, merge_msgs/4]). -export([verify_msg/2, verify_msg/3]). -export([get_msg_defs/0]). -export([get_msg_names/0]). -export([get_group_names/0]). -export([get_msg_or_group_names/0]). -export([get_enum_names/0]). -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). -export([find_rpc_def/2, fetch_rpc_def/2]). -export([fqbin_to_service_name/1]). -export([service_name_to_fqbin/1]). -export([fqbins_to_service_and_rpc_name/2]). -export([service_and_rpc_name_to_fqbins/2]). -export([fqbin_to_msg_name/1]). -export([msg_name_to_fqbin/1]). -export([fqbin_to_enum_name/1]). -export([enum_name_to_fqbin/1]). -export([get_package_name/0]). -export([uses_packages/0]). -export([source_basename/0]). -export([get_all_source_basenames/0]). -export([get_all_proto_names/0]). -export([get_msg_containment/1]). -export([get_pkg_containment/1]). -export([get_service_containment/1]). -export([get_rpc_containment/1]). -export([get_enum_containment/1]). -export([get_proto_by_msg_name_as_fqbin/1]). -export([get_proto_by_service_name_as_fqbin/1]). -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([descriptor/0, descriptor/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). %% enumerated types -export_type([]). %% message types -type empty() :: #{ }. -export_type(['empty'/0]). -spec encode_msg(empty(), atom()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). -spec encode_msg(empty(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> case proplists:get_bool(verify, Opts) of true -> verify_msg(Msg, MsgName, Opts); false -> ok end, TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData) end. encode_msg_empty(_Msg, _TrUserData) -> <<>>. -compile({nowarn_unused_function,e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). e_type_bool(true, Bin, _TrUserData) -> <>; e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_string/3}). e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -compile({nowarn_unused_function,e_type_bytes/3}). e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). e_type_float(V, Bin, _) when is_number(V) -> <>; e_type_float(infinity, Bin, _) -> <>; e_type_float('-infinity', Bin, _) -> <>; e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). e_type_double(V, Bin, _) when is_number(V) -> <>; e_type_double(infinity, Bin, _) -> <>; e_type_double('-infinity', Bin, _) -> <>; e_type_double(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). -compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, e_varint(N bsr 7, Bin2). decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), decode_msg_1_catch(Bin, MsgName, TrUserData). -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason -> StackTrace = erlang:get_stacktrace(), error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData). decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, TrUserData). dfp_read_field_def_empty(<<>>, 0, 0, _) -> #{}; dfp_read_field_def_empty(Other, Z1, Z2, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, TrUserData). dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, TrUserData); dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, TrUserData) -> Key = X bsl N + Acc, case Key band 7 of 0 -> skip_varint_empty(Rest, 0, 0, TrUserData); 1 -> skip_64_empty(Rest, 0, 0, TrUserData); 2 -> skip_length_delimited_empty(Rest, 0, 0, TrUserData); 3 -> skip_group_empty(Rest, Key bsr 3, 0, TrUserData); 5 -> skip_32_empty(Rest, 0, 0, TrUserData) end; dg_read_field_def_empty(<<>>, 0, 0, _) -> #{}. skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, TrUserData); skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, TrUserData); skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_empty(Rest2, 0, 0, TrUserData). skip_group_empty(Bin, FNum, Z2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_empty(Rest, 0, Z2, TrUserData). skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, {Group, Rest}. %% Like skipping over fields, but record the total length, %% Each field is <(FieldNum bsl 3) bor FieldType> ++ %% Record the length because varints may be non-optimally encoded. %% %% Groups can be nested, but assume the same FieldNum cannot be nested %% because group field numbers are shared with the rest of the fields %% numbers. Thus we can search just for an group-end with the same %% field number. %% %% (The only time the same group field number could occur would %% be in a nested sub message, but then it would be inside a %% length-delimited entry, which we skip-read by length.) read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) when N < (32-7) -> read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) -> Key = X bsl N + Acc, TagLen1 = TagLen + 1, case {Key bsr 3, Key band 7} of {FieldNum, 4} -> % 4 = group_end {NumBytes, TagLen1}; {_, 0} -> % 0 = varint read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); {_, 1} -> % 1 = bits64 <<_:64, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); {_, 2} -> % 2 = length_delimited read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); {_, 3} -> % 3 = group_start read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 4} -> % 4 = group_end read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 5} -> % 5 = bits32 <<_:32, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) end. read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) when N < (64-7) -> read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) when N < (64-7) -> read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> Len = X bsl N + Acc, NumBytes1 = NumBytes + 1, <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> merge_msg_empty(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_empty/3}). merge_msg_empty(_Prev, New, _TrUserData) -> New. verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> v_msg_empty(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_empty/3}). -dialyzer({nowarn_function,v_msg_empty/3}). v_msg_empty(#{} = M, Path, _) -> lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; prettify_path(PathR) -> list_to_atom(lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR))))). -compile({nowarn_unused_function,id/2}). -compile({inline,id/2}). id(X, _TrUserData) -> X. -compile({nowarn_unused_function,v_ok/3}). -compile({inline,v_ok/3}). v_ok(_Value, _Path, _TrUserData) -> ok. -compile({nowarn_unused_function,m_overwrite/3}). -compile({inline,m_overwrite/3}). m_overwrite(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. -compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). -compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. get_msg_defs() -> [{{msg, empty}, []}]. get_msg_names() -> [empty]. get_group_names() -> []. get_msg_or_group_names() -> [empty]. get_enum_names() -> []. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of Fs when is_list(Fs) -> Fs; error -> erlang:error({no_such_msg, MsgName}) end. -spec fetch_enum_def(_) -> no_return(). fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). find_msg_def(empty) -> []; find_msg_def(_) -> error. find_enum_def(_) -> error. -spec enum_symbol_by_value(_, _) -> no_return(). enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). -spec enum_value_by_symbol(_, _) -> no_return(). enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). get_service_names() -> []. get_service_def(_) -> error. get_rpc_names(_) -> error. find_rpc_def(_, _) -> error. -spec fetch_rpc_def(_, _) -> no_return(). fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}). %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. -spec fqbin_to_service_name(_) -> no_return(). fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. -spec service_name_to_fqbin(_) -> no_return(). service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. -spec fqbins_to_service_and_rpc_name(_, _) -> no_return(). fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. -spec service_and_rpc_name_to_fqbins(_, _) -> no_return(). service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"grpc.testing.Empty">>) -> empty; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin(empty) -> <<"grpc.testing.Empty">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec enum_name_to_fqbin(_) -> no_return(). fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). -spec fqbin_to_enum_name(_) -> no_return(). enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'grpc.testing'. %% Whether or not the message names %% are prepended with package name or not. uses_packages() -> true. source_basename() -> "empty.proto". %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension get_all_source_basenames() -> ["empty.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. get_all_proto_names() -> ["empty"]. get_msg_containment("empty") -> [empty]; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("empty") -> 'grpc.testing'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("empty") -> []; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("empty") -> []; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("empty") -> []; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"grpc.testing.Empty">>) -> "empty"; get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). -spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). get_protos_by_pkg_name_as_fqbin(<<"grpc.testing">>) -> ["empty"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). descriptor() -> <<10, 57, 10, 24, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 101, 109, 112, 116, 121, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 7, 10, 5, 69, 109, 112, 116, 121, 98, 6, 112, 114, 111, 116, 111, 51>>. descriptor("empty") -> <<10, 24, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 101, 109, 112, 116, 121, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 7, 10, 5, 69, 109, 112, 116, 121, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor(X) -> error({gpb_error, {badname, X}}). gpb_version_as_string() -> "4.7.1". gpb_version_as_list() -> [4,7,1]. ================================================ FILE: interop/src/grpc_testing_reconnect_service_bhvr.erl ================================================ %%%------------------------------------------------------------------- %% @doc Behaviour to implement for grpc service grpc.testing.ReconnectService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2019-03-09T00:28:54+00:00 and should not be modified manually -module(grpc_testing_reconnect_service_bhvr). %% @doc Unary RPC -callback start(ctx:t(), test_pb:reconnect_params()) -> {ok, test_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc Unary RPC -callback stop(ctx:t(), test_pb:empty()) -> {ok, test_pb:reconnect_info(), ctx:t()} | grpcbox_stream:grpc_error_response(). ================================================ FILE: interop/src/grpc_testing_reconnect_service_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc Client module for grpc service grpc.testing.ReconnectService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2019-03-09T00:28:54+00:00 and should not be modified manually -module(grpc_testing_reconnect_service_client). -compile(export_all). -compile(nowarn_export_all). -include_lib("grpcbox/include/grpcbox.hrl"). -define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). -define(SERVICE, 'grpc.testing.ReconnectService'). -define(PROTO_MODULE, 'test_pb'). -define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). -define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). -define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, message_type=MessageType, marshal_fun=?MARSHAL_FUN(Input), unmarshal_fun=?UNMARSHAL_FUN(Output)}). %% @doc Unary RPC -spec start(test_pb:reconnect_params()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). start(Input) -> start(ctx:new(), Input, #{}). -spec start(ctx:t() | test_pb:reconnect_params(), test_pb:reconnect_params() | grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). start(Ctx, Input) when ?is_ctx(Ctx) -> start(Ctx, Input, #{}); start(Input, Options) -> start(ctx:new(), Input, Options). -spec start(ctx:t(), test_pb:reconnect_params(), grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). start(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.ReconnectService/Start">>, Input, ?DEF(reconnect_params, empty, <<"grpc.testing.ReconnectParams">>), Options). %% @doc Unary RPC -spec stop(test_pb:empty()) -> {ok, test_pb:reconnect_info(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). stop(Input) -> stop(ctx:new(), Input, #{}). -spec stop(ctx:t() | test_pb:empty(), test_pb:empty() | grpcbox_client:options()) -> {ok, test_pb:reconnect_info(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). stop(Ctx, Input) when ?is_ctx(Ctx) -> stop(Ctx, Input, #{}); stop(Input, Options) -> stop(ctx:new(), Input, Options). -spec stop(ctx:t(), test_pb:empty(), grpcbox_client:options()) -> {ok, test_pb:reconnect_info(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). stop(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.ReconnectService/Stop">>, Input, ?DEF(empty, reconnect_info, <<"grpc.testing.Empty">>), Options). ================================================ FILE: interop/src/grpc_testing_test_service.erl ================================================ -module(grpc_testing_test_service). -behaviour(grpc_testing_test_service_bhvr). -export([empty_call/2, unary_call/2, cacheable_unary_call/2, streaming_output_call/2, streaming_input_call/2, full_duplex_call/2, half_duplex_call/2]). -include("grpcbox_interop_tests.hrl"). -spec empty_call(ctx:t(), test_pb:empty()) -> {ok, test_pb:empty()} | grpcbox_stream:grpc_error_response(). empty_call(Ctx, _Empty) -> {ok, #{}, Ctx}. -spec unary_call(ctx:t(), test_pb:simple_request()) -> {ok, test_pb:simple_response()} | grpcbox_stream:grpc_error_response(). unary_call(Ctx, Request=#{response_size := Size}) -> case maps:get(response_status, Request, #{}) of #{code := Code, message := Message} -> {grpc_error, {grpcbox_stream:code_to_status(Code), Message}}; _ -> Metadata = grpcbox_metadata:from_incoming_ctx(Ctx), EchoValue = maps:get(?INITIAL_METADATA_KEY, Metadata, <<>>), EchoTrailer = maps:get(?TRAILING_METADATA_KEY, Metadata, <<>>), Header = grpcbox_metadata:pairs([{?INITIAL_METADATA_KEY, EchoValue}]), Ctx1 = ctx:set(Ctx, ctx_stream_key, grpcbox_stream:send_headers(Ctx, Header)), Trailer = grpcbox_metadata:pairs([{?TRAILING_METADATA_KEY, EchoTrailer}]), Ctx2 = grpcbox_stream:set_trailers(Ctx1, Trailer), Body = << <<0>> || _ <- lists:seq(1, Size) >>, {ok, #{payload => #{type => 'COMPRESSABLE', body => Body }, username => <<"tsloughter">>, oauth_scope => <<"some-scope">> }, Ctx2} end. -spec cacheable_unary_call(ctx:t(), test_pb:simple_request()) -> {ok, test_pb:simple_response()} | grpcbox_stream:grpc_error_response(). cacheable_unary_call(Ctx, _SimpleRequest) -> {ok, #{}, Ctx}. -spec streaming_output_call(test_pb:streaming_output_call_request(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). streaming_output_call(#{response_type := ResponseType, response_parameters := ResponseParameters }, Stream) -> lists:foreach(fun(#{size := Size, interval_us := Interval}) -> timer:sleep(erlang:convert_time_unit(Interval, microsecond, millisecond)), Body = << <<0>> || _ <- lists:seq(1, Size) >>, grpcbox_stream:send(#{payload => #{type => ResponseType, body => Body}}, Stream) end, ResponseParameters), ok. -spec streaming_input_call(reference(), grpcbox_stream:t()) -> {ok, test_pb:streaming_input_call_response()} | grpcbox_stream:grpc_error_response(). streaming_input_call(Ref, GrpcStream) -> streaming_input_call(Ref, #{aggregated_payload_size => 0}, GrpcStream). streaming_input_call(Ref, Data=#{aggregated_payload_size := Size}, GrpcStream) -> receive {Ref, eos} -> {ok, #{aggregated_payload_size => Size}, GrpcStream}; {Ref, #{payload := #{type := _Type, body := Body}}} -> streaming_input_call(Ref, Data#{aggregated_payload_size => Size + size(Body)}, GrpcStream) end. -spec full_duplex_call(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). full_duplex_call(Ref, Stream) -> grpcbox_stream:add_headers([{?INITIAL_METADATA_KEY, ?INITIAL_METADATA_VALUE}], Stream), full_duplex_call_(Ref, Stream). full_duplex_call_(Ref, Stream) -> receive {Ref, eos} -> grpcbox_stream:add_trailers([{?TRAILING_METADATA_KEY, ?TRAILING_METADATA_VALUE}], Stream), ok; {Ref, #{response_status := #{code := Code, message := Message}}} -> grpcbox_stream:error(grpcbox_stream:code_to_status(Code), Message); {Ref, #{response_type := ResponseType, response_parameters := ResponseParameters }} -> lists:foreach(fun(#{size := Size, interval_us := Interval}) -> timer:sleep(erlang:convert_time_unit(Interval, microsecond, millisecond)), Body = << <<0>> || _ <- lists:seq(1, Size) >>, grpcbox_stream:send(#{payload => #{type => ResponseType, body => Body}}, Stream) end, ResponseParameters), full_duplex_call_(Ref, Stream) end. -spec half_duplex_call(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). half_duplex_call(_Ref, _Stream) -> ok. ================================================ FILE: interop/src/grpc_testing_test_service_bhvr.erl ================================================ %%%------------------------------------------------------------------- %% @doc Behaviour to implement for grpc service grpc.testing.TestService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2019-03-09T00:28:54+00:00 and should not be modified manually -module(grpc_testing_test_service_bhvr). %% @doc Unary RPC -callback empty_call(ctx:t(), test_pb:empty()) -> {ok, test_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc Unary RPC -callback unary_call(ctx:t(), test_pb:simple_request()) -> {ok, test_pb:simple_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc Unary RPC -callback cacheable_unary_call(ctx:t(), test_pb:simple_request()) -> {ok, test_pb:simple_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc -callback streaming_output_call(test_pb:streaming_output_call_request(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). %% @doc -callback streaming_input_call(reference(), grpcbox_stream:t()) -> {ok, test_pb:streaming_input_call_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc -callback full_duplex_call(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). %% @doc -callback half_duplex_call(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). %% @doc Unary RPC -callback unimplemented_call(ctx:t(), test_pb:empty()) -> {ok, test_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). ================================================ FILE: interop/src/grpc_testing_test_service_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc Client module for grpc service grpc.testing.TestService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2019-03-09T00:28:54+00:00 and should not be modified manually -module(grpc_testing_test_service_client). -compile(export_all). -compile(nowarn_export_all). -include_lib("grpcbox/include/grpcbox.hrl"). -define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). -define(SERVICE, 'grpc.testing.TestService'). -define(PROTO_MODULE, 'test_pb'). -define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). -define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). -define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, message_type=MessageType, marshal_fun=?MARSHAL_FUN(Input), unmarshal_fun=?UNMARSHAL_FUN(Output)}). %% @doc Unary RPC -spec empty_call(test_pb:empty()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). empty_call(Input) -> empty_call(ctx:new(), Input, #{}). -spec empty_call(ctx:t() | test_pb:empty(), test_pb:empty() | grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). empty_call(Ctx, Input) when ?is_ctx(Ctx) -> empty_call(Ctx, Input, #{}); empty_call(Input, Options) -> empty_call(ctx:new(), Input, Options). -spec empty_call(ctx:t(), test_pb:empty(), grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). empty_call(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.TestService/EmptyCall">>, Input, ?DEF(empty, empty, <<"grpc.testing.Empty">>), Options). %% @doc Unary RPC -spec unary_call(test_pb:simple_request()) -> {ok, test_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unary_call(Input) -> unary_call(ctx:new(), Input, #{}). -spec unary_call(ctx:t() | test_pb:simple_request(), test_pb:simple_request() | grpcbox_client:options()) -> {ok, test_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unary_call(Ctx, Input) when ?is_ctx(Ctx) -> unary_call(Ctx, Input, #{}); unary_call(Input, Options) -> unary_call(ctx:new(), Input, Options). -spec unary_call(ctx:t(), test_pb:simple_request(), grpcbox_client:options()) -> {ok, test_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unary_call(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.TestService/UnaryCall">>, Input, ?DEF(simple_request, simple_response, <<"grpc.testing.SimpleRequest">>), Options). %% @doc Unary RPC -spec cacheable_unary_call(test_pb:simple_request()) -> {ok, test_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). cacheable_unary_call(Input) -> cacheable_unary_call(ctx:new(), Input, #{}). -spec cacheable_unary_call(ctx:t() | test_pb:simple_request(), test_pb:simple_request() | grpcbox_client:options()) -> {ok, test_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). cacheable_unary_call(Ctx, Input) when ?is_ctx(Ctx) -> cacheable_unary_call(Ctx, Input, #{}); cacheable_unary_call(Input, Options) -> cacheable_unary_call(ctx:new(), Input, Options). -spec cacheable_unary_call(ctx:t(), test_pb:simple_request(), grpcbox_client:options()) -> {ok, test_pb:simple_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). cacheable_unary_call(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.TestService/CacheableUnaryCall">>, Input, ?DEF(simple_request, simple_response, <<"grpc.testing.SimpleRequest">>), Options). %% @doc -spec streaming_output_call(test_pb:streaming_output_call_request()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_output_call(Input) -> streaming_output_call(ctx:new(), Input, #{}). -spec streaming_output_call(ctx:t() | test_pb:streaming_output_call_request(), test_pb:streaming_output_call_request() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_output_call(Ctx, Input) when ?is_ctx(Ctx) -> streaming_output_call(Ctx, Input, #{}); streaming_output_call(Input, Options) -> streaming_output_call(ctx:new(), Input, Options). -spec streaming_output_call(ctx:t(), test_pb:streaming_output_call_request(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_output_call(Ctx, Input, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.TestService/StreamingOutputCall">>, Input, ?DEF(streaming_output_call_request, streaming_output_call_response, <<"grpc.testing.StreamingOutputCallRequest">>), Options). %% @doc -spec streaming_input_call() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_input_call() -> streaming_input_call(ctx:new(), #{}). -spec streaming_input_call(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_input_call(Ctx) when ?is_ctx(Ctx) -> streaming_input_call(Ctx, #{}); streaming_input_call(Options) -> streaming_input_call(ctx:new(), Options). -spec streaming_input_call(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_input_call(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.TestService/StreamingInputCall">>, ?DEF(streaming_input_call_request, streaming_input_call_response, <<"grpc.testing.StreamingInputCallRequest">>), Options). %% @doc -spec full_duplex_call() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). full_duplex_call() -> full_duplex_call(ctx:new(), #{}). -spec full_duplex_call(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). full_duplex_call(Ctx) when ?is_ctx(Ctx) -> full_duplex_call(Ctx, #{}); full_duplex_call(Options) -> full_duplex_call(ctx:new(), Options). -spec full_duplex_call(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). full_duplex_call(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.TestService/FullDuplexCall">>, ?DEF(streaming_output_call_request, streaming_output_call_response, <<"grpc.testing.StreamingOutputCallRequest">>), Options). %% @doc -spec half_duplex_call() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). half_duplex_call() -> half_duplex_call(ctx:new(), #{}). -spec half_duplex_call(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). half_duplex_call(Ctx) when ?is_ctx(Ctx) -> half_duplex_call(Ctx, #{}); half_duplex_call(Options) -> half_duplex_call(ctx:new(), Options). -spec half_duplex_call(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). half_duplex_call(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.testing.TestService/HalfDuplexCall">>, ?DEF(streaming_output_call_request, streaming_output_call_response, <<"grpc.testing.StreamingOutputCallRequest">>), Options). %% @doc Unary RPC -spec unimplemented_call(test_pb:empty()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unimplemented_call(Input) -> unimplemented_call(ctx:new(), Input, #{}). -spec unimplemented_call(ctx:t() | test_pb:empty(), test_pb:empty() | grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unimplemented_call(Ctx, Input) when ?is_ctx(Ctx) -> unimplemented_call(Ctx, Input, #{}); unimplemented_call(Input, Options) -> unimplemented_call(ctx:new(), Input, Options). -spec unimplemented_call(ctx:t(), test_pb:empty(), grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unimplemented_call(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.TestService/UnimplementedCall">>, Input, ?DEF(empty, empty, <<"grpc.testing.Empty">>), Options). ================================================ FILE: interop/src/grpc_testing_unimplemented_service_bhvr.erl ================================================ %%%------------------------------------------------------------------- %% @doc Behaviour to implement for grpc service grpc.testing.UnimplementedService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2019-03-09T00:28:54+00:00 and should not be modified manually -module(grpc_testing_unimplemented_service_bhvr). %% @doc Unary RPC -callback unimplemented_call(ctx:t(), test_pb:empty()) -> {ok, test_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). ================================================ FILE: interop/src/grpc_testing_unimplemented_service_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc Client module for grpc service grpc.testing.UnimplementedService. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2019-03-09T00:28:54+00:00 and should not be modified manually -module(grpc_testing_unimplemented_service_client). -compile(export_all). -compile(nowarn_export_all). -include_lib("grpcbox/include/grpcbox.hrl"). -define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). -define(SERVICE, 'grpc.testing.UnimplementedService'). -define(PROTO_MODULE, 'test_pb'). -define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). -define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). -define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, message_type=MessageType, marshal_fun=?MARSHAL_FUN(Input), unmarshal_fun=?UNMARSHAL_FUN(Output)}). %% @doc Unary RPC -spec unimplemented_call(test_pb:empty()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unimplemented_call(Input) -> unimplemented_call(ctx:new(), Input, #{}). -spec unimplemented_call(ctx:t() | test_pb:empty(), test_pb:empty() | grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unimplemented_call(Ctx, Input) when ?is_ctx(Ctx) -> unimplemented_call(Ctx, Input, #{}); unimplemented_call(Input, Options) -> unimplemented_call(ctx:new(), Input, Options). -spec unimplemented_call(ctx:t(), test_pb:empty(), grpcbox_client:options()) -> {ok, test_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). unimplemented_call(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.testing.UnimplementedService/UnimplementedCall">>, Input, ?DEF(empty, empty, <<"grpc.testing.Empty">>), Options). ================================================ FILE: interop/src/messages_pb.erl ================================================ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit %% Generated by gpb_compile version 4.7.1 -module(messages_pb). -export([encode_msg/2, encode_msg/3]). -export([decode_msg/2, decode_msg/3]). -export([merge_msgs/3, merge_msgs/4]). -export([verify_msg/2, verify_msg/3]). -export([get_msg_defs/0]). -export([get_msg_names/0]). -export([get_group_names/0]). -export([get_msg_or_group_names/0]). -export([get_enum_names/0]). -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). -export(['enum_symbol_by_value_grpc.testing.PayloadType'/1, 'enum_value_by_symbol_grpc.testing.PayloadType'/1]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). -export([find_rpc_def/2, fetch_rpc_def/2]). -export([fqbin_to_service_name/1]). -export([service_name_to_fqbin/1]). -export([fqbins_to_service_and_rpc_name/2]). -export([service_and_rpc_name_to_fqbins/2]). -export([fqbin_to_msg_name/1]). -export([msg_name_to_fqbin/1]). -export([fqbin_to_enum_name/1]). -export([enum_name_to_fqbin/1]). -export([get_package_name/0]). -export([uses_packages/0]). -export([source_basename/0]). -export([get_all_source_basenames/0]). -export([get_all_proto_names/0]). -export([get_msg_containment/1]). -export([get_pkg_containment/1]). -export([get_service_containment/1]). -export([get_rpc_containment/1]). -export([get_enum_containment/1]). -export([get_proto_by_msg_name_as_fqbin/1]). -export([get_proto_by_service_name_as_fqbin/1]). -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([descriptor/0, descriptor/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). %% enumerated types -type 'grpc.testing.PayloadType'() :: 'COMPRESSABLE'. -export_type(['grpc.testing.PayloadType'/0]). %% message types -type bool_value() :: #{value => boolean() | 0 | 1 % = 1 }. -type payload() :: #{type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType body => iodata() % = 2 }. -type echo_status() :: #{code => integer(), % = 1, 32 bits message => iodata() % = 2 }. -type simple_request() :: #{response_type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType response_size => integer(), % = 2, 32 bits payload => payload(), % = 3 fill_username => boolean() | 0 | 1, % = 4 fill_oauth_scope => boolean() | 0 | 1, % = 5 response_compressed => bool_value(), % = 6 response_status => echo_status(), % = 7 expect_compressed => bool_value() % = 8 }. -type simple_response() :: #{payload => payload(), % = 1 username => iodata(), % = 2 oauth_scope => iodata() % = 3 }. -type streaming_input_call_request() :: #{payload => payload(), % = 1 expect_compressed => bool_value() % = 2 }. -type streaming_input_call_response() :: #{aggregated_payload_size => integer() % = 1, 32 bits }. -type response_parameters() :: #{size => integer(), % = 1, 32 bits interval_us => integer(), % = 2, 32 bits compressed => bool_value() % = 3 }. -type streaming_output_call_request() :: #{response_type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType response_parameters => [response_parameters()], % = 2 payload => payload(), % = 3 response_status => echo_status() % = 7 }. -type streaming_output_call_response() :: #{payload => payload() % = 1 }. -type reconnect_params() :: #{max_reconnect_backoff_ms => integer() % = 1, 32 bits }. -type reconnect_info() :: #{passed => boolean() | 0 | 1, % = 1 backoff_ms => [integer()] % = 2, 32 bits }. -export_type(['bool_value'/0, 'payload'/0, 'echo_status'/0, 'simple_request'/0, 'simple_response'/0, 'streaming_input_call_request'/0, 'streaming_input_call_response'/0, 'response_parameters'/0, 'streaming_output_call_request'/0, 'streaming_output_call_response'/0, 'reconnect_params'/0, 'reconnect_info'/0]). -spec encode_msg(bool_value() | payload() | echo_status() | simple_request() | simple_response() | streaming_input_call_request() | streaming_input_call_response() | response_parameters() | streaming_output_call_request() | streaming_output_call_response() | reconnect_params() | reconnect_info(), atom()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). -spec encode_msg(bool_value() | payload() | echo_status() | simple_request() | simple_response() | streaming_input_call_request() | streaming_input_call_response() | response_parameters() | streaming_output_call_request() | streaming_output_call_response() | reconnect_params() | reconnect_info(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> case proplists:get_bool(verify, Opts) of true -> verify_msg(Msg, MsgName, Opts); false -> ok end, TrUserData = proplists:get_value(user_data, Opts), case MsgName of bool_value -> encode_msg_bool_value(id(Msg, TrUserData), TrUserData); payload -> encode_msg_payload(id(Msg, TrUserData), TrUserData); echo_status -> encode_msg_echo_status(id(Msg, TrUserData), TrUserData); simple_request -> encode_msg_simple_request(id(Msg, TrUserData), TrUserData); simple_response -> encode_msg_simple_response(id(Msg, TrUserData), TrUserData); streaming_input_call_request -> encode_msg_streaming_input_call_request(id(Msg, TrUserData), TrUserData); streaming_input_call_response -> encode_msg_streaming_input_call_response(id(Msg, TrUserData), TrUserData); response_parameters -> encode_msg_response_parameters(id(Msg, TrUserData), TrUserData); streaming_output_call_request -> encode_msg_streaming_output_call_request(id(Msg, TrUserData), TrUserData); streaming_output_call_response -> encode_msg_streaming_output_call_response(id(Msg, TrUserData), TrUserData); reconnect_params -> encode_msg_reconnect_params(id(Msg, TrUserData), TrUserData); reconnect_info -> encode_msg_reconnect_info(id(Msg, TrUserData), TrUserData) end. encode_msg_bool_value(Msg, TrUserData) -> encode_msg_bool_value(Msg, <<>>, TrUserData). encode_msg_bool_value(#{} = M, Bin, TrUserData) -> case M of #{value := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= false -> Bin; true -> e_type_bool(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_payload(Msg, TrUserData) -> encode_msg_payload(Msg, <<>>, TrUserData). encode_msg_payload(#{} = M, Bin, TrUserData) -> B1 = case M of #{type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, 'MaybeTrUserData') end end; _ -> Bin end, case M of #{body := F2} -> begin TrF2 = id(F2, TrUserData), case iolist_size(TrF2) of 0 -> B1; _ -> e_type_bytes(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_echo_status(Msg, TrUserData) -> encode_msg_echo_status(Msg, <<>>, TrUserData). encode_msg_echo_status(#{} = M, Bin, TrUserData) -> B1 = case M of #{code := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{message := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_simple_request(Msg, TrUserData) -> encode_msg_simple_request(Msg, <<>>, TrUserData). encode_msg_simple_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{response_type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, 'MaybeTrUserData') end end; _ -> Bin end, B2 = case M of #{response_size := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end, B3 = case M of #{payload := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_simple_request_payload(TrF3, <>, TrUserData) end end; _ -> B2 end, B4 = case M of #{fill_username := F4} -> begin TrF4 = id(F4, TrUserData), if TrF4 =:= false -> B3; true -> e_type_bool(TrF4, <>, TrUserData) end end; _ -> B3 end, B5 = case M of #{fill_oauth_scope := F5} -> begin TrF5 = id(F5, TrUserData), if TrF5 =:= false -> B4; true -> e_type_bool(TrF5, <>, TrUserData) end end; _ -> B4 end, B6 = case M of #{response_compressed := F6} -> begin TrF6 = id(F6, TrUserData), if TrF6 =:= undefined -> B5; true -> e_mfield_simple_request_response_compressed(TrF6, <>, TrUserData) end end; _ -> B5 end, B7 = case M of #{response_status := F7} -> begin TrF7 = id(F7, TrUserData), if TrF7 =:= undefined -> B6; true -> e_mfield_simple_request_response_status(TrF7, <>, TrUserData) end end; _ -> B6 end, case M of #{expect_compressed := F8} -> begin TrF8 = id(F8, TrUserData), if TrF8 =:= undefined -> B7; true -> e_mfield_simple_request_expect_compressed(TrF8, <>, TrUserData) end end; _ -> B7 end. encode_msg_simple_response(Msg, TrUserData) -> encode_msg_simple_response(Msg, <<>>, TrUserData). encode_msg_simple_response(#{} = M, Bin, TrUserData) -> B1 = case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_simple_response_payload(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{username := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end, case M of #{oauth_scope := F3} -> begin TrF3 = id(F3, TrUserData), case is_empty_string(TrF3) of true -> B2; false -> e_type_string(TrF3, <>, TrUserData) end end; _ -> B2 end. encode_msg_streaming_input_call_request(Msg, TrUserData) -> encode_msg_streaming_input_call_request(Msg, <<>>, TrUserData). encode_msg_streaming_input_call_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_streaming_input_call_request_payload(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{expect_compressed := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= undefined -> B1; true -> e_mfield_streaming_input_call_request_expect_compressed(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_streaming_input_call_response(Msg, TrUserData) -> encode_msg_streaming_input_call_response(Msg, <<>>, TrUserData). encode_msg_streaming_input_call_response(#{} = M, Bin, TrUserData) -> case M of #{aggregated_payload_size := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_response_parameters(Msg, TrUserData) -> encode_msg_response_parameters(Msg, <<>>, TrUserData). encode_msg_response_parameters(#{} = M, Bin, TrUserData) -> B1 = case M of #{size := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{interval_us := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end, case M of #{compressed := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_response_parameters_compressed(TrF3, <>, TrUserData) end end; _ -> B2 end. encode_msg_streaming_output_call_request(Msg, TrUserData) -> encode_msg_streaming_output_call_request(Msg, <<>>, TrUserData). encode_msg_streaming_output_call_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{response_type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, 'MaybeTrUserData') end end; _ -> Bin end, B2 = case M of #{response_parameters := F2} -> TrF2 = id(F2, TrUserData), if TrF2 == [] -> B1; true -> e_field_streaming_output_call_request_response_parameters(TrF2, B1, TrUserData) end; _ -> B1 end, B3 = case M of #{payload := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_streaming_output_call_request_payload(TrF3, <>, TrUserData) end end; _ -> B2 end, case M of #{response_status := F4} -> begin TrF4 = id(F4, TrUserData), if TrF4 =:= undefined -> B3; true -> e_mfield_streaming_output_call_request_response_status(TrF4, <>, TrUserData) end end; _ -> B3 end. encode_msg_streaming_output_call_response(Msg, TrUserData) -> encode_msg_streaming_output_call_response(Msg, <<>>, TrUserData). encode_msg_streaming_output_call_response(#{} = M, Bin, TrUserData) -> case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_streaming_output_call_response_payload(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_reconnect_params(Msg, TrUserData) -> encode_msg_reconnect_params(Msg, <<>>, TrUserData). encode_msg_reconnect_params(#{} = M, Bin, TrUserData) -> case M of #{max_reconnect_backoff_ms := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_reconnect_info(Msg, TrUserData) -> encode_msg_reconnect_info(Msg, <<>>, TrUserData). encode_msg_reconnect_info(#{} = M, Bin, TrUserData) -> B1 = case M of #{passed := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= false -> Bin; true -> e_type_bool(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{backoff_ms := F2} -> TrF2 = id(F2, TrUserData), if TrF2 == [] -> B1; true -> e_field_reconnect_info_backoff_ms(TrF2, B1, TrUserData) end; _ -> B1 end. e_mfield_simple_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_response_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_response_status(Msg, Bin, TrUserData) -> SubBin = encode_msg_echo_status(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_expect_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_response_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_input_call_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_input_call_request_expect_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_response_parameters_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_request_response_parameters(Msg, Bin, TrUserData) -> SubBin = encode_msg_response_parameters(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_streaming_output_call_request_response_parameters([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, Bin3 = e_mfield_streaming_output_call_request_response_parameters(id(Elem, TrUserData), Bin2, TrUserData), e_field_streaming_output_call_request_response_parameters(Rest, Bin3, TrUserData); e_field_streaming_output_call_request_response_parameters([], Bin, _TrUserData) -> Bin. e_mfield_streaming_output_call_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_request_response_status(Msg, Bin, TrUserData) -> SubBin = encode_msg_echo_status(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_response_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_reconnect_info_backoff_ms(Elems, Bin, TrUserData) when Elems =/= [] -> SubBin = e_pfield_reconnect_info_backoff_ms(Elems, <<>>, TrUserData), Bin2 = <>, Bin3 = e_varint(byte_size(SubBin), Bin2), <>; e_field_reconnect_info_backoff_ms([], Bin, _TrUserData) -> Bin. e_pfield_reconnect_info_backoff_ms([Value | Rest], Bin, TrUserData) -> Bin2 = e_type_int32(id(Value, TrUserData), Bin, TrUserData), e_pfield_reconnect_info_backoff_ms(Rest, Bin2, TrUserData); e_pfield_reconnect_info_backoff_ms([], Bin, _TrUserData) -> Bin. 'e_enum_grpc.testing.PayloadType'('COMPRESSABLE', Bin, _TrUserData) -> <>; 'e_enum_grpc.testing.PayloadType'(V, Bin, _TrUserData) -> e_varint(V, Bin). -compile({nowarn_unused_function,e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). e_type_bool(true, Bin, _TrUserData) -> <>; e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_string/3}). e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -compile({nowarn_unused_function,e_type_bytes/3}). e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). e_type_float(V, Bin, _) when is_number(V) -> <>; e_type_float(infinity, Bin, _) -> <>; e_type_float('-infinity', Bin, _) -> <>; e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). e_type_double(V, Bin, _) when is_number(V) -> <>; e_type_double(infinity, Bin, _) -> <>; e_type_double('-infinity', Bin, _) -> <>; e_type_double(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). -compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, e_varint(N bsr 7, Bin2). is_empty_string("") -> true; is_empty_string(<<>>) -> true; is_empty_string(L) when is_list(L) -> not string_has_chars(L); is_empty_string(B) when is_binary(B) -> false. string_has_chars([C | _]) when is_integer(C) -> true; string_has_chars([H | T]) -> case string_has_chars(H) of true -> true; false -> string_has_chars(T) end; string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; string_has_chars(C) when is_integer(C) -> true; string_has_chars(<<>>) -> false; string_has_chars([]) -> false. decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), decode_msg_1_catch(Bin, MsgName, TrUserData). -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason -> StackTrace = erlang:get_stacktrace(), error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. decode_msg_2_doit(bool_value, Bin, TrUserData) -> id(decode_msg_bool_value(Bin, TrUserData), TrUserData); decode_msg_2_doit(payload, Bin, TrUserData) -> id(decode_msg_payload(Bin, TrUserData), TrUserData); decode_msg_2_doit(echo_status, Bin, TrUserData) -> id(decode_msg_echo_status(Bin, TrUserData), TrUserData); decode_msg_2_doit(simple_request, Bin, TrUserData) -> id(decode_msg_simple_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(simple_response, Bin, TrUserData) -> id(decode_msg_simple_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_input_call_request, Bin, TrUserData) -> id(decode_msg_streaming_input_call_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_input_call_response, Bin, TrUserData) -> id(decode_msg_streaming_input_call_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(response_parameters, Bin, TrUserData) -> id(decode_msg_response_parameters(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_output_call_request, Bin, TrUserData) -> id(decode_msg_streaming_output_call_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_output_call_response, Bin, TrUserData) -> id(decode_msg_streaming_output_call_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(reconnect_params, Bin, TrUserData) -> id(decode_msg_reconnect_params(Bin, TrUserData), TrUserData); decode_msg_2_doit(reconnect_info, Bin, TrUserData) -> id(decode_msg_reconnect_info(Bin, TrUserData), TrUserData). decode_msg_bool_value(Bin, TrUserData) -> dfp_read_field_def_bool_value(Bin, 0, 0, id(false, TrUserData), TrUserData). dfp_read_field_def_bool_value(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_bool_value_value(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_bool_value(<<>>, 0, 0, F@_1, _) -> #{value => F@_1}; dfp_read_field_def_bool_value(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_bool_value(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_bool_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_bool_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_bool_value(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_bool_value_value(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_bool_value(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_bool_value(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_bool_value(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_bool_value(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_bool_value(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_bool_value(<<>>, 0, 0, F@_1, _) -> #{value => F@_1}. d_field_bool_value_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_bool_value_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_bool_value_value(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_bool_value(RestF, 0, 0, NewFValue, TrUserData). skip_varint_bool_value(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_bool_value(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_bool_value(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_bool_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_bool_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_bool_value(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_bool_value(Rest2, 0, 0, F@_1, TrUserData). skip_group_bool_value(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_bool_value(Rest, 0, Z2, F@_1, TrUserData). skip_32_bool_value(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). skip_64_bool_value(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_payload(Bin, TrUserData) -> dfp_read_field_def_payload(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_payload(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_payload_type(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_payload(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_payload_body(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_payload(<<>>, 0, 0, F@_1, F@_2, _) -> #{type => F@_1, body => F@_2}; dfp_read_field_def_payload(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_payload(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_payload_type(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_payload_body(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_payload(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_payload(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_payload(<<>>, 0, 0, F@_1, F@_2, _) -> #{type => F@_1, body => F@_2}. d_field_payload_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_payload_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_payload_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_payload(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_payload_body(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_payload_body(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_payload_body(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_payload(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_payload(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_payload(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_payload(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_payload(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_payload(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_payload(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_payload(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_echo_status(Bin, TrUserData) -> dfp_read_field_def_echo_status(Bin, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_echo_status(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_echo_status_code(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_echo_status(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_echo_status_message(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_echo_status(<<>>, 0, 0, F@_1, F@_2, _) -> #{code => F@_1, message => F@_2}; dfp_read_field_def_echo_status(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_echo_status(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_echo_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_echo_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_echo_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_echo_status_code(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_echo_status_message(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_echo_status(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_echo_status(<<>>, 0, 0, F@_1, F@_2, _) -> #{code => F@_1, message => F@_2}. d_field_echo_status_code(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_echo_status_code(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_echo_status_code(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_echo_status(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_echo_status_message(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_echo_status_message(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_echo_status_message(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_echo_status(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_echo_status(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_echo_status(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_echo_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_echo_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_echo_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_echo_status(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_echo_status(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_echo_status(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_echo_status(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_echo_status(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_simple_request(Bin, TrUserData) -> dfp_read_field_def_simple_request(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id(0, TrUserData), id('$undef', TrUserData), id(false, TrUserData), id(false, TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_simple_request(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_type(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_size(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_fill_username(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<40, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_fill_oauth_scope(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<50, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_status(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<66, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_expect_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> S1 = #{response_type => F@_1, response_size => F@_2, fill_username => F@_4, fill_oauth_scope => F@_5}, S2 = if F@_3 == '$undef' -> S1; true -> S1#{payload => F@_3} end, S3 = if F@_6 == '$undef' -> S2; true -> S2#{response_compressed => F@_6} end, S4 = if F@_7 == '$undef' -> S3; true -> S3#{response_status => F@_7} end, if F@_8 == '$undef' -> S4; true -> S4#{expect_compressed => F@_8} end; dfp_read_field_def_simple_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dg_read_field_def_simple_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). dg_read_field_def_simple_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 32 - 7 -> dg_read_field_def_simple_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dg_read_field_def_simple_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_simple_request_response_type(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 16 -> d_field_simple_request_response_size(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 26 -> d_field_simple_request_payload(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 32 -> d_field_simple_request_fill_username(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 40 -> d_field_simple_request_fill_oauth_scope(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 50 -> d_field_simple_request_response_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 58 -> d_field_simple_request_response_status(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 66 -> d_field_simple_request_expect_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 1 -> skip_64_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 2 -> skip_length_delimited_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 3 -> skip_group_simple_request(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 5 -> skip_32_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) end end; dg_read_field_def_simple_request(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> S1 = #{response_type => F@_1, response_size => F@_2, fill_username => F@_4, fill_oauth_scope => F@_5}, S2 = if F@_3 == '$undef' -> S1; true -> S1#{payload => F@_3} end, S3 = if F@_6 == '$undef' -> S2; true -> S2#{response_compressed => F@_6} end, S4 = if F@_7 == '$undef' -> S3; true -> S3#{response_status => F@_7} end, if F@_8 == '$undef' -> S4; true -> S4#{expect_compressed => F@_8} end. d_field_simple_request_response_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_response_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_size(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_size(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_fill_username(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_fill_username(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_fill_username(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_fill_oauth_scope(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_fill_oauth_scope(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_fill_oauth_scope(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_response_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, Prev, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, F@_7, F@_8, TrUserData). d_field_simple_request_response_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, Prev, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_echo_status(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, if Prev == '$undef' -> NewFValue; true -> merge_msg_echo_status(Prev, NewFValue, TrUserData) end, F@_8, TrUserData). d_field_simple_request_expect_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_expect_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_expect_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_simple_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> skip_varint_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); skip_varint_simple_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_length_delimited_simple_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> skip_length_delimited_simple_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); skip_length_delimited_simple_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_simple_request(Rest2, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_group_simple_request(Bin, FNum, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_simple_request(Rest, 0, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_32_simple_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_64_simple_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). decode_msg_simple_response(Bin, TrUserData) -> dfp_read_field_def_simple_response(Bin, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_simple_response(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_username(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_oauth_scope(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{username => F@_2, oauth_scope => F@_3}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end; dfp_read_field_def_simple_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_simple_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). dg_read_field_def_simple_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_simple_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_simple_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_simple_response_payload(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 18 -> d_field_simple_response_username(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_simple_response_oauth_scope(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_simple_response(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, TrUserData); 5 -> skip_32_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData) end end; dg_read_field_def_simple_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{username => F@_2, oauth_scope => F@_3}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end. d_field_simple_response_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_2, F@_3, TrUserData). d_field_simple_response_username(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_username(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_username(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, F@_1, NewFValue, F@_3, TrUserData). d_field_simple_response_oauth_scope(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_oauth_scope(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_oauth_scope(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, F@_1, F@_2, NewFValue, TrUserData). skip_varint_simple_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); skip_varint_simple_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_length_delimited_simple_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_simple_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_simple_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_simple_response(Rest2, 0, 0, F@_1, F@_2, F@_3, TrUserData). skip_group_simple_response(Bin, FNum, Z2, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_simple_response(Rest, 0, Z2, F@_1, F@_2, F@_3, TrUserData). skip_32_simple_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_64_simple_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). decode_msg_streaming_input_call_request(Bin, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Bin, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_input_call_request(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_streaming_input_call_request_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_streaming_input_call_request(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_streaming_input_call_request_expect_compressed(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_streaming_input_call_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{expect_compressed => F@_2} end; dfp_read_field_def_streaming_input_call_request(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_streaming_input_call_request(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_streaming_input_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_input_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_streaming_input_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_streaming_input_call_request_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_streaming_input_call_request_expect_compressed(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_streaming_input_call_request(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_streaming_input_call_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{expect_compressed => F@_2} end. d_field_streaming_input_call_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_streaming_input_call_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_streaming_input_call_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_input_call_request(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_2, TrUserData). d_field_streaming_input_call_request_expect_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_streaming_input_call_request_expect_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_streaming_input_call_request_expect_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_input_call_request(RestF, 0, 0, F@_1, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_input_call_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_streaming_input_call_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_streaming_input_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_streaming_input_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_streaming_input_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_input_call_request(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_streaming_input_call_request(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_input_call_request(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_streaming_input_call_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_streaming_input_call_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_streaming_input_call_response(Bin, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Bin, 0, 0, id(0, TrUserData), TrUserData). dfp_read_field_def_streaming_input_call_response(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_streaming_input_call_response(<<>>, 0, 0, F@_1, _) -> #{aggregated_payload_size => F@_1}; dfp_read_field_def_streaming_input_call_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_streaming_input_call_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_streaming_input_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_input_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_streaming_input_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_streaming_input_call_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_streaming_input_call_response(<<>>, 0, 0, F@_1, _) -> #{aggregated_payload_size => F@_1}. d_field_streaming_input_call_response_aggregated_payload_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_streaming_input_call_response_aggregated_payload_size(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_streaming_input_call_response(RestF, 0, 0, NewFValue, TrUserData). skip_varint_streaming_input_call_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_streaming_input_call_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_streaming_input_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_streaming_input_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_streaming_input_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_input_call_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_streaming_input_call_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_input_call_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_streaming_input_call_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_streaming_input_call_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_response_parameters(Bin, TrUserData) -> dfp_read_field_def_response_parameters(Bin, 0, 0, id(0, TrUserData), id(0, TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_response_parameters(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_size(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_interval_us(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{size => F@_1, interval_us => F@_2}, if F@_3 == '$undef' -> S1; true -> S1#{compressed => F@_3} end; dfp_read_field_def_response_parameters(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_response_parameters(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). dg_read_field_def_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_response_parameters_size(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 16 -> d_field_response_parameters_interval_us(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_response_parameters_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_response_parameters(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, TrUserData); 5 -> skip_32_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData) end end; dg_read_field_def_response_parameters(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{size => F@_1, interval_us => F@_2}, if F@_3 == '$undef' -> S1; true -> S1#{compressed => F@_3} end. d_field_response_parameters_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_size(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_size(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_response_parameters(RestF, 0, 0, NewFValue, F@_2, F@_3, TrUserData). d_field_response_parameters_interval_us(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_interval_us(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_interval_us(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_response_parameters(RestF, 0, 0, F@_1, NewFValue, F@_3, TrUserData). d_field_response_parameters_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_response_parameters(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_response_parameters(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); skip_varint_response_parameters(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_length_delimited_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_response_parameters(Rest2, 0, 0, F@_1, F@_2, F@_3, TrUserData). skip_group_response_parameters(Bin, FNum, Z2, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_response_parameters(Rest, 0, Z2, F@_1, F@_2, F@_3, TrUserData). skip_32_response_parameters(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_64_response_parameters(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). decode_msg_streaming_output_call_request(Bin, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_output_call_request(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_type(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_status(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<>>, 0, 0, F@_1, R1, F@_3, F@_4, TrUserData) -> S1 = #{response_type => F@_1}, S2 = if R1 == '$undef' -> S1; true -> S1#{response_parameters => lists_reverse(R1, TrUserData)} end, S3 = if F@_3 == '$undef' -> S2; true -> S2#{payload => F@_3} end, if F@_4 == '$undef' -> S3; true -> S3#{response_status => F@_4} end; dfp_read_field_def_streaming_output_call_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_streaming_output_call_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). dg_read_field_def_streaming_output_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_output_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); dg_read_field_def_streaming_output_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_streaming_output_call_request_response_type(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 18 -> d_field_streaming_output_call_request_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 26 -> d_field_streaming_output_call_request_payload(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 58 -> d_field_streaming_output_call_request_response_status(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 1 -> skip_64_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 2 -> skip_length_delimited_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 3 -> skip_group_streaming_output_call_request(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 5 -> skip_32_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData) end end; dg_read_field_def_streaming_output_call_request(<<>>, 0, 0, F@_1, R1, F@_3, F@_4, TrUserData) -> S1 = #{response_type => F@_1}, S2 = if R1 == '$undef' -> S1; true -> S1#{response_parameters => lists_reverse(R1, TrUserData)} end, S3 = if F@_3 == '$undef' -> S2; true -> S2#{payload => F@_3} end, if F@_4 == '$undef' -> S3; true -> S3#{response_status => F@_4} end. d_field_streaming_output_call_request_response_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, TrUserData). d_field_streaming_output_call_request_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_response_parameters(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, cons(NewFValue, Prev, TrUserData), F@_3, F@_4, TrUserData). d_field_streaming_output_call_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, F@_4, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_4, TrUserData). d_field_streaming_output_call_request_response_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_echo_status(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, F@_2, F@_3, if Prev == '$undef' -> NewFValue; true -> merge_msg_echo_status(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_output_call_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_varint_streaming_output_call_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_length_delimited_streaming_output_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_streaming_output_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_length_delimited_streaming_output_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_output_call_request(Rest2, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_group_streaming_output_call_request(Bin, FNum, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_output_call_request(Rest, 0, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_32_streaming_output_call_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_64_streaming_output_call_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). decode_msg_streaming_output_call_response(Bin, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Bin, 0, 0, id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_output_call_response(<<10, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_streaming_output_call_response_payload(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_streaming_output_call_response(<<>>, 0, 0, F@_1, _) -> S1 = #{}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end; dfp_read_field_def_streaming_output_call_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_streaming_output_call_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_streaming_output_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_output_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_streaming_output_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_streaming_output_call_response_payload(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_streaming_output_call_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_streaming_output_call_response(<<>>, 0, 0, F@_1, _) -> S1 = #{}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end. d_field_streaming_output_call_response_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_streaming_output_call_response_payload(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_streaming_output_call_response_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_response(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_output_call_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_streaming_output_call_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_streaming_output_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_streaming_output_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_streaming_output_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_output_call_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_streaming_output_call_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_output_call_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_streaming_output_call_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_streaming_output_call_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_reconnect_params(Bin, TrUserData) -> dfp_read_field_def_reconnect_params(Bin, 0, 0, id(0, TrUserData), TrUserData). dfp_read_field_def_reconnect_params(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_reconnect_params(<<>>, 0, 0, F@_1, _) -> #{max_reconnect_backoff_ms => F@_1}; dfp_read_field_def_reconnect_params(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_reconnect_params(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_reconnect_params(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_reconnect_params(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_reconnect_params(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_reconnect_params(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_reconnect_params(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_reconnect_params(<<>>, 0, 0, F@_1, _) -> #{max_reconnect_backoff_ms => F@_1}. d_field_reconnect_params_max_reconnect_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_reconnect_params_max_reconnect_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_reconnect_params(RestF, 0, 0, NewFValue, TrUserData). skip_varint_reconnect_params(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_reconnect_params(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_reconnect_params(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_reconnect_params(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_reconnect_params(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_reconnect_params(Rest2, 0, 0, F@_1, TrUserData). skip_group_reconnect_params(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_reconnect_params(Rest, 0, Z2, F@_1, TrUserData). skip_32_reconnect_params(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). skip_64_reconnect_params(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_reconnect_info(Bin, TrUserData) -> dfp_read_field_def_reconnect_info(Bin, 0, 0, id(false, TrUserData), id([], TrUserData), TrUserData). dfp_read_field_def_reconnect_info(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_reconnect_info_passed(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_pfield_reconnect_info_backoff_ms(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_reconnect_info_backoff_ms(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{passed => F@_1, backoff_ms => lists_reverse(R1, TrUserData)}; dfp_read_field_def_reconnect_info(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_reconnect_info(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_reconnect_info(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_reconnect_info(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_reconnect_info(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_reconnect_info_passed(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_pfield_reconnect_info_backoff_ms(Rest, 0, 0, F@_1, F@_2, TrUserData); 16 -> d_field_reconnect_info_backoff_ms(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_reconnect_info(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_reconnect_info(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{passed => F@_1, backoff_ms => lists_reverse(R1, TrUserData)}. d_field_reconnect_info_passed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_reconnect_info_passed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_reconnect_info_passed(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_reconnect_info(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_reconnect_info(RestF, 0, 0, F@_1, cons(NewFValue, Prev, TrUserData), TrUserData). d_pfield_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_pfield_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_pfield_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, E, TrUserData) -> Len = X bsl N + Acc, <> = Rest, NewSeq = d_packed_field_reconnect_info_backoff_ms(PackedBytes, 0, 0, E, TrUserData), dfp_read_field_def_reconnect_info(Rest2, 0, 0, F@_1, NewSeq, TrUserData). d_packed_field_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) when N < 57 -> d_packed_field_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, AccSeq, TrUserData); d_packed_field_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, d_packed_field_reconnect_info_backoff_ms(RestF, 0, 0, [NewFValue | AccSeq], TrUserData); d_packed_field_reconnect_info_backoff_ms(<<>>, 0, 0, AccSeq, _) -> AccSeq. skip_varint_reconnect_info(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_reconnect_info(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_reconnect_info(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_reconnect_info(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_reconnect_info(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_reconnect_info(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_reconnect_info(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_reconnect_info(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_reconnect_info(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_reconnect_info(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). 'd_enum_grpc.testing.PayloadType'(0) -> 'COMPRESSABLE'; 'd_enum_grpc.testing.PayloadType'(V) -> V. read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, {Group, Rest}. %% Like skipping over fields, but record the total length, %% Each field is <(FieldNum bsl 3) bor FieldType> ++ %% Record the length because varints may be non-optimally encoded. %% %% Groups can be nested, but assume the same FieldNum cannot be nested %% because group field numbers are shared with the rest of the fields %% numbers. Thus we can search just for an group-end with the same %% field number. %% %% (The only time the same group field number could occur would %% be in a nested sub message, but then it would be inside a %% length-delimited entry, which we skip-read by length.) read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) when N < (32-7) -> read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) -> Key = X bsl N + Acc, TagLen1 = TagLen + 1, case {Key bsr 3, Key band 7} of {FieldNum, 4} -> % 4 = group_end {NumBytes, TagLen1}; {_, 0} -> % 0 = varint read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); {_, 1} -> % 1 = bits64 <<_:64, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); {_, 2} -> % 2 = length_delimited read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); {_, 3} -> % 3 = group_start read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 4} -> % 4 = group_end read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 5} -> % 5 = bits32 <<_:32, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) end. read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) when N < (64-7) -> read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) when N < (64-7) -> read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> Len = X bsl N + Acc, NumBytes1 = NumBytes + 1, <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of bool_value -> merge_msg_bool_value(Prev, New, TrUserData); payload -> merge_msg_payload(Prev, New, TrUserData); echo_status -> merge_msg_echo_status(Prev, New, TrUserData); simple_request -> merge_msg_simple_request(Prev, New, TrUserData); simple_response -> merge_msg_simple_response(Prev, New, TrUserData); streaming_input_call_request -> merge_msg_streaming_input_call_request(Prev, New, TrUserData); streaming_input_call_response -> merge_msg_streaming_input_call_response(Prev, New, TrUserData); response_parameters -> merge_msg_response_parameters(Prev, New, TrUserData); streaming_output_call_request -> merge_msg_streaming_output_call_request(Prev, New, TrUserData); streaming_output_call_response -> merge_msg_streaming_output_call_response(Prev, New, TrUserData); reconnect_params -> merge_msg_reconnect_params(Prev, New, TrUserData); reconnect_info -> merge_msg_reconnect_info(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_bool_value/3}). merge_msg_bool_value(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{value := NFvalue}} -> S1#{value => NFvalue}; {#{value := PFvalue}, _} -> S1#{value => PFvalue}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_payload/3}). merge_msg_payload(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{type := NFtype}} -> S1#{type => NFtype}; {#{type := PFtype}, _} -> S1#{type => PFtype}; _ -> S1 end, case {PMsg, NMsg} of {_, #{body := NFbody}} -> S2#{body => NFbody}; {#{body := PFbody}, _} -> S2#{body => PFbody}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_echo_status/3}). merge_msg_echo_status(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{code := NFcode}} -> S1#{code => NFcode}; {#{code := PFcode}, _} -> S1#{code => PFcode}; _ -> S1 end, case {PMsg, NMsg} of {_, #{message := NFmessage}} -> S2#{message => NFmessage}; {#{message := PFmessage}, _} -> S2#{message => PFmessage}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_simple_request/3}). merge_msg_simple_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{response_type := NFresponse_type}} -> S1#{response_type => NFresponse_type}; {#{response_type := PFresponse_type}, _} -> S1#{response_type => PFresponse_type}; _ -> S1 end, S3 = case {PMsg, NMsg} of {_, #{response_size := NFresponse_size}} -> S2#{response_size => NFresponse_size}; {#{response_size := PFresponse_size}, _} -> S2#{response_size => PFresponse_size}; _ -> S2 end, S4 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S3#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S3#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S3#{payload => PFpayload}; {_, _} -> S3 end, S5 = case {PMsg, NMsg} of {_, #{fill_username := NFfill_username}} -> S4#{fill_username => NFfill_username}; {#{fill_username := PFfill_username}, _} -> S4#{fill_username => PFfill_username}; _ -> S4 end, S6 = case {PMsg, NMsg} of {_, #{fill_oauth_scope := NFfill_oauth_scope}} -> S5#{fill_oauth_scope => NFfill_oauth_scope}; {#{fill_oauth_scope := PFfill_oauth_scope}, _} -> S5#{fill_oauth_scope => PFfill_oauth_scope}; _ -> S5 end, S7 = case {PMsg, NMsg} of {#{response_compressed := PFresponse_compressed}, #{response_compressed := NFresponse_compressed}} -> S6#{response_compressed => merge_msg_bool_value(PFresponse_compressed, NFresponse_compressed, TrUserData)}; {_, #{response_compressed := NFresponse_compressed}} -> S6#{response_compressed => NFresponse_compressed}; {#{response_compressed := PFresponse_compressed}, _} -> S6#{response_compressed => PFresponse_compressed}; {_, _} -> S6 end, S8 = case {PMsg, NMsg} of {#{response_status := PFresponse_status}, #{response_status := NFresponse_status}} -> S7#{response_status => merge_msg_echo_status(PFresponse_status, NFresponse_status, TrUserData)}; {_, #{response_status := NFresponse_status}} -> S7#{response_status => NFresponse_status}; {#{response_status := PFresponse_status}, _} -> S7#{response_status => PFresponse_status}; {_, _} -> S7 end, case {PMsg, NMsg} of {#{expect_compressed := PFexpect_compressed}, #{expect_compressed := NFexpect_compressed}} -> S8#{expect_compressed => merge_msg_bool_value(PFexpect_compressed, NFexpect_compressed, TrUserData)}; {_, #{expect_compressed := NFexpect_compressed}} -> S8#{expect_compressed => NFexpect_compressed}; {#{expect_compressed := PFexpect_compressed}, _} -> S8#{expect_compressed => PFexpect_compressed}; {_, _} -> S8 end. -compile({nowarn_unused_function,merge_msg_simple_response/3}). merge_msg_simple_response(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end, S3 = case {PMsg, NMsg} of {_, #{username := NFusername}} -> S2#{username => NFusername}; {#{username := PFusername}, _} -> S2#{username => PFusername}; _ -> S2 end, case {PMsg, NMsg} of {_, #{oauth_scope := NFoauth_scope}} -> S3#{oauth_scope => NFoauth_scope}; {#{oauth_scope := PFoauth_scope}, _} -> S3#{oauth_scope => PFoauth_scope}; _ -> S3 end. -compile({nowarn_unused_function,merge_msg_streaming_input_call_request/3}). merge_msg_streaming_input_call_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end, case {PMsg, NMsg} of {#{expect_compressed := PFexpect_compressed}, #{expect_compressed := NFexpect_compressed}} -> S2#{expect_compressed => merge_msg_bool_value(PFexpect_compressed, NFexpect_compressed, TrUserData)}; {_, #{expect_compressed := NFexpect_compressed}} -> S2#{expect_compressed => NFexpect_compressed}; {#{expect_compressed := PFexpect_compressed}, _} -> S2#{expect_compressed => PFexpect_compressed}; {_, _} -> S2 end. -compile({nowarn_unused_function,merge_msg_streaming_input_call_response/3}). merge_msg_streaming_input_call_response(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{aggregated_payload_size := NFaggregated_payload_size}} -> S1#{aggregated_payload_size => NFaggregated_payload_size}; {#{aggregated_payload_size := PFaggregated_payload_size}, _} -> S1#{aggregated_payload_size => PFaggregated_payload_size}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_response_parameters/3}). merge_msg_response_parameters(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{size := NFsize}} -> S1#{size => NFsize}; {#{size := PFsize}, _} -> S1#{size => PFsize}; _ -> S1 end, S3 = case {PMsg, NMsg} of {_, #{interval_us := NFinterval_us}} -> S2#{interval_us => NFinterval_us}; {#{interval_us := PFinterval_us}, _} -> S2#{interval_us => PFinterval_us}; _ -> S2 end, case {PMsg, NMsg} of {#{compressed := PFcompressed}, #{compressed := NFcompressed}} -> S3#{compressed => merge_msg_bool_value(PFcompressed, NFcompressed, TrUserData)}; {_, #{compressed := NFcompressed}} -> S3#{compressed => NFcompressed}; {#{compressed := PFcompressed}, _} -> S3#{compressed => PFcompressed}; {_, _} -> S3 end. -compile({nowarn_unused_function,merge_msg_streaming_output_call_request/3}). merge_msg_streaming_output_call_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{response_type := NFresponse_type}} -> S1#{response_type => NFresponse_type}; {#{response_type := PFresponse_type}, _} -> S1#{response_type => PFresponse_type}; _ -> S1 end, S3 = case {PMsg, NMsg} of {#{response_parameters := PFresponse_parameters}, #{response_parameters := NFresponse_parameters}} -> S2#{response_parameters => 'erlang_++'(PFresponse_parameters, NFresponse_parameters, TrUserData)}; {_, #{response_parameters := NFresponse_parameters}} -> S2#{response_parameters => NFresponse_parameters}; {#{response_parameters := PFresponse_parameters}, _} -> S2#{response_parameters => PFresponse_parameters}; {_, _} -> S2 end, S4 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S3#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S3#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S3#{payload => PFpayload}; {_, _} -> S3 end, case {PMsg, NMsg} of {#{response_status := PFresponse_status}, #{response_status := NFresponse_status}} -> S4#{response_status => merge_msg_echo_status(PFresponse_status, NFresponse_status, TrUserData)}; {_, #{response_status := NFresponse_status}} -> S4#{response_status => NFresponse_status}; {#{response_status := PFresponse_status}, _} -> S4#{response_status => PFresponse_status}; {_, _} -> S4 end. -compile({nowarn_unused_function,merge_msg_streaming_output_call_response/3}). merge_msg_streaming_output_call_response(PMsg, NMsg, TrUserData) -> S1 = #{}, case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_reconnect_params/3}). merge_msg_reconnect_params(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{max_reconnect_backoff_ms := NFmax_reconnect_backoff_ms}} -> S1#{max_reconnect_backoff_ms => NFmax_reconnect_backoff_ms}; {#{max_reconnect_backoff_ms := PFmax_reconnect_backoff_ms}, _} -> S1#{max_reconnect_backoff_ms => PFmax_reconnect_backoff_ms}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_reconnect_info/3}). merge_msg_reconnect_info(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{passed := NFpassed}} -> S1#{passed => NFpassed}; {#{passed := PFpassed}, _} -> S1#{passed => PFpassed}; _ -> S1 end, case {PMsg, NMsg} of {#{backoff_ms := PFbackoff_ms}, #{backoff_ms := NFbackoff_ms}} -> S2#{backoff_ms => 'erlang_++'(PFbackoff_ms, NFbackoff_ms, TrUserData)}; {_, #{backoff_ms := NFbackoff_ms}} -> S2#{backoff_ms => NFbackoff_ms}; {#{backoff_ms := PFbackoff_ms}, _} -> S2#{backoff_ms => PFbackoff_ms}; {_, _} -> S2 end. verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of bool_value -> v_msg_bool_value(Msg, [MsgName], TrUserData); payload -> v_msg_payload(Msg, [MsgName], TrUserData); echo_status -> v_msg_echo_status(Msg, [MsgName], TrUserData); simple_request -> v_msg_simple_request(Msg, [MsgName], TrUserData); simple_response -> v_msg_simple_response(Msg, [MsgName], TrUserData); streaming_input_call_request -> v_msg_streaming_input_call_request(Msg, [MsgName], TrUserData); streaming_input_call_response -> v_msg_streaming_input_call_response(Msg, [MsgName], TrUserData); response_parameters -> v_msg_response_parameters(Msg, [MsgName], TrUserData); streaming_output_call_request -> v_msg_streaming_output_call_request(Msg, [MsgName], TrUserData); streaming_output_call_response -> v_msg_streaming_output_call_response(Msg, [MsgName], TrUserData); reconnect_params -> v_msg_reconnect_params(Msg, [MsgName], TrUserData); reconnect_info -> v_msg_reconnect_info(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_bool_value/3}). -dialyzer({nowarn_function,v_msg_bool_value/3}). v_msg_bool_value(#{} = M, Path, TrUserData) -> case M of #{value := F1} -> v_type_bool(F1, [value | Path], TrUserData); _ -> ok end, lists:foreach(fun (value) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_bool_value(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), bool_value}, M, Path); v_msg_bool_value(X, Path, _TrUserData) -> mk_type_error({expected_msg, bool_value}, X, Path). -compile({nowarn_unused_function,v_msg_payload/3}). -dialyzer({nowarn_function,v_msg_payload/3}). v_msg_payload(#{} = M, Path, TrUserData) -> case M of #{type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [type | Path], TrUserData); _ -> ok end, case M of #{body := F2} -> v_type_bytes(F2, [body | Path], TrUserData); _ -> ok end, lists:foreach(fun (type) -> ok; (body) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_payload(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), payload}, M, Path); v_msg_payload(X, Path, _TrUserData) -> mk_type_error({expected_msg, payload}, X, Path). -compile({nowarn_unused_function,v_msg_echo_status/3}). -dialyzer({nowarn_function,v_msg_echo_status/3}). v_msg_echo_status(#{} = M, Path, TrUserData) -> case M of #{code := F1} -> v_type_int32(F1, [code | Path], TrUserData); _ -> ok end, case M of #{message := F2} -> v_type_string(F2, [message | Path], TrUserData); _ -> ok end, lists:foreach(fun (code) -> ok; (message) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_echo_status(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), echo_status}, M, Path); v_msg_echo_status(X, Path, _TrUserData) -> mk_type_error({expected_msg, echo_status}, X, Path). -compile({nowarn_unused_function,v_msg_simple_request/3}). -dialyzer({nowarn_function,v_msg_simple_request/3}). v_msg_simple_request(#{} = M, Path, TrUserData) -> case M of #{response_type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [response_type | Path], TrUserData); _ -> ok end, case M of #{response_size := F2} -> v_type_int32(F2, [response_size | Path], TrUserData); _ -> ok end, case M of #{payload := F3} -> v_msg_payload(F3, [payload | Path], TrUserData); _ -> ok end, case M of #{fill_username := F4} -> v_type_bool(F4, [fill_username | Path], TrUserData); _ -> ok end, case M of #{fill_oauth_scope := F5} -> v_type_bool(F5, [fill_oauth_scope | Path], TrUserData); _ -> ok end, case M of #{response_compressed := F6} -> v_msg_bool_value(F6, [response_compressed | Path], TrUserData); _ -> ok end, case M of #{response_status := F7} -> v_msg_echo_status(F7, [response_status | Path], TrUserData); _ -> ok end, case M of #{expect_compressed := F8} -> v_msg_bool_value(F8, [expect_compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (response_type) -> ok; (response_size) -> ok; (payload) -> ok; (fill_username) -> ok; (fill_oauth_scope) -> ok; (response_compressed) -> ok; (response_status) -> ok; (expect_compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_simple_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), simple_request}, M, Path); v_msg_simple_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, simple_request}, X, Path). -compile({nowarn_unused_function,v_msg_simple_response/3}). -dialyzer({nowarn_function,v_msg_simple_response/3}). v_msg_simple_response(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, case M of #{username := F2} -> v_type_string(F2, [username | Path], TrUserData); _ -> ok end, case M of #{oauth_scope := F3} -> v_type_string(F3, [oauth_scope | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (username) -> ok; (oauth_scope) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_simple_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), simple_response}, M, Path); v_msg_simple_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, simple_response}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_input_call_request/3}). -dialyzer({nowarn_function,v_msg_streaming_input_call_request/3}). v_msg_streaming_input_call_request(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, case M of #{expect_compressed := F2} -> v_msg_bool_value(F2, [expect_compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (expect_compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_input_call_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_input_call_request}, M, Path); v_msg_streaming_input_call_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_input_call_request}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_input_call_response/3}). -dialyzer({nowarn_function,v_msg_streaming_input_call_response/3}). v_msg_streaming_input_call_response(#{} = M, Path, TrUserData) -> case M of #{aggregated_payload_size := F1} -> v_type_int32(F1, [aggregated_payload_size | Path], TrUserData); _ -> ok end, lists:foreach(fun (aggregated_payload_size) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_input_call_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_input_call_response}, M, Path); v_msg_streaming_input_call_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_input_call_response}, X, Path). -compile({nowarn_unused_function,v_msg_response_parameters/3}). -dialyzer({nowarn_function,v_msg_response_parameters/3}). v_msg_response_parameters(#{} = M, Path, TrUserData) -> case M of #{size := F1} -> v_type_int32(F1, [size | Path], TrUserData); _ -> ok end, case M of #{interval_us := F2} -> v_type_int32(F2, [interval_us | Path], TrUserData); _ -> ok end, case M of #{compressed := F3} -> v_msg_bool_value(F3, [compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (size) -> ok; (interval_us) -> ok; (compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_response_parameters(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), response_parameters}, M, Path); v_msg_response_parameters(X, Path, _TrUserData) -> mk_type_error({expected_msg, response_parameters}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_output_call_request/3}). -dialyzer({nowarn_function,v_msg_streaming_output_call_request/3}). v_msg_streaming_output_call_request(#{} = M, Path, TrUserData) -> case M of #{response_type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [response_type | Path], TrUserData); _ -> ok end, case M of #{response_parameters := F2} -> if is_list(F2) -> _ = [v_msg_response_parameters(Elem, [response_parameters | Path], TrUserData) || Elem <- F2], ok; true -> mk_type_error({invalid_list_of, {msg, response_parameters}}, F2, [response_parameters | Path]) end; _ -> ok end, case M of #{payload := F3} -> v_msg_payload(F3, [payload | Path], TrUserData); _ -> ok end, case M of #{response_status := F4} -> v_msg_echo_status(F4, [response_status | Path], TrUserData); _ -> ok end, lists:foreach(fun (response_type) -> ok; (response_parameters) -> ok; (payload) -> ok; (response_status) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_output_call_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_output_call_request}, M, Path); v_msg_streaming_output_call_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_output_call_request}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_output_call_response/3}). -dialyzer({nowarn_function,v_msg_streaming_output_call_response/3}). v_msg_streaming_output_call_response(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_output_call_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_output_call_response}, M, Path); v_msg_streaming_output_call_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_output_call_response}, X, Path). -compile({nowarn_unused_function,v_msg_reconnect_params/3}). -dialyzer({nowarn_function,v_msg_reconnect_params/3}). v_msg_reconnect_params(#{} = M, Path, TrUserData) -> case M of #{max_reconnect_backoff_ms := F1} -> v_type_int32(F1, [max_reconnect_backoff_ms | Path], TrUserData); _ -> ok end, lists:foreach(fun (max_reconnect_backoff_ms) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_reconnect_params(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), reconnect_params}, M, Path); v_msg_reconnect_params(X, Path, _TrUserData) -> mk_type_error({expected_msg, reconnect_params}, X, Path). -compile({nowarn_unused_function,v_msg_reconnect_info/3}). -dialyzer({nowarn_function,v_msg_reconnect_info/3}). v_msg_reconnect_info(#{} = M, Path, TrUserData) -> case M of #{passed := F1} -> v_type_bool(F1, [passed | Path], TrUserData); _ -> ok end, case M of #{backoff_ms := F2} -> if is_list(F2) -> _ = [v_type_int32(Elem, [backoff_ms | Path], TrUserData) || Elem <- F2], ok; true -> mk_type_error({invalid_list_of, int32}, F2, [backoff_ms | Path]) end; _ -> ok end, lists:foreach(fun (passed) -> ok; (backoff_ms) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_reconnect_info(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), reconnect_info}, M, Path); v_msg_reconnect_info(X, Path, _TrUserData) -> mk_type_error({expected_msg, reconnect_info}, X, Path). -compile({nowarn_unused_function,'v_enum_grpc.testing.PayloadType'/3}). -dialyzer({nowarn_function,'v_enum_grpc.testing.PayloadType'/3}). 'v_enum_grpc.testing.PayloadType'('COMPRESSABLE', _Path, _TrUserData) -> ok; 'v_enum_grpc.testing.PayloadType'(V, Path, TrUserData) when is_integer(V) -> v_type_sint32(V, Path, TrUserData); 'v_enum_grpc.testing.PayloadType'(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'grpc.testing.PayloadType'}, X, Path). -compile({nowarn_unused_function,v_type_sint32/3}). -dialyzer({nowarn_function,v_type_sint32/3}). v_type_sint32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_sint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, sint32, signed, 32}, N, Path); v_type_sint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, sint32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -dialyzer({nowarn_function,v_type_int32/3}). v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_bool/3}). -dialyzer({nowarn_function,v_type_bool/3}). v_type_bool(false, _Path, _TrUserData) -> ok; v_type_bool(true, _Path, _TrUserData) -> ok; v_type_bool(0, _Path, _TrUserData) -> ok; v_type_bool(1, _Path, _TrUserData) -> ok; v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,v_type_bytes/3}). -dialyzer({nowarn_function,v_type_bytes/3}). v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; prettify_path(PathR) -> list_to_atom(lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR))))). -compile({nowarn_unused_function,id/2}). -compile({inline,id/2}). id(X, _TrUserData) -> X. -compile({nowarn_unused_function,v_ok/3}). -compile({inline,v_ok/3}). v_ok(_Value, _Path, _TrUserData) -> ok. -compile({nowarn_unused_function,m_overwrite/3}). -compile({inline,m_overwrite/3}). m_overwrite(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. -compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). -compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. get_msg_defs() -> [{{enum, 'grpc.testing.PayloadType'}, [{'COMPRESSABLE', 0}]}, {{msg, bool_value}, [#{name => value, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}]}, {{msg, payload}, [#{name => type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => body, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]}, {{msg, echo_status}, [#{name => code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, {{msg, simple_request}, [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_size, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => fill_username, fnum => 4, rnum => 5, type => bool, occurrence => optional, opts => []}, #{name => fill_oauth_scope, fnum => 5, rnum => 6, type => bool, occurrence => optional, opts => []}, #{name => response_compressed, fnum => 6, rnum => 7, type => {msg, bool_value}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 8, type => {msg, echo_status}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 8, rnum => 9, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, simple_response}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => username, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => oauth_scope, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, {{msg, streaming_input_call_request}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 2, rnum => 3, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, streaming_input_call_response}, [#{name => aggregated_payload_size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]}, {{msg, response_parameters}, [#{name => size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => interval_us, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => compressed, fnum => 3, rnum => 4, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, streaming_output_call_request}, [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_parameters, fnum => 2, rnum => 3, type => {msg, response_parameters}, occurrence => repeated, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 5, type => {msg, echo_status}, occurrence => optional, opts => []}]}, {{msg, streaming_output_call_response}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}]}, {{msg, reconnect_params}, [#{name => max_reconnect_backoff_ms, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]}, {{msg, reconnect_info}, [#{name => passed, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}, #{name => backoff_ms, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]}]. get_msg_names() -> [bool_value, payload, echo_status, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, response_parameters, streaming_output_call_request, streaming_output_call_response, reconnect_params, reconnect_info]. get_group_names() -> []. get_msg_or_group_names() -> [bool_value, payload, echo_status, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, response_parameters, streaming_output_call_request, streaming_output_call_response, reconnect_params, reconnect_info]. get_enum_names() -> ['grpc.testing.PayloadType']. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of Fs when is_list(Fs) -> Fs; error -> erlang:error({no_such_msg, MsgName}) end. fetch_enum_def(EnumName) -> case find_enum_def(EnumName) of Es when is_list(Es) -> Es; error -> erlang:error({no_such_enum, EnumName}) end. find_msg_def(bool_value) -> [#{name => value, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}]; find_msg_def(payload) -> [#{name => type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => body, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]; find_msg_def(echo_status) -> [#{name => code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; find_msg_def(simple_request) -> [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_size, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => fill_username, fnum => 4, rnum => 5, type => bool, occurrence => optional, opts => []}, #{name => fill_oauth_scope, fnum => 5, rnum => 6, type => bool, occurrence => optional, opts => []}, #{name => response_compressed, fnum => 6, rnum => 7, type => {msg, bool_value}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 8, type => {msg, echo_status}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 8, rnum => 9, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(simple_response) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => username, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => oauth_scope, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; find_msg_def(streaming_input_call_request) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 2, rnum => 3, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(streaming_input_call_response) -> [#{name => aggregated_payload_size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]; find_msg_def(response_parameters) -> [#{name => size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => interval_us, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => compressed, fnum => 3, rnum => 4, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(streaming_output_call_request) -> [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_parameters, fnum => 2, rnum => 3, type => {msg, response_parameters}, occurrence => repeated, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 5, type => {msg, echo_status}, occurrence => optional, opts => []}]; find_msg_def(streaming_output_call_response) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}]; find_msg_def(reconnect_params) -> [#{name => max_reconnect_backoff_ms, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]; find_msg_def(reconnect_info) -> [#{name => passed, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}, #{name => backoff_ms, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]; find_msg_def(_) -> error. find_enum_def('grpc.testing.PayloadType') -> [{'COMPRESSABLE', 0}]; find_enum_def(_) -> error. enum_symbol_by_value('grpc.testing.PayloadType', Value) -> 'enum_symbol_by_value_grpc.testing.PayloadType'(Value). enum_value_by_symbol('grpc.testing.PayloadType', Sym) -> 'enum_value_by_symbol_grpc.testing.PayloadType'(Sym). 'enum_symbol_by_value_grpc.testing.PayloadType'(0) -> 'COMPRESSABLE'. 'enum_value_by_symbol_grpc.testing.PayloadType'('COMPRESSABLE') -> 0. get_service_names() -> []. get_service_def(_) -> error. get_rpc_names(_) -> error. find_rpc_def(_, _) -> error. -spec fetch_rpc_def(_, _) -> no_return(). fetch_rpc_def(ServiceName, RpcName) -> erlang:error({no_such_rpc, ServiceName, RpcName}). %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. -spec fqbin_to_service_name(_) -> no_return(). fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. -spec service_name_to_fqbin(_) -> no_return(). service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. -spec fqbins_to_service_and_rpc_name(_, _) -> no_return(). fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. -spec service_and_rpc_name_to_fqbins(_, _) -> no_return(). service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"grpc.testing.BoolValue">>) -> bool_value; fqbin_to_msg_name(<<"grpc.testing.Payload">>) -> payload; fqbin_to_msg_name(<<"grpc.testing.EchoStatus">>) -> echo_status; fqbin_to_msg_name(<<"grpc.testing.SimpleRequest">>) -> simple_request; fqbin_to_msg_name(<<"grpc.testing.SimpleResponse">>) -> simple_response; fqbin_to_msg_name(<<"grpc.testing.StreamingInputCallRequest">>) -> streaming_input_call_request; fqbin_to_msg_name(<<"grpc.testing.StreamingInputCallResponse">>) -> streaming_input_call_response; fqbin_to_msg_name(<<"grpc.testing.ResponseParameters">>) -> response_parameters; fqbin_to_msg_name(<<"grpc.testing.StreamingOutputCallRequest">>) -> streaming_output_call_request; fqbin_to_msg_name(<<"grpc.testing.StreamingOutputCallResponse">>) -> streaming_output_call_response; fqbin_to_msg_name(<<"grpc.testing.ReconnectParams">>) -> reconnect_params; fqbin_to_msg_name(<<"grpc.testing.ReconnectInfo">>) -> reconnect_info; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin(bool_value) -> <<"grpc.testing.BoolValue">>; msg_name_to_fqbin(payload) -> <<"grpc.testing.Payload">>; msg_name_to_fqbin(echo_status) -> <<"grpc.testing.EchoStatus">>; msg_name_to_fqbin(simple_request) -> <<"grpc.testing.SimpleRequest">>; msg_name_to_fqbin(simple_response) -> <<"grpc.testing.SimpleResponse">>; msg_name_to_fqbin(streaming_input_call_request) -> <<"grpc.testing.StreamingInputCallRequest">>; msg_name_to_fqbin(streaming_input_call_response) -> <<"grpc.testing.StreamingInputCallResponse">>; msg_name_to_fqbin(response_parameters) -> <<"grpc.testing.ResponseParameters">>; msg_name_to_fqbin(streaming_output_call_request) -> <<"grpc.testing.StreamingOutputCallRequest">>; msg_name_to_fqbin(streaming_output_call_response) -> <<"grpc.testing.StreamingOutputCallResponse">>; msg_name_to_fqbin(reconnect_params) -> <<"grpc.testing.ReconnectParams">>; msg_name_to_fqbin(reconnect_info) -> <<"grpc.testing.ReconnectInfo">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). fqbin_to_enum_name(<<"grpc.testing.PayloadType">>) -> 'grpc.testing.PayloadType'; fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). enum_name_to_fqbin('grpc.testing.PayloadType') -> <<"grpc.testing.PayloadType">>; enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'grpc.testing'. %% Whether or not the message names %% are prepended with package name or not. uses_packages() -> true. source_basename() -> "messages.proto". %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension get_all_source_basenames() -> ["messages.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. get_all_proto_names() -> ["messages"]. get_msg_containment("messages") -> [bool_value, echo_status, payload, reconnect_info, reconnect_params, response_parameters, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, streaming_output_call_request, streaming_output_call_response]; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("messages") -> 'grpc.testing'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("messages") -> []; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("messages") -> []; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("messages") -> ['grpc.testing.PayloadType']; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ResponseParameters">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ReconnectParams">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.EchoStatus">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingOutputCallRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingInputCallRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.SimpleRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.Payload">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingOutputCallResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingInputCallResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.SimpleResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.BoolValue">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ReconnectInfo">>) -> "messages"; get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec get_proto_by_service_name_as_fqbin(_) -> no_return(). get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). get_proto_by_enum_name_as_fqbin(<<"grpc.testing.PayloadType">>) -> "messages"; get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). get_protos_by_pkg_name_as_fqbin(<<"grpc.testing">>) -> ["messages"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). descriptor() -> <<10, 215, 10, 10, 27, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 109, 101, 115, 115, 97, 103, 101, 115, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 26, 10, 9, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 13, 10, 5, 118, 97, 108, 117, 101, 24, 1, 32, 1, 40, 8, 34, 43, 10, 10, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 12, 10, 4, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 64, 10, 7, 80, 97, 121, 108, 111, 97, 100, 18, 39, 10, 4, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 12, 10, 4, 98, 111, 100, 121, 24, 2, 32, 1, 40, 12, 34, 63, 10, 13, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 18, 14, 10, 6, 112, 97, 115, 115, 101, 100, 24, 1, 32, 1, 40, 8, 18, 30, 10, 10, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 51, 10, 15, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 18, 32, 10, 24, 109, 97, 120, 95, 114, 101, 99, 111, 110, 110, 101, 99, 116, 95, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 1, 32, 1, 40, 5, 34, 100, 10, 18, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 12, 10, 4, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 18, 19, 10, 11, 105, 110, 116, 101, 114, 118, 97, 108, 95, 117, 115, 24, 2, 32, 1, 40, 5, 18, 43, 10, 10, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 3, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 206, 2, 10, 13, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 21, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 105, 122, 101, 24, 2, 32, 1, 40, 5, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 21, 10, 13, 102, 105, 108, 108, 95, 117, 115, 101, 114, 110, 97, 109, 101, 24, 4, 32, 1, 40, 8, 18, 24, 10, 16, 102, 105, 108, 108, 95, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 5, 32, 1, 40, 8, 18, 52, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 6, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 8, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 95, 10, 14, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 16, 10, 8, 117, 115, 101, 114, 110, 97, 109, 101, 24, 2, 32, 1, 40, 9, 18, 19, 10, 11, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 3, 32, 1, 40, 9, 34, 119, 10, 25, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 2, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 61, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 31, 10, 23, 97, 103, 103, 114, 101, 103, 97, 116, 101, 100, 95, 112, 97, 121, 108, 111, 97, 100, 95, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 34, 232, 1, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 61, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 24, 2, 32, 3, 40, 11, 50, 32, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 34, 69, 10, 27, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 42, 31, 10, 11, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 16, 10, 12, 67, 79, 77, 80, 82, 69, 83, 83, 65, 66, 76, 69, 16, 0, 98, 6, 112, 114, 111, 116, 111, 51>>. descriptor("messages") -> <<10, 27, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 109, 101, 115, 115, 97, 103, 101, 115, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 26, 10, 9, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 13, 10, 5, 118, 97, 108, 117, 101, 24, 1, 32, 1, 40, 8, 34, 43, 10, 10, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 12, 10, 4, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 64, 10, 7, 80, 97, 121, 108, 111, 97, 100, 18, 39, 10, 4, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 12, 10, 4, 98, 111, 100, 121, 24, 2, 32, 1, 40, 12, 34, 63, 10, 13, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 18, 14, 10, 6, 112, 97, 115, 115, 101, 100, 24, 1, 32, 1, 40, 8, 18, 30, 10, 10, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 51, 10, 15, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 18, 32, 10, 24, 109, 97, 120, 95, 114, 101, 99, 111, 110, 110, 101, 99, 116, 95, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 1, 32, 1, 40, 5, 34, 100, 10, 18, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 12, 10, 4, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 18, 19, 10, 11, 105, 110, 116, 101, 114, 118, 97, 108, 95, 117, 115, 24, 2, 32, 1, 40, 5, 18, 43, 10, 10, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 3, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 206, 2, 10, 13, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 21, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 105, 122, 101, 24, 2, 32, 1, 40, 5, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 21, 10, 13, 102, 105, 108, 108, 95, 117, 115, 101, 114, 110, 97, 109, 101, 24, 4, 32, 1, 40, 8, 18, 24, 10, 16, 102, 105, 108, 108, 95, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 5, 32, 1, 40, 8, 18, 52, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 6, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 8, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 95, 10, 14, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 16, 10, 8, 117, 115, 101, 114, 110, 97, 109, 101, 24, 2, 32, 1, 40, 9, 18, 19, 10, 11, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 3, 32, 1, 40, 9, 34, 119, 10, 25, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 2, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 61, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 31, 10, 23, 97, 103, 103, 114, 101, 103, 97, 116, 101, 100, 95, 112, 97, 121, 108, 111, 97, 100, 95, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 34, 232, 1, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 61, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 24, 2, 32, 3, 40, 11, 50, 32, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 34, 69, 10, 27, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 42, 31, 10, 11, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 16, 10, 12, 67, 79, 77, 80, 82, 69, 83, 83, 65, 66, 76, 69, 16, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor(X) -> error({gpb_error, {badname, X}}). gpb_version_as_string() -> "4.7.1". gpb_version_as_list() -> [4,7,1]. ================================================ FILE: interop/src/test_pb.erl ================================================ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit %% Generated by gpb_compile version 4.7.1 -module(test_pb). -export([encode_msg/2, encode_msg/3]). -export([decode_msg/2, decode_msg/3]). -export([merge_msgs/3, merge_msgs/4]). -export([verify_msg/2, verify_msg/3]). -export([get_msg_defs/0]). -export([get_msg_names/0]). -export([get_group_names/0]). -export([get_msg_or_group_names/0]). -export([get_enum_names/0]). -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). -export(['enum_symbol_by_value_grpc.testing.PayloadType'/1, 'enum_value_by_symbol_grpc.testing.PayloadType'/1]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). -export([find_rpc_def/2, fetch_rpc_def/2]). -export([fqbin_to_service_name/1]). -export([service_name_to_fqbin/1]). -export([fqbins_to_service_and_rpc_name/2]). -export([service_and_rpc_name_to_fqbins/2]). -export([fqbin_to_msg_name/1]). -export([msg_name_to_fqbin/1]). -export([fqbin_to_enum_name/1]). -export([enum_name_to_fqbin/1]). -export([get_package_name/0]). -export([uses_packages/0]). -export([source_basename/0]). -export([get_all_source_basenames/0]). -export([get_all_proto_names/0]). -export([get_msg_containment/1]). -export([get_pkg_containment/1]). -export([get_service_containment/1]). -export([get_rpc_containment/1]). -export([get_enum_containment/1]). -export([get_proto_by_msg_name_as_fqbin/1]). -export([get_proto_by_service_name_as_fqbin/1]). -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([descriptor/0, descriptor/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). %% enumerated types -type 'grpc.testing.PayloadType'() :: 'COMPRESSABLE'. -export_type(['grpc.testing.PayloadType'/0]). %% message types -type empty() :: #{ }. -type bool_value() :: #{value => boolean() | 0 | 1 % = 1 }. -type payload() :: #{type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType body => iodata() % = 2 }. -type echo_status() :: #{code => integer(), % = 1, 32 bits message => iodata() % = 2 }. -type simple_request() :: #{response_type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType response_size => integer(), % = 2, 32 bits payload => payload(), % = 3 fill_username => boolean() | 0 | 1, % = 4 fill_oauth_scope => boolean() | 0 | 1, % = 5 response_compressed => bool_value(), % = 6 response_status => echo_status(), % = 7 expect_compressed => bool_value() % = 8 }. -type simple_response() :: #{payload => payload(), % = 1 username => iodata(), % = 2 oauth_scope => iodata() % = 3 }. -type streaming_input_call_request() :: #{payload => payload(), % = 1 expect_compressed => bool_value() % = 2 }. -type streaming_input_call_response() :: #{aggregated_payload_size => integer() % = 1, 32 bits }. -type response_parameters() :: #{size => integer(), % = 1, 32 bits interval_us => integer(), % = 2, 32 bits compressed => bool_value() % = 3 }. -type streaming_output_call_request() :: #{response_type => 'COMPRESSABLE' | integer(), % = 1, enum grpc.testing.PayloadType response_parameters => [response_parameters()], % = 2 payload => payload(), % = 3 response_status => echo_status() % = 7 }. -type streaming_output_call_response() :: #{payload => payload() % = 1 }. -type reconnect_params() :: #{max_reconnect_backoff_ms => integer() % = 1, 32 bits }. -type reconnect_info() :: #{passed => boolean() | 0 | 1, % = 1 backoff_ms => [integer()] % = 2, 32 bits }. -export_type(['empty'/0, 'bool_value'/0, 'payload'/0, 'echo_status'/0, 'simple_request'/0, 'simple_response'/0, 'streaming_input_call_request'/0, 'streaming_input_call_response'/0, 'response_parameters'/0, 'streaming_output_call_request'/0, 'streaming_output_call_response'/0, 'reconnect_params'/0, 'reconnect_info'/0]). -spec encode_msg(empty() | bool_value() | payload() | echo_status() | simple_request() | simple_response() | streaming_input_call_request() | streaming_input_call_response() | response_parameters() | streaming_output_call_request() | streaming_output_call_response() | reconnect_params() | reconnect_info(), atom()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). -spec encode_msg(empty() | bool_value() | payload() | echo_status() | simple_request() | simple_response() | streaming_input_call_request() | streaming_input_call_response() | response_parameters() | streaming_output_call_request() | streaming_output_call_response() | reconnect_params() | reconnect_info(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> case proplists:get_bool(verify, Opts) of true -> verify_msg(Msg, MsgName, Opts); false -> ok end, TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); bool_value -> encode_msg_bool_value(id(Msg, TrUserData), TrUserData); payload -> encode_msg_payload(id(Msg, TrUserData), TrUserData); echo_status -> encode_msg_echo_status(id(Msg, TrUserData), TrUserData); simple_request -> encode_msg_simple_request(id(Msg, TrUserData), TrUserData); simple_response -> encode_msg_simple_response(id(Msg, TrUserData), TrUserData); streaming_input_call_request -> encode_msg_streaming_input_call_request(id(Msg, TrUserData), TrUserData); streaming_input_call_response -> encode_msg_streaming_input_call_response(id(Msg, TrUserData), TrUserData); response_parameters -> encode_msg_response_parameters(id(Msg, TrUserData), TrUserData); streaming_output_call_request -> encode_msg_streaming_output_call_request(id(Msg, TrUserData), TrUserData); streaming_output_call_response -> encode_msg_streaming_output_call_response(id(Msg, TrUserData), TrUserData); reconnect_params -> encode_msg_reconnect_params(id(Msg, TrUserData), TrUserData); reconnect_info -> encode_msg_reconnect_info(id(Msg, TrUserData), TrUserData) end. encode_msg_empty(_Msg, _TrUserData) -> <<>>. encode_msg_bool_value(Msg, TrUserData) -> encode_msg_bool_value(Msg, <<>>, TrUserData). encode_msg_bool_value(#{} = M, Bin, TrUserData) -> case M of #{value := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= false -> Bin; true -> e_type_bool(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_payload(Msg, TrUserData) -> encode_msg_payload(Msg, <<>>, TrUserData). encode_msg_payload(#{} = M, Bin, TrUserData) -> B1 = case M of #{type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, 'MaybeTrUserData') end end; _ -> Bin end, case M of #{body := F2} -> begin TrF2 = id(F2, TrUserData), case iolist_size(TrF2) of 0 -> B1; _ -> e_type_bytes(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_echo_status(Msg, TrUserData) -> encode_msg_echo_status(Msg, <<>>, TrUserData). encode_msg_echo_status(#{} = M, Bin, TrUserData) -> B1 = case M of #{code := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{message := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_simple_request(Msg, TrUserData) -> encode_msg_simple_request(Msg, <<>>, TrUserData). encode_msg_simple_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{response_type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, 'MaybeTrUserData') end end; _ -> Bin end, B2 = case M of #{response_size := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end, B3 = case M of #{payload := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_simple_request_payload(TrF3, <>, TrUserData) end end; _ -> B2 end, B4 = case M of #{fill_username := F4} -> begin TrF4 = id(F4, TrUserData), if TrF4 =:= false -> B3; true -> e_type_bool(TrF4, <>, TrUserData) end end; _ -> B3 end, B5 = case M of #{fill_oauth_scope := F5} -> begin TrF5 = id(F5, TrUserData), if TrF5 =:= false -> B4; true -> e_type_bool(TrF5, <>, TrUserData) end end; _ -> B4 end, B6 = case M of #{response_compressed := F6} -> begin TrF6 = id(F6, TrUserData), if TrF6 =:= undefined -> B5; true -> e_mfield_simple_request_response_compressed(TrF6, <>, TrUserData) end end; _ -> B5 end, B7 = case M of #{response_status := F7} -> begin TrF7 = id(F7, TrUserData), if TrF7 =:= undefined -> B6; true -> e_mfield_simple_request_response_status(TrF7, <>, TrUserData) end end; _ -> B6 end, case M of #{expect_compressed := F8} -> begin TrF8 = id(F8, TrUserData), if TrF8 =:= undefined -> B7; true -> e_mfield_simple_request_expect_compressed(TrF8, <>, TrUserData) end end; _ -> B7 end. encode_msg_simple_response(Msg, TrUserData) -> encode_msg_simple_response(Msg, <<>>, TrUserData). encode_msg_simple_response(#{} = M, Bin, TrUserData) -> B1 = case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_simple_response_payload(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{username := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end, case M of #{oauth_scope := F3} -> begin TrF3 = id(F3, TrUserData), case is_empty_string(TrF3) of true -> B2; false -> e_type_string(TrF3, <>, TrUserData) end end; _ -> B2 end. encode_msg_streaming_input_call_request(Msg, TrUserData) -> encode_msg_streaming_input_call_request(Msg, <<>>, TrUserData). encode_msg_streaming_input_call_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_streaming_input_call_request_payload(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{expect_compressed := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= undefined -> B1; true -> e_mfield_streaming_input_call_request_expect_compressed(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_streaming_input_call_response(Msg, TrUserData) -> encode_msg_streaming_input_call_response(Msg, <<>>, TrUserData). encode_msg_streaming_input_call_response(#{} = M, Bin, TrUserData) -> case M of #{aggregated_payload_size := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_response_parameters(Msg, TrUserData) -> encode_msg_response_parameters(Msg, <<>>, TrUserData). encode_msg_response_parameters(#{} = M, Bin, TrUserData) -> B1 = case M of #{size := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{interval_us := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end, case M of #{compressed := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_response_parameters_compressed(TrF3, <>, TrUserData) end end; _ -> B2 end. encode_msg_streaming_output_call_request(Msg, TrUserData) -> encode_msg_streaming_output_call_request(Msg, <<>>, TrUserData). encode_msg_streaming_output_call_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{response_type := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'COMPRESSABLE'; TrF1 =:= 0 -> Bin; true -> 'e_enum_grpc.testing.PayloadType'(TrF1, <>, 'MaybeTrUserData') end end; _ -> Bin end, B2 = case M of #{response_parameters := F2} -> TrF2 = id(F2, TrUserData), if TrF2 == [] -> B1; true -> e_field_streaming_output_call_request_response_parameters(TrF2, B1, TrUserData) end; _ -> B1 end, B3 = case M of #{payload := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= undefined -> B2; true -> e_mfield_streaming_output_call_request_payload(TrF3, <>, TrUserData) end end; _ -> B2 end, case M of #{response_status := F4} -> begin TrF4 = id(F4, TrUserData), if TrF4 =:= undefined -> B3; true -> e_mfield_streaming_output_call_request_response_status(TrF4, <>, TrUserData) end end; _ -> B3 end. encode_msg_streaming_output_call_response(Msg, TrUserData) -> encode_msg_streaming_output_call_response(Msg, <<>>, TrUserData). encode_msg_streaming_output_call_response(#{} = M, Bin, TrUserData) -> case M of #{payload := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_streaming_output_call_response_payload(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_reconnect_params(Msg, TrUserData) -> encode_msg_reconnect_params(Msg, <<>>, TrUserData). encode_msg_reconnect_params(#{} = M, Bin, TrUserData) -> case M of #{max_reconnect_backoff_ms := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_reconnect_info(Msg, TrUserData) -> encode_msg_reconnect_info(Msg, <<>>, TrUserData). encode_msg_reconnect_info(#{} = M, Bin, TrUserData) -> B1 = case M of #{passed := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= false -> Bin; true -> e_type_bool(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{backoff_ms := F2} -> TrF2 = id(F2, TrUserData), if TrF2 == [] -> B1; true -> e_field_reconnect_info_backoff_ms(TrF2, B1, TrUserData) end; _ -> B1 end. e_mfield_simple_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_response_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_response_status(Msg, Bin, TrUserData) -> SubBin = encode_msg_echo_status(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_request_expect_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_simple_response_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_input_call_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_input_call_request_expect_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_response_parameters_compressed(Msg, Bin, TrUserData) -> SubBin = encode_msg_bool_value(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_request_response_parameters(Msg, Bin, TrUserData) -> SubBin = encode_msg_response_parameters(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_streaming_output_call_request_response_parameters([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, Bin3 = e_mfield_streaming_output_call_request_response_parameters(id(Elem, TrUserData), Bin2, TrUserData), e_field_streaming_output_call_request_response_parameters(Rest, Bin3, TrUserData); e_field_streaming_output_call_request_response_parameters([], Bin, _TrUserData) -> Bin. e_mfield_streaming_output_call_request_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_request_response_status(Msg, Bin, TrUserData) -> SubBin = encode_msg_echo_status(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_streaming_output_call_response_payload(Msg, Bin, TrUserData) -> SubBin = encode_msg_payload(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_reconnect_info_backoff_ms(Elems, Bin, TrUserData) when Elems =/= [] -> SubBin = e_pfield_reconnect_info_backoff_ms(Elems, <<>>, TrUserData), Bin2 = <>, Bin3 = e_varint(byte_size(SubBin), Bin2), <>; e_field_reconnect_info_backoff_ms([], Bin, _TrUserData) -> Bin. e_pfield_reconnect_info_backoff_ms([Value | Rest], Bin, TrUserData) -> Bin2 = e_type_int32(id(Value, TrUserData), Bin, TrUserData), e_pfield_reconnect_info_backoff_ms(Rest, Bin2, TrUserData); e_pfield_reconnect_info_backoff_ms([], Bin, _TrUserData) -> Bin. 'e_enum_grpc.testing.PayloadType'('COMPRESSABLE', Bin, _TrUserData) -> <>; 'e_enum_grpc.testing.PayloadType'(V, Bin, _TrUserData) -> e_varint(V, Bin). -compile({nowarn_unused_function,e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). e_type_bool(true, Bin, _TrUserData) -> <>; e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_string/3}). e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -compile({nowarn_unused_function,e_type_bytes/3}). e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). e_type_float(V, Bin, _) when is_number(V) -> <>; e_type_float(infinity, Bin, _) -> <>; e_type_float('-infinity', Bin, _) -> <>; e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). e_type_double(V, Bin, _) when is_number(V) -> <>; e_type_double(infinity, Bin, _) -> <>; e_type_double('-infinity', Bin, _) -> <>; e_type_double(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). -compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, e_varint(N bsr 7, Bin2). is_empty_string("") -> true; is_empty_string(<<>>) -> true; is_empty_string(L) when is_list(L) -> not string_has_chars(L); is_empty_string(B) when is_binary(B) -> false. string_has_chars([C | _]) when is_integer(C) -> true; string_has_chars([H | T]) -> case string_has_chars(H) of true -> true; false -> string_has_chars(T) end; string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; string_has_chars(C) when is_integer(C) -> true; string_has_chars(<<>>) -> false; string_has_chars([]) -> false. decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), decode_msg_1_catch(Bin, MsgName, TrUserData). -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason -> StackTrace = erlang:get_stacktrace(), error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); decode_msg_2_doit(bool_value, Bin, TrUserData) -> id(decode_msg_bool_value(Bin, TrUserData), TrUserData); decode_msg_2_doit(payload, Bin, TrUserData) -> id(decode_msg_payload(Bin, TrUserData), TrUserData); decode_msg_2_doit(echo_status, Bin, TrUserData) -> id(decode_msg_echo_status(Bin, TrUserData), TrUserData); decode_msg_2_doit(simple_request, Bin, TrUserData) -> id(decode_msg_simple_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(simple_response, Bin, TrUserData) -> id(decode_msg_simple_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_input_call_request, Bin, TrUserData) -> id(decode_msg_streaming_input_call_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_input_call_response, Bin, TrUserData) -> id(decode_msg_streaming_input_call_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(response_parameters, Bin, TrUserData) -> id(decode_msg_response_parameters(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_output_call_request, Bin, TrUserData) -> id(decode_msg_streaming_output_call_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(streaming_output_call_response, Bin, TrUserData) -> id(decode_msg_streaming_output_call_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(reconnect_params, Bin, TrUserData) -> id(decode_msg_reconnect_params(Bin, TrUserData), TrUserData); decode_msg_2_doit(reconnect_info, Bin, TrUserData) -> id(decode_msg_reconnect_info(Bin, TrUserData), TrUserData). decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, TrUserData). dfp_read_field_def_empty(<<>>, 0, 0, _) -> #{}; dfp_read_field_def_empty(Other, Z1, Z2, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, TrUserData). dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, TrUserData); dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, TrUserData) -> Key = X bsl N + Acc, case Key band 7 of 0 -> skip_varint_empty(Rest, 0, 0, TrUserData); 1 -> skip_64_empty(Rest, 0, 0, TrUserData); 2 -> skip_length_delimited_empty(Rest, 0, 0, TrUserData); 3 -> skip_group_empty(Rest, Key bsr 3, 0, TrUserData); 5 -> skip_32_empty(Rest, 0, 0, TrUserData) end; dg_read_field_def_empty(<<>>, 0, 0, _) -> #{}. skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, TrUserData); skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, TrUserData); skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_empty(Rest2, 0, 0, TrUserData). skip_group_empty(Bin, FNum, Z2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_empty(Rest, 0, Z2, TrUserData). skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). decode_msg_bool_value(Bin, TrUserData) -> dfp_read_field_def_bool_value(Bin, 0, 0, id(false, TrUserData), TrUserData). dfp_read_field_def_bool_value(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_bool_value_value(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_bool_value(<<>>, 0, 0, F@_1, _) -> #{value => F@_1}; dfp_read_field_def_bool_value(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_bool_value(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_bool_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_bool_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_bool_value(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_bool_value_value(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_bool_value(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_bool_value(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_bool_value(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_bool_value(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_bool_value(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_bool_value(<<>>, 0, 0, F@_1, _) -> #{value => F@_1}. d_field_bool_value_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_bool_value_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_bool_value_value(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_bool_value(RestF, 0, 0, NewFValue, TrUserData). skip_varint_bool_value(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_bool_value(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_bool_value(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_bool_value(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_bool_value(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_bool_value(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_bool_value(Rest2, 0, 0, F@_1, TrUserData). skip_group_bool_value(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_bool_value(Rest, 0, Z2, F@_1, TrUserData). skip_32_bool_value(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). skip_64_bool_value(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_bool_value(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_payload(Bin, TrUserData) -> dfp_read_field_def_payload(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_payload(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_payload_type(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_payload(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_payload_body(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_payload(<<>>, 0, 0, F@_1, F@_2, _) -> #{type => F@_1, body => F@_2}; dfp_read_field_def_payload(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_payload(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_payload_type(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_payload_body(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_payload(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_payload(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_payload(<<>>, 0, 0, F@_1, F@_2, _) -> #{type => F@_1, body => F@_2}. d_field_payload_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_payload_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_payload_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_payload(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_payload_body(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_payload_body(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_payload_body(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_payload(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_payload(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_payload(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_payload(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_payload(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_payload(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_payload(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_payload(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_echo_status(Bin, TrUserData) -> dfp_read_field_def_echo_status(Bin, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_echo_status(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_echo_status_code(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_echo_status(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_echo_status_message(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_echo_status(<<>>, 0, 0, F@_1, F@_2, _) -> #{code => F@_1, message => F@_2}; dfp_read_field_def_echo_status(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_echo_status(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_echo_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_echo_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_echo_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_echo_status_code(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_echo_status_message(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_echo_status(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_echo_status(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_echo_status(<<>>, 0, 0, F@_1, F@_2, _) -> #{code => F@_1, message => F@_2}. d_field_echo_status_code(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_echo_status_code(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_echo_status_code(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_echo_status(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_echo_status_message(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_echo_status_message(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_echo_status_message(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_echo_status(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_echo_status(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_echo_status(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_echo_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_echo_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_echo_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_echo_status(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_echo_status(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_echo_status(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_echo_status(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_echo_status(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_echo_status(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_simple_request(Bin, TrUserData) -> dfp_read_field_def_simple_request(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id(0, TrUserData), id('$undef', TrUserData), id(false, TrUserData), id(false, TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_simple_request(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_type(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_size(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_fill_username(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<40, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_fill_oauth_scope(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<50, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_response_status(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<66, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> d_field_simple_request_expect_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dfp_read_field_def_simple_request(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> S1 = #{response_type => F@_1, response_size => F@_2, fill_username => F@_4, fill_oauth_scope => F@_5}, S2 = if F@_3 == '$undef' -> S1; true -> S1#{payload => F@_3} end, S3 = if F@_6 == '$undef' -> S2; true -> S2#{response_compressed => F@_6} end, S4 = if F@_7 == '$undef' -> S3; true -> S3#{response_status => F@_7} end, if F@_8 == '$undef' -> S4; true -> S4#{expect_compressed => F@_8} end; dfp_read_field_def_simple_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dg_read_field_def_simple_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). dg_read_field_def_simple_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 32 - 7 -> dg_read_field_def_simple_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); dg_read_field_def_simple_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_simple_request_response_type(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 16 -> d_field_simple_request_response_size(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 26 -> d_field_simple_request_payload(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 32 -> d_field_simple_request_fill_username(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 40 -> d_field_simple_request_fill_oauth_scope(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 50 -> d_field_simple_request_response_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 58 -> d_field_simple_request_response_status(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 66 -> d_field_simple_request_expect_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 1 -> skip_64_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 2 -> skip_length_delimited_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 3 -> skip_group_simple_request(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); 5 -> skip_32_simple_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) end end; dg_read_field_def_simple_request(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, _) -> S1 = #{response_type => F@_1, response_size => F@_2, fill_username => F@_4, fill_oauth_scope => F@_5}, S2 = if F@_3 == '$undef' -> S1; true -> S1#{payload => F@_3} end, S3 = if F@_6 == '$undef' -> S2; true -> S2#{response_compressed => F@_6} end, S4 = if F@_7 == '$undef' -> S3; true -> S3#{response_status => F@_7} end, if F@_8 == '$undef' -> S4; true -> S4#{expect_compressed => F@_8} end. d_field_simple_request_response_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_response_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_size(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_size(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, NewFValue, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_fill_username(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_fill_username(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_fill_username(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, _, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, NewFValue, F@_5, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_fill_oauth_scope(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_fill_oauth_scope(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_fill_oauth_scope(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, _, F@_6, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, NewFValue, F@_6, F@_7, F@_8, TrUserData). d_field_simple_request_response_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, Prev, F@_7, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, F@_7, F@_8, TrUserData). d_field_simple_request_response_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_response_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_response_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, Prev, F@_8, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_echo_status(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, if Prev == '$undef' -> NewFValue; true -> merge_msg_echo_status(Prev, NewFValue, TrUserData) end, F@_8, TrUserData). d_field_simple_request_expect_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> d_field_simple_request_expect_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); d_field_simple_request_expect_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_request(RestF, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_simple_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> skip_varint_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); skip_varint_simple_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_length_delimited_simple_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) when N < 57 -> skip_length_delimited_simple_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData); skip_length_delimited_simple_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_simple_request(Rest2, 0, 0, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_group_simple_request(Bin, FNum, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_simple_request(Rest, 0, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_32_simple_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). skip_64_simple_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData) -> dfp_read_field_def_simple_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, F@_5, F@_6, F@_7, F@_8, TrUserData). decode_msg_simple_response(Bin, TrUserData) -> dfp_read_field_def_simple_response(Bin, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_simple_response(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_username(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_simple_response_oauth_scope(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_simple_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{username => F@_2, oauth_scope => F@_3}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end; dfp_read_field_def_simple_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_simple_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). dg_read_field_def_simple_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_simple_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_simple_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_simple_response_payload(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 18 -> d_field_simple_response_username(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_simple_response_oauth_scope(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_simple_response(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, TrUserData); 5 -> skip_32_simple_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData) end end; dg_read_field_def_simple_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{username => F@_2, oauth_scope => F@_3}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end. d_field_simple_response_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_2, F@_3, TrUserData). d_field_simple_response_username(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_username(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_username(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, F@_1, NewFValue, F@_3, TrUserData). d_field_simple_response_oauth_scope(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_simple_response_oauth_scope(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_simple_response_oauth_scope(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_simple_response(RestF, 0, 0, F@_1, F@_2, NewFValue, TrUserData). skip_varint_simple_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); skip_varint_simple_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_length_delimited_simple_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_simple_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_simple_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_simple_response(Rest2, 0, 0, F@_1, F@_2, F@_3, TrUserData). skip_group_simple_response(Bin, FNum, Z2, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_simple_response(Rest, 0, Z2, F@_1, F@_2, F@_3, TrUserData). skip_32_simple_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_64_simple_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_simple_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). decode_msg_streaming_input_call_request(Bin, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Bin, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_input_call_request(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_streaming_input_call_request_payload(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_streaming_input_call_request(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_streaming_input_call_request_expect_compressed(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_streaming_input_call_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{expect_compressed => F@_2} end; dfp_read_field_def_streaming_input_call_request(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_streaming_input_call_request(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_streaming_input_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_input_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_streaming_input_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_streaming_input_call_request_payload(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_streaming_input_call_request_expect_compressed(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_streaming_input_call_request(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_streaming_input_call_request(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_streaming_input_call_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{expect_compressed => F@_2} end. d_field_streaming_input_call_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_streaming_input_call_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_streaming_input_call_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_input_call_request(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_2, TrUserData). d_field_streaming_input_call_request_expect_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_streaming_input_call_request_expect_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_streaming_input_call_request_expect_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_input_call_request(RestF, 0, 0, F@_1, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_input_call_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_streaming_input_call_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_streaming_input_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_streaming_input_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_streaming_input_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_input_call_request(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_streaming_input_call_request(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_input_call_request(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_streaming_input_call_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_streaming_input_call_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_streaming_input_call_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_streaming_input_call_response(Bin, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Bin, 0, 0, id(0, TrUserData), TrUserData). dfp_read_field_def_streaming_input_call_response(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_streaming_input_call_response(<<>>, 0, 0, F@_1, _) -> #{aggregated_payload_size => F@_1}; dfp_read_field_def_streaming_input_call_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_streaming_input_call_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_streaming_input_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_input_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_streaming_input_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_streaming_input_call_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_streaming_input_call_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_streaming_input_call_response(<<>>, 0, 0, F@_1, _) -> #{aggregated_payload_size => F@_1}. d_field_streaming_input_call_response_aggregated_payload_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_streaming_input_call_response_aggregated_payload_size(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_streaming_input_call_response_aggregated_payload_size(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_streaming_input_call_response(RestF, 0, 0, NewFValue, TrUserData). skip_varint_streaming_input_call_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_streaming_input_call_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_streaming_input_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_streaming_input_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_streaming_input_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_input_call_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_streaming_input_call_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_input_call_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_streaming_input_call_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_streaming_input_call_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_input_call_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_response_parameters(Bin, TrUserData) -> dfp_read_field_def_response_parameters(Bin, 0, 0, id(0, TrUserData), id(0, TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_response_parameters(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_size(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_interval_us(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_response_parameters_compressed(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_response_parameters(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{size => F@_1, interval_us => F@_2}, if F@_3 == '$undef' -> S1; true -> S1#{compressed => F@_3} end; dfp_read_field_def_response_parameters(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_response_parameters(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). dg_read_field_def_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_response_parameters_size(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 16 -> d_field_response_parameters_interval_us(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 26 -> d_field_response_parameters_compressed(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_response_parameters(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, TrUserData); 5 -> skip_32_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData) end end; dg_read_field_def_response_parameters(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{size => F@_1, interval_us => F@_2}, if F@_3 == '$undef' -> S1; true -> S1#{compressed => F@_3} end. d_field_response_parameters_size(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_size(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_size(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_response_parameters(RestF, 0, 0, NewFValue, F@_2, F@_3, TrUserData). d_field_response_parameters_interval_us(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_interval_us(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_interval_us(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_response_parameters(RestF, 0, 0, F@_1, NewFValue, F@_3, TrUserData). d_field_response_parameters_compressed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_response_parameters_compressed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_response_parameters_compressed(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_bool_value(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_response_parameters(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_bool_value(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_response_parameters(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); skip_varint_response_parameters(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_length_delimited_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_response_parameters(Rest2, 0, 0, F@_1, F@_2, F@_3, TrUserData). skip_group_response_parameters(Bin, FNum, Z2, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_response_parameters(Rest, 0, Z2, F@_1, F@_2, F@_3, TrUserData). skip_32_response_parameters(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_64_response_parameters(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). decode_msg_streaming_output_call_request(Bin, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Bin, 0, 0, id('COMPRESSABLE', TrUserData), id([], TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_output_call_request(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_type(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_parameters(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_payload(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_streaming_output_call_request_response_status(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_streaming_output_call_request(<<>>, 0, 0, F@_1, R1, F@_3, F@_4, TrUserData) -> S1 = #{response_type => F@_1}, S2 = if R1 == '$undef' -> S1; true -> S1#{response_parameters => lists_reverse(R1, TrUserData)} end, S3 = if F@_3 == '$undef' -> S2; true -> S2#{payload => F@_3} end, if F@_4 == '$undef' -> S3; true -> S3#{response_status => F@_4} end; dfp_read_field_def_streaming_output_call_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_streaming_output_call_request(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). dg_read_field_def_streaming_output_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_output_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); dg_read_field_def_streaming_output_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_streaming_output_call_request_response_type(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 18 -> d_field_streaming_output_call_request_response_parameters(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 26 -> d_field_streaming_output_call_request_payload(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 58 -> d_field_streaming_output_call_request_response_status(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 1 -> skip_64_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 2 -> skip_length_delimited_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 3 -> skip_group_streaming_output_call_request(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 5 -> skip_32_streaming_output_call_request(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData) end end; dg_read_field_def_streaming_output_call_request(<<>>, 0, 0, F@_1, R1, F@_3, F@_4, TrUserData) -> S1 = #{response_type => F@_1}, S2 = if R1 == '$undef' -> S1; true -> S1#{response_parameters => lists_reverse(R1, TrUserData)} end, S3 = if F@_3 == '$undef' -> S2; true -> S2#{payload => F@_3} end, if F@_4 == '$undef' -> S3; true -> S3#{response_status => F@_4} end. d_field_streaming_output_call_request_response_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = {id('d_enum_grpc.testing.PayloadType'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, TrUserData). d_field_streaming_output_call_request_response_parameters(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_parameters(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_parameters(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_response_parameters(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, cons(NewFValue, Prev, TrUserData), F@_3, F@_4, TrUserData). d_field_streaming_output_call_request_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_payload(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_payload(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, F@_4, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, F@_2, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, F@_4, TrUserData). d_field_streaming_output_call_request_response_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_streaming_output_call_request_response_status(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_streaming_output_call_request_response_status(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_echo_status(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_request(RestF, 0, 0, F@_1, F@_2, F@_3, if Prev == '$undef' -> NewFValue; true -> merge_msg_echo_status(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_output_call_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_varint_streaming_output_call_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_length_delimited_streaming_output_call_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_streaming_output_call_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_length_delimited_streaming_output_call_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_output_call_request(Rest2, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_group_streaming_output_call_request(Bin, FNum, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_output_call_request(Rest, 0, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_32_streaming_output_call_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_64_streaming_output_call_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_streaming_output_call_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). decode_msg_streaming_output_call_response(Bin, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Bin, 0, 0, id('$undef', TrUserData), TrUserData). dfp_read_field_def_streaming_output_call_response(<<10, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_streaming_output_call_response_payload(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_streaming_output_call_response(<<>>, 0, 0, F@_1, _) -> S1 = #{}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end; dfp_read_field_def_streaming_output_call_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_streaming_output_call_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_streaming_output_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_streaming_output_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_streaming_output_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_streaming_output_call_response_payload(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_streaming_output_call_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_streaming_output_call_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_streaming_output_call_response(<<>>, 0, 0, F@_1, _) -> S1 = #{}, if F@_1 == '$undef' -> S1; true -> S1#{payload => F@_1} end. d_field_streaming_output_call_response_payload(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_streaming_output_call_response_payload(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_streaming_output_call_response_payload(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_payload(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_streaming_output_call_response(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_payload(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_streaming_output_call_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_streaming_output_call_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_streaming_output_call_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_streaming_output_call_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_streaming_output_call_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_streaming_output_call_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_streaming_output_call_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_streaming_output_call_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_streaming_output_call_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_streaming_output_call_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_streaming_output_call_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_reconnect_params(Bin, TrUserData) -> dfp_read_field_def_reconnect_params(Bin, 0, 0, id(0, TrUserData), TrUserData). dfp_read_field_def_reconnect_params(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_reconnect_params(<<>>, 0, 0, F@_1, _) -> #{max_reconnect_backoff_ms => F@_1}; dfp_read_field_def_reconnect_params(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_reconnect_params(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_reconnect_params(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_reconnect_params(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_reconnect_params(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_reconnect_params(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_reconnect_params(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_reconnect_params(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_reconnect_params(<<>>, 0, 0, F@_1, _) -> #{max_reconnect_backoff_ms => F@_1}. d_field_reconnect_params_max_reconnect_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_reconnect_params_max_reconnect_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_reconnect_params_max_reconnect_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_reconnect_params(RestF, 0, 0, NewFValue, TrUserData). skip_varint_reconnect_params(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_reconnect_params(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_reconnect_params(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_reconnect_params(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_reconnect_params(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_reconnect_params(Rest2, 0, 0, F@_1, TrUserData). skip_group_reconnect_params(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_reconnect_params(Rest, 0, Z2, F@_1, TrUserData). skip_32_reconnect_params(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). skip_64_reconnect_params(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_reconnect_params(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_reconnect_info(Bin, TrUserData) -> dfp_read_field_def_reconnect_info(Bin, 0, 0, id(false, TrUserData), id([], TrUserData), TrUserData). dfp_read_field_def_reconnect_info(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_reconnect_info_passed(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_pfield_reconnect_info_backoff_ms(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_reconnect_info_backoff_ms(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_reconnect_info(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{passed => F@_1, backoff_ms => lists_reverse(R1, TrUserData)}; dfp_read_field_def_reconnect_info(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_reconnect_info(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_reconnect_info(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_reconnect_info(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_reconnect_info(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_reconnect_info_passed(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_pfield_reconnect_info_backoff_ms(Rest, 0, 0, F@_1, F@_2, TrUserData); 16 -> d_field_reconnect_info_backoff_ms(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_reconnect_info(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_reconnect_info(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_reconnect_info(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{passed => F@_1, backoff_ms => lists_reverse(R1, TrUserData)}. d_field_reconnect_info_passed(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_reconnect_info_passed(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_reconnect_info_passed(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {id(X bsl N + Acc =/= 0, TrUserData), Rest}, dfp_read_field_def_reconnect_info(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_reconnect_info(RestF, 0, 0, F@_1, cons(NewFValue, Prev, TrUserData), TrUserData). d_pfield_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_pfield_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_pfield_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, E, TrUserData) -> Len = X bsl N + Acc, <> = Rest, NewSeq = d_packed_field_reconnect_info_backoff_ms(PackedBytes, 0, 0, E, TrUserData), dfp_read_field_def_reconnect_info(Rest2, 0, 0, F@_1, NewSeq, TrUserData). d_packed_field_reconnect_info_backoff_ms(<<1:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) when N < 57 -> d_packed_field_reconnect_info_backoff_ms(Rest, N + 7, X bsl N + Acc, AccSeq, TrUserData); d_packed_field_reconnect_info_backoff_ms(<<0:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, d_packed_field_reconnect_info_backoff_ms(RestF, 0, 0, [NewFValue | AccSeq], TrUserData); d_packed_field_reconnect_info_backoff_ms(<<>>, 0, 0, AccSeq, _) -> AccSeq. skip_varint_reconnect_info(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_reconnect_info(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_reconnect_info(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_reconnect_info(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_reconnect_info(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_reconnect_info(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_reconnect_info(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_reconnect_info(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_reconnect_info(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_reconnect_info(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_reconnect_info(Rest, Z1, Z2, F@_1, F@_2, TrUserData). 'd_enum_grpc.testing.PayloadType'(0) -> 'COMPRESSABLE'; 'd_enum_grpc.testing.PayloadType'(V) -> V. read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, {Group, Rest}. %% Like skipping over fields, but record the total length, %% Each field is <(FieldNum bsl 3) bor FieldType> ++ %% Record the length because varints may be non-optimally encoded. %% %% Groups can be nested, but assume the same FieldNum cannot be nested %% because group field numbers are shared with the rest of the fields %% numbers. Thus we can search just for an group-end with the same %% field number. %% %% (The only time the same group field number could occur would %% be in a nested sub message, but then it would be inside a %% length-delimited entry, which we skip-read by length.) read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) when N < (32-7) -> read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) -> Key = X bsl N + Acc, TagLen1 = TagLen + 1, case {Key bsr 3, Key band 7} of {FieldNum, 4} -> % 4 = group_end {NumBytes, TagLen1}; {_, 0} -> % 0 = varint read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); {_, 1} -> % 1 = bits64 <<_:64, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); {_, 2} -> % 2 = length_delimited read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); {_, 3} -> % 3 = group_start read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 4} -> % 4 = group_end read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 5} -> % 5 = bits32 <<_:32, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) end. read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) when N < (64-7) -> read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) when N < (64-7) -> read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> Len = X bsl N + Acc, NumBytes1 = NumBytes + 1, <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> merge_msg_empty(Prev, New, TrUserData); bool_value -> merge_msg_bool_value(Prev, New, TrUserData); payload -> merge_msg_payload(Prev, New, TrUserData); echo_status -> merge_msg_echo_status(Prev, New, TrUserData); simple_request -> merge_msg_simple_request(Prev, New, TrUserData); simple_response -> merge_msg_simple_response(Prev, New, TrUserData); streaming_input_call_request -> merge_msg_streaming_input_call_request(Prev, New, TrUserData); streaming_input_call_response -> merge_msg_streaming_input_call_response(Prev, New, TrUserData); response_parameters -> merge_msg_response_parameters(Prev, New, TrUserData); streaming_output_call_request -> merge_msg_streaming_output_call_request(Prev, New, TrUserData); streaming_output_call_response -> merge_msg_streaming_output_call_response(Prev, New, TrUserData); reconnect_params -> merge_msg_reconnect_params(Prev, New, TrUserData); reconnect_info -> merge_msg_reconnect_info(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_empty/3}). merge_msg_empty(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,merge_msg_bool_value/3}). merge_msg_bool_value(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{value := NFvalue}} -> S1#{value => NFvalue}; {#{value := PFvalue}, _} -> S1#{value => PFvalue}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_payload/3}). merge_msg_payload(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{type := NFtype}} -> S1#{type => NFtype}; {#{type := PFtype}, _} -> S1#{type => PFtype}; _ -> S1 end, case {PMsg, NMsg} of {_, #{body := NFbody}} -> S2#{body => NFbody}; {#{body := PFbody}, _} -> S2#{body => PFbody}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_echo_status/3}). merge_msg_echo_status(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{code := NFcode}} -> S1#{code => NFcode}; {#{code := PFcode}, _} -> S1#{code => PFcode}; _ -> S1 end, case {PMsg, NMsg} of {_, #{message := NFmessage}} -> S2#{message => NFmessage}; {#{message := PFmessage}, _} -> S2#{message => PFmessage}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_simple_request/3}). merge_msg_simple_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{response_type := NFresponse_type}} -> S1#{response_type => NFresponse_type}; {#{response_type := PFresponse_type}, _} -> S1#{response_type => PFresponse_type}; _ -> S1 end, S3 = case {PMsg, NMsg} of {_, #{response_size := NFresponse_size}} -> S2#{response_size => NFresponse_size}; {#{response_size := PFresponse_size}, _} -> S2#{response_size => PFresponse_size}; _ -> S2 end, S4 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S3#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S3#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S3#{payload => PFpayload}; {_, _} -> S3 end, S5 = case {PMsg, NMsg} of {_, #{fill_username := NFfill_username}} -> S4#{fill_username => NFfill_username}; {#{fill_username := PFfill_username}, _} -> S4#{fill_username => PFfill_username}; _ -> S4 end, S6 = case {PMsg, NMsg} of {_, #{fill_oauth_scope := NFfill_oauth_scope}} -> S5#{fill_oauth_scope => NFfill_oauth_scope}; {#{fill_oauth_scope := PFfill_oauth_scope}, _} -> S5#{fill_oauth_scope => PFfill_oauth_scope}; _ -> S5 end, S7 = case {PMsg, NMsg} of {#{response_compressed := PFresponse_compressed}, #{response_compressed := NFresponse_compressed}} -> S6#{response_compressed => merge_msg_bool_value(PFresponse_compressed, NFresponse_compressed, TrUserData)}; {_, #{response_compressed := NFresponse_compressed}} -> S6#{response_compressed => NFresponse_compressed}; {#{response_compressed := PFresponse_compressed}, _} -> S6#{response_compressed => PFresponse_compressed}; {_, _} -> S6 end, S8 = case {PMsg, NMsg} of {#{response_status := PFresponse_status}, #{response_status := NFresponse_status}} -> S7#{response_status => merge_msg_echo_status(PFresponse_status, NFresponse_status, TrUserData)}; {_, #{response_status := NFresponse_status}} -> S7#{response_status => NFresponse_status}; {#{response_status := PFresponse_status}, _} -> S7#{response_status => PFresponse_status}; {_, _} -> S7 end, case {PMsg, NMsg} of {#{expect_compressed := PFexpect_compressed}, #{expect_compressed := NFexpect_compressed}} -> S8#{expect_compressed => merge_msg_bool_value(PFexpect_compressed, NFexpect_compressed, TrUserData)}; {_, #{expect_compressed := NFexpect_compressed}} -> S8#{expect_compressed => NFexpect_compressed}; {#{expect_compressed := PFexpect_compressed}, _} -> S8#{expect_compressed => PFexpect_compressed}; {_, _} -> S8 end. -compile({nowarn_unused_function,merge_msg_simple_response/3}). merge_msg_simple_response(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end, S3 = case {PMsg, NMsg} of {_, #{username := NFusername}} -> S2#{username => NFusername}; {#{username := PFusername}, _} -> S2#{username => PFusername}; _ -> S2 end, case {PMsg, NMsg} of {_, #{oauth_scope := NFoauth_scope}} -> S3#{oauth_scope => NFoauth_scope}; {#{oauth_scope := PFoauth_scope}, _} -> S3#{oauth_scope => PFoauth_scope}; _ -> S3 end. -compile({nowarn_unused_function,merge_msg_streaming_input_call_request/3}). merge_msg_streaming_input_call_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end, case {PMsg, NMsg} of {#{expect_compressed := PFexpect_compressed}, #{expect_compressed := NFexpect_compressed}} -> S2#{expect_compressed => merge_msg_bool_value(PFexpect_compressed, NFexpect_compressed, TrUserData)}; {_, #{expect_compressed := NFexpect_compressed}} -> S2#{expect_compressed => NFexpect_compressed}; {#{expect_compressed := PFexpect_compressed}, _} -> S2#{expect_compressed => PFexpect_compressed}; {_, _} -> S2 end. -compile({nowarn_unused_function,merge_msg_streaming_input_call_response/3}). merge_msg_streaming_input_call_response(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{aggregated_payload_size := NFaggregated_payload_size}} -> S1#{aggregated_payload_size => NFaggregated_payload_size}; {#{aggregated_payload_size := PFaggregated_payload_size}, _} -> S1#{aggregated_payload_size => PFaggregated_payload_size}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_response_parameters/3}). merge_msg_response_parameters(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{size := NFsize}} -> S1#{size => NFsize}; {#{size := PFsize}, _} -> S1#{size => PFsize}; _ -> S1 end, S3 = case {PMsg, NMsg} of {_, #{interval_us := NFinterval_us}} -> S2#{interval_us => NFinterval_us}; {#{interval_us := PFinterval_us}, _} -> S2#{interval_us => PFinterval_us}; _ -> S2 end, case {PMsg, NMsg} of {#{compressed := PFcompressed}, #{compressed := NFcompressed}} -> S3#{compressed => merge_msg_bool_value(PFcompressed, NFcompressed, TrUserData)}; {_, #{compressed := NFcompressed}} -> S3#{compressed => NFcompressed}; {#{compressed := PFcompressed}, _} -> S3#{compressed => PFcompressed}; {_, _} -> S3 end. -compile({nowarn_unused_function,merge_msg_streaming_output_call_request/3}). merge_msg_streaming_output_call_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{response_type := NFresponse_type}} -> S1#{response_type => NFresponse_type}; {#{response_type := PFresponse_type}, _} -> S1#{response_type => PFresponse_type}; _ -> S1 end, S3 = case {PMsg, NMsg} of {#{response_parameters := PFresponse_parameters}, #{response_parameters := NFresponse_parameters}} -> S2#{response_parameters => 'erlang_++'(PFresponse_parameters, NFresponse_parameters, TrUserData)}; {_, #{response_parameters := NFresponse_parameters}} -> S2#{response_parameters => NFresponse_parameters}; {#{response_parameters := PFresponse_parameters}, _} -> S2#{response_parameters => PFresponse_parameters}; {_, _} -> S2 end, S4 = case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S3#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S3#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S3#{payload => PFpayload}; {_, _} -> S3 end, case {PMsg, NMsg} of {#{response_status := PFresponse_status}, #{response_status := NFresponse_status}} -> S4#{response_status => merge_msg_echo_status(PFresponse_status, NFresponse_status, TrUserData)}; {_, #{response_status := NFresponse_status}} -> S4#{response_status => NFresponse_status}; {#{response_status := PFresponse_status}, _} -> S4#{response_status => PFresponse_status}; {_, _} -> S4 end. -compile({nowarn_unused_function,merge_msg_streaming_output_call_response/3}). merge_msg_streaming_output_call_response(PMsg, NMsg, TrUserData) -> S1 = #{}, case {PMsg, NMsg} of {#{payload := PFpayload}, #{payload := NFpayload}} -> S1#{payload => merge_msg_payload(PFpayload, NFpayload, TrUserData)}; {_, #{payload := NFpayload}} -> S1#{payload => NFpayload}; {#{payload := PFpayload}, _} -> S1#{payload => PFpayload}; {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_reconnect_params/3}). merge_msg_reconnect_params(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{max_reconnect_backoff_ms := NFmax_reconnect_backoff_ms}} -> S1#{max_reconnect_backoff_ms => NFmax_reconnect_backoff_ms}; {#{max_reconnect_backoff_ms := PFmax_reconnect_backoff_ms}, _} -> S1#{max_reconnect_backoff_ms => PFmax_reconnect_backoff_ms}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_reconnect_info/3}). merge_msg_reconnect_info(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{passed := NFpassed}} -> S1#{passed => NFpassed}; {#{passed := PFpassed}, _} -> S1#{passed => PFpassed}; _ -> S1 end, case {PMsg, NMsg} of {#{backoff_ms := PFbackoff_ms}, #{backoff_ms := NFbackoff_ms}} -> S2#{backoff_ms => 'erlang_++'(PFbackoff_ms, NFbackoff_ms, TrUserData)}; {_, #{backoff_ms := NFbackoff_ms}} -> S2#{backoff_ms => NFbackoff_ms}; {#{backoff_ms := PFbackoff_ms}, _} -> S2#{backoff_ms => PFbackoff_ms}; {_, _} -> S2 end. verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> v_msg_empty(Msg, [MsgName], TrUserData); bool_value -> v_msg_bool_value(Msg, [MsgName], TrUserData); payload -> v_msg_payload(Msg, [MsgName], TrUserData); echo_status -> v_msg_echo_status(Msg, [MsgName], TrUserData); simple_request -> v_msg_simple_request(Msg, [MsgName], TrUserData); simple_response -> v_msg_simple_response(Msg, [MsgName], TrUserData); streaming_input_call_request -> v_msg_streaming_input_call_request(Msg, [MsgName], TrUserData); streaming_input_call_response -> v_msg_streaming_input_call_response(Msg, [MsgName], TrUserData); response_parameters -> v_msg_response_parameters(Msg, [MsgName], TrUserData); streaming_output_call_request -> v_msg_streaming_output_call_request(Msg, [MsgName], TrUserData); streaming_output_call_response -> v_msg_streaming_output_call_response(Msg, [MsgName], TrUserData); reconnect_params -> v_msg_reconnect_params(Msg, [MsgName], TrUserData); reconnect_info -> v_msg_reconnect_info(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_empty/3}). -dialyzer({nowarn_function,v_msg_empty/3}). v_msg_empty(#{} = M, Path, _) -> lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). -compile({nowarn_unused_function,v_msg_bool_value/3}). -dialyzer({nowarn_function,v_msg_bool_value/3}). v_msg_bool_value(#{} = M, Path, TrUserData) -> case M of #{value := F1} -> v_type_bool(F1, [value | Path], TrUserData); _ -> ok end, lists:foreach(fun (value) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_bool_value(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), bool_value}, M, Path); v_msg_bool_value(X, Path, _TrUserData) -> mk_type_error({expected_msg, bool_value}, X, Path). -compile({nowarn_unused_function,v_msg_payload/3}). -dialyzer({nowarn_function,v_msg_payload/3}). v_msg_payload(#{} = M, Path, TrUserData) -> case M of #{type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [type | Path], TrUserData); _ -> ok end, case M of #{body := F2} -> v_type_bytes(F2, [body | Path], TrUserData); _ -> ok end, lists:foreach(fun (type) -> ok; (body) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_payload(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), payload}, M, Path); v_msg_payload(X, Path, _TrUserData) -> mk_type_error({expected_msg, payload}, X, Path). -compile({nowarn_unused_function,v_msg_echo_status/3}). -dialyzer({nowarn_function,v_msg_echo_status/3}). v_msg_echo_status(#{} = M, Path, TrUserData) -> case M of #{code := F1} -> v_type_int32(F1, [code | Path], TrUserData); _ -> ok end, case M of #{message := F2} -> v_type_string(F2, [message | Path], TrUserData); _ -> ok end, lists:foreach(fun (code) -> ok; (message) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_echo_status(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), echo_status}, M, Path); v_msg_echo_status(X, Path, _TrUserData) -> mk_type_error({expected_msg, echo_status}, X, Path). -compile({nowarn_unused_function,v_msg_simple_request/3}). -dialyzer({nowarn_function,v_msg_simple_request/3}). v_msg_simple_request(#{} = M, Path, TrUserData) -> case M of #{response_type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [response_type | Path], TrUserData); _ -> ok end, case M of #{response_size := F2} -> v_type_int32(F2, [response_size | Path], TrUserData); _ -> ok end, case M of #{payload := F3} -> v_msg_payload(F3, [payload | Path], TrUserData); _ -> ok end, case M of #{fill_username := F4} -> v_type_bool(F4, [fill_username | Path], TrUserData); _ -> ok end, case M of #{fill_oauth_scope := F5} -> v_type_bool(F5, [fill_oauth_scope | Path], TrUserData); _ -> ok end, case M of #{response_compressed := F6} -> v_msg_bool_value(F6, [response_compressed | Path], TrUserData); _ -> ok end, case M of #{response_status := F7} -> v_msg_echo_status(F7, [response_status | Path], TrUserData); _ -> ok end, case M of #{expect_compressed := F8} -> v_msg_bool_value(F8, [expect_compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (response_type) -> ok; (response_size) -> ok; (payload) -> ok; (fill_username) -> ok; (fill_oauth_scope) -> ok; (response_compressed) -> ok; (response_status) -> ok; (expect_compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_simple_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), simple_request}, M, Path); v_msg_simple_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, simple_request}, X, Path). -compile({nowarn_unused_function,v_msg_simple_response/3}). -dialyzer({nowarn_function,v_msg_simple_response/3}). v_msg_simple_response(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, case M of #{username := F2} -> v_type_string(F2, [username | Path], TrUserData); _ -> ok end, case M of #{oauth_scope := F3} -> v_type_string(F3, [oauth_scope | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (username) -> ok; (oauth_scope) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_simple_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), simple_response}, M, Path); v_msg_simple_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, simple_response}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_input_call_request/3}). -dialyzer({nowarn_function,v_msg_streaming_input_call_request/3}). v_msg_streaming_input_call_request(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, case M of #{expect_compressed := F2} -> v_msg_bool_value(F2, [expect_compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (expect_compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_input_call_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_input_call_request}, M, Path); v_msg_streaming_input_call_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_input_call_request}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_input_call_response/3}). -dialyzer({nowarn_function,v_msg_streaming_input_call_response/3}). v_msg_streaming_input_call_response(#{} = M, Path, TrUserData) -> case M of #{aggregated_payload_size := F1} -> v_type_int32(F1, [aggregated_payload_size | Path], TrUserData); _ -> ok end, lists:foreach(fun (aggregated_payload_size) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_input_call_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_input_call_response}, M, Path); v_msg_streaming_input_call_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_input_call_response}, X, Path). -compile({nowarn_unused_function,v_msg_response_parameters/3}). -dialyzer({nowarn_function,v_msg_response_parameters/3}). v_msg_response_parameters(#{} = M, Path, TrUserData) -> case M of #{size := F1} -> v_type_int32(F1, [size | Path], TrUserData); _ -> ok end, case M of #{interval_us := F2} -> v_type_int32(F2, [interval_us | Path], TrUserData); _ -> ok end, case M of #{compressed := F3} -> v_msg_bool_value(F3, [compressed | Path], TrUserData); _ -> ok end, lists:foreach(fun (size) -> ok; (interval_us) -> ok; (compressed) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_response_parameters(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), response_parameters}, M, Path); v_msg_response_parameters(X, Path, _TrUserData) -> mk_type_error({expected_msg, response_parameters}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_output_call_request/3}). -dialyzer({nowarn_function,v_msg_streaming_output_call_request/3}). v_msg_streaming_output_call_request(#{} = M, Path, TrUserData) -> case M of #{response_type := F1} -> 'v_enum_grpc.testing.PayloadType'(F1, [response_type | Path], TrUserData); _ -> ok end, case M of #{response_parameters := F2} -> if is_list(F2) -> _ = [v_msg_response_parameters(Elem, [response_parameters | Path], TrUserData) || Elem <- F2], ok; true -> mk_type_error({invalid_list_of, {msg, response_parameters}}, F2, [response_parameters | Path]) end; _ -> ok end, case M of #{payload := F3} -> v_msg_payload(F3, [payload | Path], TrUserData); _ -> ok end, case M of #{response_status := F4} -> v_msg_echo_status(F4, [response_status | Path], TrUserData); _ -> ok end, lists:foreach(fun (response_type) -> ok; (response_parameters) -> ok; (payload) -> ok; (response_status) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_output_call_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_output_call_request}, M, Path); v_msg_streaming_output_call_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_output_call_request}, X, Path). -compile({nowarn_unused_function,v_msg_streaming_output_call_response/3}). -dialyzer({nowarn_function,v_msg_streaming_output_call_response/3}). v_msg_streaming_output_call_response(#{} = M, Path, TrUserData) -> case M of #{payload := F1} -> v_msg_payload(F1, [payload | Path], TrUserData); _ -> ok end, lists:foreach(fun (payload) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_streaming_output_call_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), streaming_output_call_response}, M, Path); v_msg_streaming_output_call_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, streaming_output_call_response}, X, Path). -compile({nowarn_unused_function,v_msg_reconnect_params/3}). -dialyzer({nowarn_function,v_msg_reconnect_params/3}). v_msg_reconnect_params(#{} = M, Path, TrUserData) -> case M of #{max_reconnect_backoff_ms := F1} -> v_type_int32(F1, [max_reconnect_backoff_ms | Path], TrUserData); _ -> ok end, lists:foreach(fun (max_reconnect_backoff_ms) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_reconnect_params(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), reconnect_params}, M, Path); v_msg_reconnect_params(X, Path, _TrUserData) -> mk_type_error({expected_msg, reconnect_params}, X, Path). -compile({nowarn_unused_function,v_msg_reconnect_info/3}). -dialyzer({nowarn_function,v_msg_reconnect_info/3}). v_msg_reconnect_info(#{} = M, Path, TrUserData) -> case M of #{passed := F1} -> v_type_bool(F1, [passed | Path], TrUserData); _ -> ok end, case M of #{backoff_ms := F2} -> if is_list(F2) -> _ = [v_type_int32(Elem, [backoff_ms | Path], TrUserData) || Elem <- F2], ok; true -> mk_type_error({invalid_list_of, int32}, F2, [backoff_ms | Path]) end; _ -> ok end, lists:foreach(fun (passed) -> ok; (backoff_ms) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_reconnect_info(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), reconnect_info}, M, Path); v_msg_reconnect_info(X, Path, _TrUserData) -> mk_type_error({expected_msg, reconnect_info}, X, Path). -compile({nowarn_unused_function,'v_enum_grpc.testing.PayloadType'/3}). -dialyzer({nowarn_function,'v_enum_grpc.testing.PayloadType'/3}). 'v_enum_grpc.testing.PayloadType'('COMPRESSABLE', _Path, _TrUserData) -> ok; 'v_enum_grpc.testing.PayloadType'(V, Path, TrUserData) when is_integer(V) -> v_type_sint32(V, Path, TrUserData); 'v_enum_grpc.testing.PayloadType'(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'grpc.testing.PayloadType'}, X, Path). -compile({nowarn_unused_function,v_type_sint32/3}). -dialyzer({nowarn_function,v_type_sint32/3}). v_type_sint32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_sint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, sint32, signed, 32}, N, Path); v_type_sint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, sint32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -dialyzer({nowarn_function,v_type_int32/3}). v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_bool/3}). -dialyzer({nowarn_function,v_type_bool/3}). v_type_bool(false, _Path, _TrUserData) -> ok; v_type_bool(true, _Path, _TrUserData) -> ok; v_type_bool(0, _Path, _TrUserData) -> ok; v_type_bool(1, _Path, _TrUserData) -> ok; v_type_bool(X, Path, _TrUserData) -> mk_type_error(bad_boolean_value, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,v_type_bytes/3}). -dialyzer({nowarn_function,v_type_bytes/3}). v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; prettify_path(PathR) -> list_to_atom(lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR))))). -compile({nowarn_unused_function,id/2}). -compile({inline,id/2}). id(X, _TrUserData) -> X. -compile({nowarn_unused_function,v_ok/3}). -compile({inline,v_ok/3}). v_ok(_Value, _Path, _TrUserData) -> ok. -compile({nowarn_unused_function,m_overwrite/3}). -compile({inline,m_overwrite/3}). m_overwrite(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. -compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). -compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. get_msg_defs() -> [{{enum, 'grpc.testing.PayloadType'}, [{'COMPRESSABLE', 0}]}, {{msg, empty}, []}, {{msg, bool_value}, [#{name => value, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}]}, {{msg, payload}, [#{name => type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => body, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]}, {{msg, echo_status}, [#{name => code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, {{msg, simple_request}, [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_size, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => fill_username, fnum => 4, rnum => 5, type => bool, occurrence => optional, opts => []}, #{name => fill_oauth_scope, fnum => 5, rnum => 6, type => bool, occurrence => optional, opts => []}, #{name => response_compressed, fnum => 6, rnum => 7, type => {msg, bool_value}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 8, type => {msg, echo_status}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 8, rnum => 9, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, simple_response}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => username, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => oauth_scope, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]}, {{msg, streaming_input_call_request}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 2, rnum => 3, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, streaming_input_call_response}, [#{name => aggregated_payload_size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]}, {{msg, response_parameters}, [#{name => size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => interval_us, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => compressed, fnum => 3, rnum => 4, type => {msg, bool_value}, occurrence => optional, opts => []}]}, {{msg, streaming_output_call_request}, [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_parameters, fnum => 2, rnum => 3, type => {msg, response_parameters}, occurrence => repeated, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 5, type => {msg, echo_status}, occurrence => optional, opts => []}]}, {{msg, streaming_output_call_response}, [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}]}, {{msg, reconnect_params}, [#{name => max_reconnect_backoff_ms, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]}, {{msg, reconnect_info}, [#{name => passed, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}, #{name => backoff_ms, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]}]. get_msg_names() -> [empty, bool_value, payload, echo_status, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, response_parameters, streaming_output_call_request, streaming_output_call_response, reconnect_params, reconnect_info]. get_group_names() -> []. get_msg_or_group_names() -> [empty, bool_value, payload, echo_status, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, response_parameters, streaming_output_call_request, streaming_output_call_response, reconnect_params, reconnect_info]. get_enum_names() -> ['grpc.testing.PayloadType']. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of Fs when is_list(Fs) -> Fs; error -> erlang:error({no_such_msg, MsgName}) end. fetch_enum_def(EnumName) -> case find_enum_def(EnumName) of Es when is_list(Es) -> Es; error -> erlang:error({no_such_enum, EnumName}) end. find_msg_def(empty) -> []; find_msg_def(bool_value) -> [#{name => value, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}]; find_msg_def(payload) -> [#{name => type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => body, fnum => 2, rnum => 3, type => bytes, occurrence => optional, opts => []}]; find_msg_def(echo_status) -> [#{name => code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; find_msg_def(simple_request) -> [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_size, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => fill_username, fnum => 4, rnum => 5, type => bool, occurrence => optional, opts => []}, #{name => fill_oauth_scope, fnum => 5, rnum => 6, type => bool, occurrence => optional, opts => []}, #{name => response_compressed, fnum => 6, rnum => 7, type => {msg, bool_value}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 8, type => {msg, echo_status}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 8, rnum => 9, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(simple_response) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => username, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => oauth_scope, fnum => 3, rnum => 4, type => string, occurrence => optional, opts => []}]; find_msg_def(streaming_input_call_request) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}, #{name => expect_compressed, fnum => 2, rnum => 3, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(streaming_input_call_response) -> [#{name => aggregated_payload_size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]; find_msg_def(response_parameters) -> [#{name => size, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => interval_us, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => compressed, fnum => 3, rnum => 4, type => {msg, bool_value}, occurrence => optional, opts => []}]; find_msg_def(streaming_output_call_request) -> [#{name => response_type, fnum => 1, rnum => 2, type => {enum, 'grpc.testing.PayloadType'}, occurrence => optional, opts => []}, #{name => response_parameters, fnum => 2, rnum => 3, type => {msg, response_parameters}, occurrence => repeated, opts => []}, #{name => payload, fnum => 3, rnum => 4, type => {msg, payload}, occurrence => optional, opts => []}, #{name => response_status, fnum => 7, rnum => 5, type => {msg, echo_status}, occurrence => optional, opts => []}]; find_msg_def(streaming_output_call_response) -> [#{name => payload, fnum => 1, rnum => 2, type => {msg, payload}, occurrence => optional, opts => []}]; find_msg_def(reconnect_params) -> [#{name => max_reconnect_backoff_ms, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}]; find_msg_def(reconnect_info) -> [#{name => passed, fnum => 1, rnum => 2, type => bool, occurrence => optional, opts => []}, #{name => backoff_ms, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]; find_msg_def(_) -> error. find_enum_def('grpc.testing.PayloadType') -> [{'COMPRESSABLE', 0}]; find_enum_def(_) -> error. enum_symbol_by_value('grpc.testing.PayloadType', Value) -> 'enum_symbol_by_value_grpc.testing.PayloadType'(Value). enum_value_by_symbol('grpc.testing.PayloadType', Sym) -> 'enum_value_by_symbol_grpc.testing.PayloadType'(Sym). 'enum_symbol_by_value_grpc.testing.PayloadType'(0) -> 'COMPRESSABLE'. 'enum_value_by_symbol_grpc.testing.PayloadType'('COMPRESSABLE') -> 0. get_service_names() -> ['grpc.testing.TestService', 'grpc.testing.UnimplementedService', 'grpc.testing.ReconnectService']. get_service_def('grpc.testing.TestService') -> {{service, 'grpc.testing.TestService'}, [#{name => 'EmptyCall', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}, #{name => 'UnaryCall', input => simple_request, output => simple_response, input_stream => false, output_stream => false, opts => []}, #{name => 'CacheableUnaryCall', input => simple_request, output => simple_response, input_stream => false, output_stream => false, opts => []}, #{name => 'StreamingOutputCall', input => streaming_output_call_request, output => streaming_output_call_response, input_stream => false, output_stream => true, opts => []}, #{name => 'StreamingInputCall', input => streaming_input_call_request, output => streaming_input_call_response, input_stream => true, output_stream => false, opts => []}, #{name => 'FullDuplexCall', input => streaming_output_call_request, output => streaming_output_call_response, input_stream => true, output_stream => true, opts => []}, #{name => 'HalfDuplexCall', input => streaming_output_call_request, output => streaming_output_call_response, input_stream => true, output_stream => true, opts => []}, #{name => 'UnimplementedCall', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}]}; get_service_def('grpc.testing.UnimplementedService') -> {{service, 'grpc.testing.UnimplementedService'}, [#{name => 'UnimplementedCall', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}]}; get_service_def('grpc.testing.ReconnectService') -> {{service, 'grpc.testing.ReconnectService'}, [#{name => 'Start', input => reconnect_params, output => empty, input_stream => false, output_stream => false, opts => []}, #{name => 'Stop', input => empty, output => reconnect_info, input_stream => false, output_stream => false, opts => []}]}; get_service_def(_) -> error. get_rpc_names('grpc.testing.TestService') -> ['EmptyCall', 'UnaryCall', 'CacheableUnaryCall', 'StreamingOutputCall', 'StreamingInputCall', 'FullDuplexCall', 'HalfDuplexCall', 'UnimplementedCall']; get_rpc_names('grpc.testing.UnimplementedService') -> ['UnimplementedCall']; get_rpc_names('grpc.testing.ReconnectService') -> ['Start', 'Stop']; get_rpc_names(_) -> error. find_rpc_def('grpc.testing.TestService', RpcName) -> 'find_rpc_def_grpc.testing.TestService'(RpcName); find_rpc_def('grpc.testing.UnimplementedService', RpcName) -> 'find_rpc_def_grpc.testing.UnimplementedService'(RpcName); find_rpc_def('grpc.testing.ReconnectService', RpcName) -> 'find_rpc_def_grpc.testing.ReconnectService'(RpcName); find_rpc_def(_, _) -> error. 'find_rpc_def_grpc.testing.TestService'('EmptyCall') -> #{name => 'EmptyCall', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.TestService'('UnaryCall') -> #{name => 'UnaryCall', input => simple_request, output => simple_response, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.TestService'('CacheableUnaryCall') -> #{name => 'CacheableUnaryCall', input => simple_request, output => simple_response, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.TestService'('StreamingOutputCall') -> #{name => 'StreamingOutputCall', input => streaming_output_call_request, output => streaming_output_call_response, input_stream => false, output_stream => true, opts => []}; 'find_rpc_def_grpc.testing.TestService'('StreamingInputCall') -> #{name => 'StreamingInputCall', input => streaming_input_call_request, output => streaming_input_call_response, input_stream => true, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.TestService'('FullDuplexCall') -> #{name => 'FullDuplexCall', input => streaming_output_call_request, output => streaming_output_call_response, input_stream => true, output_stream => true, opts => []}; 'find_rpc_def_grpc.testing.TestService'('HalfDuplexCall') -> #{name => 'HalfDuplexCall', input => streaming_output_call_request, output => streaming_output_call_response, input_stream => true, output_stream => true, opts => []}; 'find_rpc_def_grpc.testing.TestService'('UnimplementedCall') -> #{name => 'UnimplementedCall', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.TestService'(_) -> error. 'find_rpc_def_grpc.testing.UnimplementedService'('UnimplementedCall') -> #{name => 'UnimplementedCall', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.UnimplementedService'(_) -> error. 'find_rpc_def_grpc.testing.ReconnectService'('Start') -> #{name => 'Start', input => reconnect_params, output => empty, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.ReconnectService'('Stop') -> #{name => 'Stop', input => empty, output => reconnect_info, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.testing.ReconnectService'(_) -> error. fetch_rpc_def(ServiceName, RpcName) -> case find_rpc_def(ServiceName, RpcName) of Def when is_map(Def) -> Def; error -> erlang:error({no_such_rpc, ServiceName, RpcName}) end. %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. fqbin_to_service_name(<<"grpc.testing.TestService">>) -> 'grpc.testing.TestService'; fqbin_to_service_name(<<"grpc.testing.UnimplementedService">>) -> 'grpc.testing.UnimplementedService'; fqbin_to_service_name(<<"grpc.testing.ReconnectService">>) -> 'grpc.testing.ReconnectService'; fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. service_name_to_fqbin('grpc.testing.TestService') -> <<"grpc.testing.TestService">>; service_name_to_fqbin('grpc.testing.UnimplementedService') -> <<"grpc.testing.UnimplementedService">>; service_name_to_fqbin('grpc.testing.ReconnectService') -> <<"grpc.testing.ReconnectService">>; service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"EmptyCall">>) -> {'grpc.testing.TestService', 'EmptyCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"UnaryCall">>) -> {'grpc.testing.TestService', 'UnaryCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"CacheableUnaryCall">>) -> {'grpc.testing.TestService', 'CacheableUnaryCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"StreamingOutputCall">>) -> {'grpc.testing.TestService', 'StreamingOutputCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"StreamingInputCall">>) -> {'grpc.testing.TestService', 'StreamingInputCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"FullDuplexCall">>) -> {'grpc.testing.TestService', 'FullDuplexCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"HalfDuplexCall">>) -> {'grpc.testing.TestService', 'HalfDuplexCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.TestService">>, <<"UnimplementedCall">>) -> {'grpc.testing.TestService', 'UnimplementedCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.UnimplementedService">>, <<"UnimplementedCall">>) -> {'grpc.testing.UnimplementedService', 'UnimplementedCall'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.ReconnectService">>, <<"Start">>) -> {'grpc.testing.ReconnectService', 'Start'}; fqbins_to_service_and_rpc_name(<<"grpc.testing.ReconnectService">>, <<"Stop">>) -> {'grpc.testing.ReconnectService', 'Stop'}; fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'EmptyCall') -> {<<"grpc.testing.TestService">>, <<"EmptyCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'UnaryCall') -> {<<"grpc.testing.TestService">>, <<"UnaryCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'CacheableUnaryCall') -> {<<"grpc.testing.TestService">>, <<"CacheableUnaryCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'StreamingOutputCall') -> {<<"grpc.testing.TestService">>, <<"StreamingOutputCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'StreamingInputCall') -> {<<"grpc.testing.TestService">>, <<"StreamingInputCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'FullDuplexCall') -> {<<"grpc.testing.TestService">>, <<"FullDuplexCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'HalfDuplexCall') -> {<<"grpc.testing.TestService">>, <<"HalfDuplexCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.TestService', 'UnimplementedCall') -> {<<"grpc.testing.TestService">>, <<"UnimplementedCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.UnimplementedService', 'UnimplementedCall') -> {<<"grpc.testing.UnimplementedService">>, <<"UnimplementedCall">>}; service_and_rpc_name_to_fqbins('grpc.testing.ReconnectService', 'Start') -> {<<"grpc.testing.ReconnectService">>, <<"Start">>}; service_and_rpc_name_to_fqbins('grpc.testing.ReconnectService', 'Stop') -> {<<"grpc.testing.ReconnectService">>, <<"Stop">>}; service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"grpc.testing.Empty">>) -> empty; fqbin_to_msg_name(<<"grpc.testing.BoolValue">>) -> bool_value; fqbin_to_msg_name(<<"grpc.testing.Payload">>) -> payload; fqbin_to_msg_name(<<"grpc.testing.EchoStatus">>) -> echo_status; fqbin_to_msg_name(<<"grpc.testing.SimpleRequest">>) -> simple_request; fqbin_to_msg_name(<<"grpc.testing.SimpleResponse">>) -> simple_response; fqbin_to_msg_name(<<"grpc.testing.StreamingInputCallRequest">>) -> streaming_input_call_request; fqbin_to_msg_name(<<"grpc.testing.StreamingInputCallResponse">>) -> streaming_input_call_response; fqbin_to_msg_name(<<"grpc.testing.ResponseParameters">>) -> response_parameters; fqbin_to_msg_name(<<"grpc.testing.StreamingOutputCallRequest">>) -> streaming_output_call_request; fqbin_to_msg_name(<<"grpc.testing.StreamingOutputCallResponse">>) -> streaming_output_call_response; fqbin_to_msg_name(<<"grpc.testing.ReconnectParams">>) -> reconnect_params; fqbin_to_msg_name(<<"grpc.testing.ReconnectInfo">>) -> reconnect_info; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin(empty) -> <<"grpc.testing.Empty">>; msg_name_to_fqbin(bool_value) -> <<"grpc.testing.BoolValue">>; msg_name_to_fqbin(payload) -> <<"grpc.testing.Payload">>; msg_name_to_fqbin(echo_status) -> <<"grpc.testing.EchoStatus">>; msg_name_to_fqbin(simple_request) -> <<"grpc.testing.SimpleRequest">>; msg_name_to_fqbin(simple_response) -> <<"grpc.testing.SimpleResponse">>; msg_name_to_fqbin(streaming_input_call_request) -> <<"grpc.testing.StreamingInputCallRequest">>; msg_name_to_fqbin(streaming_input_call_response) -> <<"grpc.testing.StreamingInputCallResponse">>; msg_name_to_fqbin(response_parameters) -> <<"grpc.testing.ResponseParameters">>; msg_name_to_fqbin(streaming_output_call_request) -> <<"grpc.testing.StreamingOutputCallRequest">>; msg_name_to_fqbin(streaming_output_call_response) -> <<"grpc.testing.StreamingOutputCallResponse">>; msg_name_to_fqbin(reconnect_params) -> <<"grpc.testing.ReconnectParams">>; msg_name_to_fqbin(reconnect_info) -> <<"grpc.testing.ReconnectInfo">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). fqbin_to_enum_name(<<"grpc.testing.PayloadType">>) -> 'grpc.testing.PayloadType'; fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). enum_name_to_fqbin('grpc.testing.PayloadType') -> <<"grpc.testing.PayloadType">>; enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'grpc.testing'. %% Whether or not the message names %% are prepended with package name or not. uses_packages() -> true. source_basename() -> "test.proto". %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension get_all_source_basenames() -> ["test.proto", "empty.proto", "messages.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. get_all_proto_names() -> ["test", "empty", "messages"]. get_msg_containment("test") -> []; get_msg_containment("empty") -> [empty]; get_msg_containment("messages") -> [bool_value, echo_status, payload, reconnect_info, reconnect_params, response_parameters, simple_request, simple_response, streaming_input_call_request, streaming_input_call_response, streaming_output_call_request, streaming_output_call_response]; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("test") -> 'grpc.testing'; get_pkg_containment("empty") -> 'grpc.testing'; get_pkg_containment("messages") -> 'grpc.testing'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("test") -> ['grpc.testing.ReconnectService', 'grpc.testing.TestService', 'grpc.testing.UnimplementedService']; get_service_containment("empty") -> []; get_service_containment("messages") -> []; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("test") -> [{'grpc.testing.TestService', 'EmptyCall'}, {'grpc.testing.TestService', 'UnaryCall'}, {'grpc.testing.TestService', 'CacheableUnaryCall'}, {'grpc.testing.TestService', 'StreamingOutputCall'}, {'grpc.testing.TestService', 'StreamingInputCall'}, {'grpc.testing.TestService', 'FullDuplexCall'}, {'grpc.testing.TestService', 'HalfDuplexCall'}, {'grpc.testing.TestService', 'UnimplementedCall'}, {'grpc.testing.UnimplementedService', 'UnimplementedCall'}, {'grpc.testing.ReconnectService', 'Start'}, {'grpc.testing.ReconnectService', 'Stop'}]; get_rpc_containment("empty") -> []; get_rpc_containment("messages") -> []; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("test") -> []; get_enum_containment("empty") -> []; get_enum_containment("messages") -> ['grpc.testing.PayloadType']; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ResponseParameters">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ReconnectParams">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.EchoStatus">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingOutputCallRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingInputCallRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.SimpleRequest">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.Payload">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingOutputCallResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.StreamingInputCallResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.SimpleResponse">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.BoolValue">>) -> "messages"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.Empty">>) -> "empty"; get_proto_by_msg_name_as_fqbin(<<"grpc.testing.ReconnectInfo">>) -> "messages"; get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). get_proto_by_service_name_as_fqbin(<<"grpc.testing.UnimplementedService">>) -> "test"; get_proto_by_service_name_as_fqbin(<<"grpc.testing.TestService">>) -> "test"; get_proto_by_service_name_as_fqbin(<<"grpc.testing.ReconnectService">>) -> "test"; get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). get_proto_by_enum_name_as_fqbin(<<"grpc.testing.PayloadType">>) -> "messages"; get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). get_protos_by_pkg_name_as_fqbin(<<"grpc.testing">>) -> ["empty", "messages", "test"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). descriptor() -> <<10, 128, 8, 10, 23, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 116, 101, 115, 116, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 50, 223, 5, 10, 11, 84, 101, 115, 116, 83, 101, 114, 118, 105, 99, 101, 18, 57, 10, 9, 69, 109, 112, 116, 121, 67, 97, 108, 108, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 74, 10, 9, 85, 110, 97, 114, 121, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 83, 10, 18, 67, 97, 99, 104, 101, 97, 98, 108, 101, 85, 110, 97, 114, 121, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 110, 10, 19, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 18, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 41, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 107, 10, 18, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 18, 39, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 105, 10, 14, 70, 117, 108, 108, 68, 117, 112, 108, 101, 120, 67, 97, 108, 108, 18, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 41, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 105, 10, 14, 72, 97, 108, 102, 68, 117, 112, 108, 101, 120, 67, 97, 108, 108, 18, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 41, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 65, 10, 17, 85, 110, 105, 109, 112, 108, 101, 109, 101, 110, 116, 101, 100, 67, 97, 108, 108, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 50, 89, 10, 20, 85, 110, 105, 109, 112, 108, 101, 109, 101, 110, 116, 101, 100, 83, 101, 114, 118, 105, 99, 101, 18, 65, 10, 17, 85, 110, 105, 109, 112, 108, 101, 109, 101, 110, 116, 101, 100, 67, 97, 108, 108, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 50, 145, 1, 10, 16, 82, 101, 99, 111, 110, 110, 101, 99, 116, 83, 101, 114, 118, 105, 99, 101, 18, 63, 10, 5, 83, 116, 97, 114, 116, 18, 29, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 60, 10, 4, 83, 116, 111, 112, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51, 10, 57, 10, 24, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 101, 109, 112, 116, 121, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 7, 10, 5, 69, 109, 112, 116, 121, 98, 6, 112, 114, 111, 116, 111, 51, 10, 215, 10, 10, 27, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 109, 101, 115, 115, 97, 103, 101, 115, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 26, 10, 9, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 13, 10, 5, 118, 97, 108, 117, 101, 24, 1, 32, 1, 40, 8, 34, 43, 10, 10, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 12, 10, 4, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 64, 10, 7, 80, 97, 121, 108, 111, 97, 100, 18, 39, 10, 4, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 12, 10, 4, 98, 111, 100, 121, 24, 2, 32, 1, 40, 12, 34, 63, 10, 13, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 18, 14, 10, 6, 112, 97, 115, 115, 101, 100, 24, 1, 32, 1, 40, 8, 18, 30, 10, 10, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 51, 10, 15, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 18, 32, 10, 24, 109, 97, 120, 95, 114, 101, 99, 111, 110, 110, 101, 99, 116, 95, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 1, 32, 1, 40, 5, 34, 100, 10, 18, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 12, 10, 4, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 18, 19, 10, 11, 105, 110, 116, 101, 114, 118, 97, 108, 95, 117, 115, 24, 2, 32, 1, 40, 5, 18, 43, 10, 10, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 3, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 206, 2, 10, 13, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 21, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 105, 122, 101, 24, 2, 32, 1, 40, 5, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 21, 10, 13, 102, 105, 108, 108, 95, 117, 115, 101, 114, 110, 97, 109, 101, 24, 4, 32, 1, 40, 8, 18, 24, 10, 16, 102, 105, 108, 108, 95, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 5, 32, 1, 40, 8, 18, 52, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 6, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 8, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 95, 10, 14, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 16, 10, 8, 117, 115, 101, 114, 110, 97, 109, 101, 24, 2, 32, 1, 40, 9, 18, 19, 10, 11, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 3, 32, 1, 40, 9, 34, 119, 10, 25, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 2, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 61, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 31, 10, 23, 97, 103, 103, 114, 101, 103, 97, 116, 101, 100, 95, 112, 97, 121, 108, 111, 97, 100, 95, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 34, 232, 1, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 61, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 24, 2, 32, 3, 40, 11, 50, 32, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 34, 69, 10, 27, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 42, 31, 10, 11, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 16, 10, 12, 67, 79, 77, 80, 82, 69, 83, 83, 65, 66, 76, 69, 16, 0, 98, 6, 112, 114, 111, 116, 111, 51>>. descriptor("test") -> <<10, 23, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 116, 101, 115, 116, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 50, 223, 5, 10, 11, 84, 101, 115, 116, 83, 101, 114, 118, 105, 99, 101, 18, 57, 10, 9, 69, 109, 112, 116, 121, 67, 97, 108, 108, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 74, 10, 9, 85, 110, 97, 114, 121, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 83, 10, 18, 67, 97, 99, 104, 101, 97, 98, 108, 101, 85, 110, 97, 114, 121, 67, 97, 108, 108, 18, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 26, 28, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 110, 10, 19, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 18, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 41, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 107, 10, 18, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 18, 39, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 105, 10, 14, 70, 117, 108, 108, 68, 117, 112, 108, 101, 120, 67, 97, 108, 108, 18, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 41, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 105, 10, 14, 72, 97, 108, 102, 68, 117, 112, 108, 101, 120, 67, 97, 108, 108, 18, 40, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 26, 41, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 65, 10, 17, 85, 110, 105, 109, 112, 108, 101, 109, 101, 110, 116, 101, 100, 67, 97, 108, 108, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 50, 89, 10, 20, 85, 110, 105, 109, 112, 108, 101, 109, 101, 110, 116, 101, 100, 83, 101, 114, 118, 105, 99, 101, 18, 65, 10, 17, 85, 110, 105, 109, 112, 108, 101, 109, 101, 110, 116, 101, 100, 67, 97, 108, 108, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 50, 145, 1, 10, 16, 82, 101, 99, 111, 110, 110, 101, 99, 116, 83, 101, 114, 118, 105, 99, 101, 18, 63, 10, 5, 83, 116, 97, 114, 116, 18, 29, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 26, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 60, 10, 4, 83, 116, 111, 112, 18, 19, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 109, 112, 116, 121, 26, 27, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor("empty") -> <<10, 24, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 101, 109, 112, 116, 121, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 7, 10, 5, 69, 109, 112, 116, 121, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor("messages") -> <<10, 27, 103, 114, 112, 99, 47, 116, 101, 115, 116, 105, 110, 103, 47, 109, 101, 115, 115, 97, 103, 101, 115, 46, 112, 114, 111, 116, 111, 18, 12, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 34, 26, 10, 9, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 13, 10, 5, 118, 97, 108, 117, 101, 24, 1, 32, 1, 40, 8, 34, 43, 10, 10, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 12, 10, 4, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 64, 10, 7, 80, 97, 121, 108, 111, 97, 100, 18, 39, 10, 4, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 12, 10, 4, 98, 111, 100, 121, 24, 2, 32, 1, 40, 12, 34, 63, 10, 13, 82, 101, 99, 111, 110, 110, 101, 99, 116, 73, 110, 102, 111, 18, 14, 10, 6, 112, 97, 115, 115, 101, 100, 24, 1, 32, 1, 40, 8, 18, 30, 10, 10, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 51, 10, 15, 82, 101, 99, 111, 110, 110, 101, 99, 116, 80, 97, 114, 97, 109, 115, 18, 32, 10, 24, 109, 97, 120, 95, 114, 101, 99, 111, 110, 110, 101, 99, 116, 95, 98, 97, 99, 107, 111, 102, 102, 95, 109, 115, 24, 1, 32, 1, 40, 5, 34, 100, 10, 18, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 12, 10, 4, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 18, 19, 10, 11, 105, 110, 116, 101, 114, 118, 97, 108, 95, 117, 115, 24, 2, 32, 1, 40, 5, 18, 43, 10, 10, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 3, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 206, 2, 10, 13, 83, 105, 109, 112, 108, 101, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 21, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 105, 122, 101, 24, 2, 32, 1, 40, 5, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 21, 10, 13, 102, 105, 108, 108, 95, 117, 115, 101, 114, 110, 97, 109, 101, 24, 4, 32, 1, 40, 8, 18, 24, 10, 16, 102, 105, 108, 108, 95, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 5, 32, 1, 40, 8, 18, 52, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 6, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 8, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 95, 10, 14, 83, 105, 109, 112, 108, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 16, 10, 8, 117, 115, 101, 114, 110, 97, 109, 101, 24, 2, 32, 1, 40, 9, 18, 19, 10, 11, 111, 97, 117, 116, 104, 95, 115, 99, 111, 112, 101, 24, 3, 32, 1, 40, 9, 34, 119, 10, 25, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 50, 10, 17, 101, 120, 112, 101, 99, 116, 95, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 24, 2, 32, 1, 40, 11, 50, 23, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 66, 111, 111, 108, 86, 97, 108, 117, 101, 34, 61, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 73, 110, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 31, 10, 23, 97, 103, 103, 114, 101, 103, 97, 116, 101, 100, 95, 112, 97, 121, 108, 111, 97, 100, 95, 115, 105, 122, 101, 24, 1, 32, 1, 40, 5, 34, 232, 1, 10, 26, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 113, 117, 101, 115, 116, 18, 48, 10, 13, 114, 101, 115, 112, 111, 110, 115, 101, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 14, 50, 25, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 61, 10, 19, 114, 101, 115, 112, 111, 110, 115, 101, 95, 112, 97, 114, 97, 109, 101, 116, 101, 114, 115, 24, 2, 32, 3, 40, 11, 50, 32, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 82, 101, 115, 112, 111, 110, 115, 101, 80, 97, 114, 97, 109, 101, 116, 101, 114, 115, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 3, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 18, 49, 10, 15, 114, 101, 115, 112, 111, 110, 115, 101, 95, 115, 116, 97, 116, 117, 115, 24, 7, 32, 1, 40, 11, 50, 24, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 69, 99, 104, 111, 83, 116, 97, 116, 117, 115, 34, 69, 10, 27, 83, 116, 114, 101, 97, 109, 105, 110, 103, 79, 117, 116, 112, 117, 116, 67, 97, 108, 108, 82, 101, 115, 112, 111, 110, 115, 101, 18, 38, 10, 7, 112, 97, 121, 108, 111, 97, 100, 24, 1, 32, 1, 40, 11, 50, 21, 46, 103, 114, 112, 99, 46, 116, 101, 115, 116, 105, 110, 103, 46, 80, 97, 121, 108, 111, 97, 100, 42, 31, 10, 11, 80, 97, 121, 108, 111, 97, 100, 84, 121, 112, 101, 18, 16, 10, 12, 67, 79, 77, 80, 82, 69, 83, 83, 65, 66, 76, 69, 16, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor(X) -> error({gpb_error, {badname, X}}). gpb_version_as_string() -> "4.7.1". gpb_version_as_list() -> [4,7,1]. ================================================ FILE: interop/test/grpcbox_interop_client_SUITE.erl ================================================ -module(grpcbox_interop_client_SUITE). -compile([export_all]). -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). -include("grpcbox_interop_tests.hrl"). -include("grpcbox.hrl"). -define(REQ_SIZES, [27182, 8, 1828, 45904]). -define(RESP_SIZES, [31415, 9, 2653, 58979]). all() -> [{group, identity}, {group, gzip} ]. groups() -> Cases = [empty_unary, large_unary, client_streaming, server_streaming, ping_pong, empty_stream, status_code_and_message, custom_metadata, unimplemented_method, unimplemented_service ], [{identity, Cases}, {gzip, Cases} ]. init_per_group(Encoding, Config) -> application:load(grpcbox), application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{encoding => Encoding}}]}), {ok, _} = application:ensure_all_started(grpcbox), Config. end_per_group(_Encoding, _Config) -> application:stop(grpcbox), ok. empty_unary(_Config) -> ?assertMatch({ok, _, _}, grpc_testing_test_service_client:empty_call(ctx:new(), #{})). large_unary(_Config) -> Payload = client_payload(271828), SimpleRequest = #{payload => Payload}, ?assertMatch({ok, _, _}, grpc_testing_test_service_client:unary_call(ctx:new(), SimpleRequest)). client_streaming(_Config) -> TotalSize = lists:sum(?REQ_SIZES), {ok, S} = grpc_testing_test_service_client:streaming_input_call(ctx:new()), lists:foreach(fun(Size) -> ReqPayload = client_payload(Size), ok = grpcbox_client:send(S, #{payload => ReqPayload}) end, ?REQ_SIZES), %% server returns the total aggregated payload size ?assertMatch({ok, #{aggregated_payload_size := TotalSize}}, grpcbox_client:close_and_recv(S)). server_streaming(_Config) -> RespSizes = [31415, 9, 2653, 58979], Payload = #{response_parameters => [#{size => S} || S <- RespSizes]}, {ok, S} = grpc_testing_test_service_client:streaming_output_call(ctx:new(), Payload), lists:foreach(fun(Size) -> {ok, #{payload := #{body := Body1}}} = grpcbox_client:recv_data(S), ?assertMatch(Size, erlang:byte_size(Body1)) end, RespSizes). ping_pong(_Config) -> Sizes = lists:zip(?REQ_SIZES, ?RESP_SIZES), {ok, S} = grpc_testing_test_service_client:full_duplex_call(ctx:new()), lists:foreach(fun({ReqSize, RespSize}) -> Payload = client_payload(ReqSize), Req = #{response_parameters => [#{size => RespSize}], payload => Payload}, ok = grpcbox_client:send(S, Req), {ok, #{payload := #{body := Body1}}} = grpcbox_client:recv_data(S), ?assertMatch(RespSize, erlang:byte_size(Body1)) end, Sizes). empty_stream(_Config) -> {ok, S} = grpc_testing_test_service_client:full_duplex_call(ctx:new()), ok = grpcbox_client:close_send(S), ?assertMatch(stream_finished, grpcbox_client:recv_data(S)). status_code_and_message(_Config) -> Msg = <<"test status message">>, RespStatus = #{code => 2, message => Msg}, Req = #{response_status => RespStatus}, ?assertMatch({error, {<<"2">>, Msg}, _}, grpc_testing_test_service_client:unary_call(ctx:new(), Req)). custom_metadata(_Config) -> Payload = client_payload(1), SimpleRequest = #{response_size => 1, payload => Payload}, Metadata = grpcbox_metadata:pairs([{?INITIAL_METADATA_KEY, ?INITIAL_METADATA_VALUE}, {?TRAILING_METADATA_KEY, ?TRAILING_METADATA_VALUE}]), Ctx = grpcbox_metadata:append_to_outgoing_ctx(ctx:new(), Metadata), {ok, _, #{headers := Headers, trailers := Trailers}} = grpc_testing_test_service_client:unary_call(Ctx, SimpleRequest), ?assertEqual(?INITIAL_METADATA_VALUE, maps:get(?INITIAL_METADATA_KEY, Headers)), ?assertEqual(?TRAILING_METADATA_VALUE, maps:get(?TRAILING_METADATA_KEY, Trailers)), %% test also with full duplex {ok, S} = grpc_testing_test_service_client:full_duplex_call(Ctx), Req = #{response_parameters => [#{size => 1}], payload => Payload}, ok = grpcbox_client:send(S, Req), {ok, #{payload := #{body := Body1}}} = grpcbox_client:recv_data(S), ?assertMatch(1, erlang:byte_size(Body1)), grpcbox_client:close_send(S), {ok, Headers1} = grpcbox_client:recv_headers(S), {ok, {_, _, Trailers1}} = grpcbox_client:recv_trailers(S), ?assertEqual(?INITIAL_METADATA_VALUE, maps:get(?INITIAL_METADATA_KEY, Headers1)), ?assertEqual(?TRAILING_METADATA_VALUE, maps:get(?TRAILING_METADATA_KEY, Trailers1)). unimplemented_method(_Config) -> Def = #grpcbox_def{service = 'grpc.testing.TestService', marshal_fun = fun(I) -> test_pb:encode_msg(I, simple_request) end, unmarshal_fun = fun(I) -> test_pb:encode_msg(I, simple_response) end}, ?assertMatch({error, {?GRPC_STATUS_UNIMPLEMENTED, _}, _}, grpcbox_client:unary(ctx:new(), <<"/grpc.testing.TestService/NotReal">>, #{}, Def, #{})). unimplemented_service(_Config) -> Def = #grpcbox_def{service = 'grpc.testing.Unimplemented', marshal_fun = fun(I) -> test_pb:encode_msg(I, simple_request) end, unmarshal_fun = fun(I) -> test_pb:encode_msg(I, simple_response) end}, ?assertMatch({error, {?GRPC_STATUS_UNIMPLEMENTED, _}, _}, grpcbox_client:unary(ctx:new(), <<"/grpc.testing.Unimplemented/NotReal">>, #{}, Def, #{})). client_payload(NumBytes) -> Body = << <<0:8>> || _ <- lists:seq(1, NumBytes)>>, #{type => 0, body => Body}. ================================================ FILE: proto/health.proto ================================================ // Copyright 2015 The gRPC Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // The canonical version of this proto can be found at // https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto syntax = "proto3"; package grpc.health.v1; option csharp_namespace = "Grpc.Health.V1"; option go_package = "google.golang.org/grpc/health/grpc_health_v1"; option java_multiple_files = true; option java_outer_classname = "HealthProto"; option java_package = "io.grpc.health.v1"; message HealthCheckRequest { string service = 1; } message HealthCheckResponse { enum ServingStatus { UNKNOWN = 0; SERVING = 1; NOT_SERVING = 2; SERVICE_UNKNOWN = 3; // Used only by the Watch method. } ServingStatus status = 1; } service Health { // If the requested service is unknown, the call will fail with status // NOT_FOUND. rpc Check(HealthCheckRequest) returns (HealthCheckResponse); // Performs a watch for the serving status of the requested service. // The server will immediately send back a message indicating the current // serving status. It will then subsequently send a new message whenever // the service's serving status changes. // // If the requested service is unknown when the call is received, the // server will send a message setting the serving status to // SERVICE_UNKNOWN but will *not* terminate the call. If at some // future point, the serving status of the service becomes known, the // server will send a new message with the service's serving status. // // If the call terminates with status UNIMPLEMENTED, then clients // should assume this method is not supported and should not retry the // call. If the call terminates with any other status (including OK), // clients should retry the call with appropriate exponential backoff. rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse); } ================================================ FILE: proto/reflection.proto ================================================ // Copyright 2016 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Service exported by server reflection syntax = "proto3"; package grpc.reflection.v1alpha; service ServerReflection { // The reflection service is structured as a bidirectional stream, ensuring // all related requests go to a single server. rpc ServerReflectionInfo(stream ServerReflectionRequest) returns (stream ServerReflectionResponse); } // The message sent by the client when calling ServerReflectionInfo method. message ServerReflectionRequest { string host = 1; // To use reflection service, the client should set one of the following // fields in message_request. The server distinguishes requests by their // defined field and then handles them using corresponding methods. oneof message_request { // Find a proto file by the file name. string file_by_filename = 3; // Find the proto file that declares the given fully-qualified symbol name. // This field should be a fully-qualified symbol name // (e.g. .[.] or .). string file_containing_symbol = 4; // Find the proto file which defines an extension extending the given // message type with the given field number. ExtensionRequest file_containing_extension = 5; // Finds the tag numbers used by all known extensions of the given message // type, and appends them to ExtensionNumberResponse in an undefined order. // Its corresponding method is best-effort: it's not guaranteed that the // reflection service will implement this method, and it's not guaranteed // that this method will provide all extensions. Returns // StatusCode::UNIMPLEMENTED if it's not implemented. // This field should be a fully-qualified type name. The format is // . string all_extension_numbers_of_type = 6; // List the full names of registered services. The content will not be // checked. string list_services = 7; } } // The type name and extension number sent by the client when requesting // file_containing_extension. message ExtensionRequest { // Fully-qualified type name. The format should be . string containing_type = 1; int32 extension_number = 2; } // The message sent by the server to answer ServerReflectionInfo method. message ServerReflectionResponse { string valid_host = 1; ServerReflectionRequest original_request = 2; // The server set one of the following fields according to the message_request // in the request. oneof message_response { // This message is used to answer file_by_filename, file_containing_symbol, // file_containing_extension requests with transitive dependencies. As // the repeated label is not allowed in oneof fields, we use a // FileDescriptorResponse message to encapsulate the repeated fields. // The reflection service is allowed to avoid sending FileDescriptorProtos // that were previously sent in response to earlier requests in the stream. FileDescriptorResponse file_descriptor_response = 4; // This message is used to answer all_extension_numbers_of_type request. ExtensionNumberResponse all_extension_numbers_response = 5; // This message is used to answer list_services request. ListServiceResponse list_services_response = 6; // This message is used when an error occurs. ErrorResponse error_response = 7; } } // Serialized FileDescriptorProto messages sent by the server answering // a file_by_filename, file_containing_symbol, or file_containing_extension // request. message FileDescriptorResponse { // Serialized FileDescriptorProto messages. We avoid taking a dependency on // descriptor.proto, which uses proto2 only features, by making them opaque // bytes instead. repeated bytes file_descriptor_proto = 1; } // A list of extension numbers sent by the server answering // all_extension_numbers_of_type request. message ExtensionNumberResponse { // Full name of the base type, including the package name. The format // is . string base_type_name = 1; repeated int32 extension_number = 2; } // A list of ServiceResponse sent by the server answering list_services request. message ListServiceResponse { // The information of each service may be expanded in the future, so we use // ServiceResponse message to encapsulate it. repeated ServiceResponse service = 1; } // The information of a single service used by ListServiceResponse to answer // list_services request. message ServiceResponse { // Full name of a registered service, including its package name. The format // is . string name = 1; } // The error code and error message sent by the server when an error occurs. message ErrorResponse { // This field uses the error codes defined in grpc::StatusCode. int32 error_code = 1; string error_message = 2; } ================================================ FILE: rebar.config ================================================ {erl_opts, [debug_info]}. {deps, [{chatterbox, {pkg, ts_chatterbox}}, ctx, acceptor_pool, gproc]}. {grpc, [{protos, ["proto"]}, {service_modules, [{'grpc.health.v1.Health', "grpcbox_health"}, {'grpc.reflection.v1alpha.ServerReflection', "grpcbox_reflection"}]}, {gpb_opts, [{descriptor, true}, {module_name_prefix, "grpcbox_"}, {module_name_suffix, "_pb"}]}]}. {profiles, [{test, [{erl_opts, [nowarn_export_all]}, {shell, [{config, "config/test.config"}]}, {grpc, [{protos, "test/grpcbox_SUITE_data"}, {out_dir, "test"}, {gpb_opts, [{o, "test"}, {descriptor, true}, {module_name_suffix, "_pb"}]}]}, {overrides, [{override, opencensus, [{erl_opts, []}]}]}, {deps, [opencensus, jsx]}]}, {interop, [{deps, [recon]}, {grpc, [{protos, "interop/proto"}, {out_dir, "interop/src"}, {gpb_opts, [{o, "interop/src"}, {descriptor, true}, {module_name_suffix, "_pb"}]}]}, {relx, [{release, {grpc_interop, "0.1.0"}, [grpcbox]}, {sys_config, "interop/config/sys.config"}]}, {erl_opts, [{i, "interop/include"}]}, %% use src_dirs so the modules are in the release for testing {src_dirs, ["src", "interop"]}, {ct_opts, [{config, "interop/config/sys.config"}, {dir, "interop/test"}]}, {shell, [{apps, [grpcbox]}, {config, "interop/config/sys.config"}]}]}, {benchmark, [{grpc, [{protos, "benchmark/proto"}, {out_dir, "benchmark/src"}, {gpb_opts, [{o, "benchmark/src"}, {descriptor, true}, {module_name_suffix, "_pb"}]}]}, {extra_src_dirs, ["benchmark"]}, {ct_opts, [{config, "benchmark/config/test.config"}, {dir, "benchmark/test"}]}, {shell, [{apps, [grpcbox]}, {config, "benchmark/config/sys.config"}]}]} ]}. {shell, [{apps, [grpcbox]}]}. {xref_checks, [undefined_function_calls, undefined_functions, deprecated_function_calls, deprecated_functions]}. {project_plugins, [covertool, {grpcbox_plugin, "~> 0.9.0"}, rebar3_lint]}. {cover_enabled, true}. {cover_opts, [verbose]}. {cover_export_enabled, true}. {covertool, [{coverdata_files, ["ct.coverdata"]}]}. %% create junit xml for circleci {ct_opts, [{ct_hooks, [cth_surefire]}]}. {dialyzer, [{warnings, [no_unknown]}]}. ================================================ FILE: src/grpcbox.app.src ================================================ {application, grpcbox, [{description,"Erlang grpc library based on chatterbox"}, {vsn,"git"}, {registered,[]}, {mod,{grpcbox_app,[]}}, {applications,[kernel, stdlib, chatterbox, acceptor_pool, gproc, ctx]}, {env, [{client, #{channels => [%% {default_channel, [{http, "localhost", 8080, []}], #{}} ]}}, {grpc_opts, #{service_protos => [], client_cert_dir => ""}}, {transport_opts, #{ssl => false, keyfile => "", certfile => "", cacertfile => ""}}, {listen_opts, #{port => 8080, ip => {0,0,0,0}}}, %% server acceptors {pool_opts, #{size => 10}}, %% chatterbox options {server_opts, #{header_table_size => 4096, enable_push => 1, max_concurrent_streams => unlimited, initial_window_size => 65535, max_frame_size => 16384, max_header_list_size => unlimited}}]}, {modules,[]}, {licenses,["Apache 2.0"]}, {links,[{"Github","https://github.com/tsloughter/grpcbox"}]}]}. ================================================ FILE: src/grpcbox.erl ================================================ %%%------------------------------------------------------------------- %% @doc grpc client %% @end %%%------------------------------------------------------------------- -module(grpcbox). -export([start_server/1, server_child_spec/5]). -include_lib("chatterbox/include/http2.hrl"). -type encoding() :: identity | gzip | deflate | snappy | atom(). -type metadata() :: #{headers := grpcbox_metadata:t(), trailers := grpcbox_metadata:t()}. -type server_opts() :: #{server_opts => settings(), %% TODO: change this in chatterbox to be under a module grpc_opts => #{service_protos := [module()]}, listen_opts => #{port => inet:port_number(), ip => inet:ip_address(), socket_options => [gen_tcp:option()]}, pool_opts => #{size => integer()}, transport_opts => #{ssl => boolean(), keyfile => file:filename_all(), certfile => file:filename_all(), cacertfile => file:filename_all()}}. -export_type([metadata/0, server_opts/0, encoding/0]). -spec start_server(server_opts()) -> supervisor:startchild_ret(). start_server(Opts) -> grpcbox_services_simple_sup:start_child(Opts). server_child_spec(ServerOpts, GrpcOpts, ListenOpts, PoolOpts, TransportOpts) -> #{id => grpcbox_services_sup, start => {grpcbox_services_sup, start_link, [ServerOpts, GrpcOpts, ListenOpts, PoolOpts, TransportOpts]}, type => supervisor, restart => permanent, shutdown => 1000}. ================================================ FILE: src/grpcbox_acceptor.erl ================================================ -module(grpcbox_acceptor). -behaviour(acceptor). -export([acceptor_init/3, acceptor_continue/3, acceptor_terminate/2]). acceptor_init(_, LSocket, {Transport, ServerOpts, ChatterboxOpts, SslOpts}) -> % monitor listen socket to gracefully close when it closes MRef = monitor(port, LSocket), {ok, {Transport, MRef, ServerOpts, ChatterboxOpts, SslOpts}}. acceptor_continue(_PeerName, Socket, {ssl, _MRef, ServerOpts, ChatterboxOpts, SslOpts}) -> {ok, AcceptSocket} = ssl:handshake(Socket, SslOpts), case ssl:negotiated_protocol(AcceptSocket) of {ok, <<"h2">>} -> h2_connection:become({ssl, AcceptSocket}, ServerOpts, ChatterboxOpts); _ -> exit(bad_negotiated_protocol) end; acceptor_continue(_PeerName, Socket, {gen_tcp, _MRef, ServerOpts, ChatterboxOpts, _SslOpts}) -> h2_connection:become({gen_tcp, Socket}, ServerOpts, ChatterboxOpts). acceptor_terminate(Reason, _) -> % Something went wrong. Either the acceptor_pool is terminating or the % accept failed. exit(Reason). ================================================ FILE: src/grpcbox_app.erl ================================================ %%%------------------------------------------------------------------- %% @doc grpcbox public API %% @end %%%------------------------------------------------------------------- -module(grpcbox_app). -behaviour(application). -export([start/2, stop/1]). -include("grpcbox.hrl"). start(_StartType, _StartArgs) -> {ok, Pid} = grpcbox_sup:start_link(), case application:get_env(grpcbox, client) of {ok, #{channels := Channels}} -> [grpcbox_channel_sup:start_child(Name, Endpoints, Options) || {Name, Endpoints, Options} <- Channels]; _ -> ok end, ServerOpts = application:get_env(grpcbox, servers, []), maybe_start_server(ServerOpts), {ok, Pid}. stop(_State) -> ok. %% maybe_start_server([]) -> ok; maybe_start_server([ServerOpts | Tail]) -> grpcbox_services_simple_sup:start_child(ServerOpts), maybe_start_server(Tail). ================================================ FILE: src/grpcbox_chain_interceptor.erl ================================================ -module(grpcbox_chain_interceptor). -export([stream_chain/1, unary_client/1, new_stream_client/1, send_client/1, recv_client/1, unary/1, stream/1]). stream_chain(L) -> #{new_stream => new_stream_client(L), send_msg => send_client(L), recv_msg => recv_client(L)}. new_stream_client([I]) -> fun(Ctx, Channel, Path, Def, Handler, Options) -> I:new_stream(Ctx, Channel, Path, Def, Handler, Options) end; new_stream_client([I | Rest]) -> fun(Ctx, Channel, Path, Def, Handler, Options) -> I:new_stream(Ctx, Channel, Path, Def, create_new_stream_fun(Rest, Handler), Options) end. create_new_stream_fun([I], Handler) -> fun(Ctx, Channel, Path, Def, Options) -> I:new_stream(Ctx, Channel, Path, Def, Handler, Options) end; create_new_stream_fun([I | Rest], Handler) -> fun(Ctx, Channel, Path, Def, Options) -> I:new_stream(Ctx, Channel, Path, Def, create_new_stream_fun(Rest, Handler), Options) end. send_client([I]) -> fun(Stream, Handler, Input) -> I:send_msg(Stream, Handler, Input) end; send_client([I | Rest]) -> fun(Stream, Handler, Input) -> I:send_msg(Stream, create_send_fun(Rest, Handler), Input) end. create_send_fun([I], Handler) -> fun(Stream, Input) -> I:send_msg(Stream, Handler, Input) end; create_send_fun([I | Rest], Handler) -> fun(Stream, Input) -> I:send_msg(Stream, create_new_stream_fun(Rest, Handler), Input) end. recv_client([I]) -> fun(Stream, Handler, Timeout) -> I:recv_msg(Stream, Handler, Timeout) end; recv_client([I | Rest]) -> fun(Stream, Handler, Timeout) -> I:recv_msg(Stream, create_recv_fun(Rest, Handler), Timeout) end. create_recv_fun([I], Handler) -> fun(Stream, Timeout) -> I:recv_msg(Stream, Handler, Timeout) end; create_recv_fun([I | Rest], Handler) -> fun(Stream, Timeout) -> I:recv_msg(Stream, create_new_stream_fun(Rest, Handler), Timeout) end. unary_client(InterceptorList) -> create_client_interceptor_fun(InterceptorList). create_client_interceptor_fun([I]) -> fun(Ctx, Channel, Handler, Path, Input, Def, Options) -> I(Ctx, Channel, Handler, Path, Input, Def, Options) end; create_client_interceptor_fun([I | Rest]) -> fun(Ctx, Channel, Handler, Path, Input, Def, Options) -> I(Ctx, Channel, create_client_handler_fun(Rest, Channel, Handler, Path, Def, Options), Path, Input, Def, Options) end. create_client_handler_fun([I], Channel, Handler, Path, Def, Options) -> fun(Ctx, Input) -> I(Ctx, Channel, Handler, Path, Input, Def, Options) end; create_client_handler_fun([I | Rest], Channel, Handler, Path, Def, Options) -> fun(Ctx, Input) -> I(Ctx, Channel, create_client_handler_fun(Rest, Channel, Handler, Path, Def, Options), Path, Input, Def, Options) end. unary(InterceptorList) -> create_interceptor_fun(InterceptorList). %% right now stream and unary have the same arity and ServerInfo argument so we build them the same %% this may change in the future stream(InterceptorList) -> create_interceptor_fun(InterceptorList). %% the chain interceptor creates an interceptor which for the handler receives a fun/2 that %% calls the next interceptor, which has a handler fun/2 that has the interceptor after that, %% and so on until the last which has the service method handler as usual. create_interceptor_fun([I]) -> fun(Arg1, Arg2, ServerInfo, Handler) -> I(Arg1, Arg2, ServerInfo, Handler) end; create_interceptor_fun([I | Rest]) -> fun(Arg1, Arg2, ServerInfo, Handler) -> I(Arg1, Arg2, ServerInfo, create_handler_fun(Rest, ServerInfo, Handler)) end. create_handler_fun([I], ServerInfo, Handler) -> fun(Arg1, Arg2) -> I(Arg1, Arg2, ServerInfo, Handler) end; create_handler_fun([I | Rest], ServerInfo, Handler) -> fun(Arg1, Arg2) -> I(Arg1, Arg2, ServerInfo, create_handler_fun(Rest, ServerInfo, Handler)) end. ================================================ FILE: src/grpcbox_channel.erl ================================================ -module(grpcbox_channel). -behaviour(gen_statem). -export([start_link/3, is_ready/1, pick/2, stop/1, stop/2]). -export([init/1, callback_mode/0, terminate/3, connected/3, idle/3]). -include("grpcbox.hrl"). -define(CHANNEL(Name), {via, gproc, {n, l, {?MODULE, Name}}}). -type t() :: any(). -type name() :: t(). -type transport() :: http | https. -type host() :: inet:ip_address() | inet:hostname(). -type connection_settings() :: map(). -type endpoint() :: {transport(), host(), inet:port_number(), [ssl:ssl_options()]} | {transport(), host(), inet:port_number(), [ssl:ssl_options()], connection_settings()}. -type options() :: #{balancer => load_balancer(), encoding => gprcbox:encoding(), unary_interceptor => grpcbox_client:unary_interceptor(), stream_interceptor => grpcbox_client:stream_interceptor(), stats_handler => module(), sync_start => boolean()}. -type load_balancer() :: round_robin | random | hash | direct | claim. -export_type([t/0, name/0, options/0, endpoint/0]). -record(data, {endpoints :: [endpoint()], pool :: atom(), resolver :: module(), balancer :: grpcbox:balancer(), encoding :: grpcbox:encoding(), interceptors :: #{unary_interceptor => grpcbox_client:unary_interceptor(), stream_interceptor => grpcbox_client:stream_interceptor()} | undefined, stats_handler :: module() | undefined, refresh_interval :: timer:time()}). -spec start_link(name(), [endpoint()], options()) -> {ok, pid()} | ignore | {error, term()}. start_link(Name, Endpoints, Options) -> gen_statem:start_link(?CHANNEL(Name), ?MODULE, [Name, Endpoints, Options], []). -spec is_ready(name()) -> boolean(). is_ready(Name) -> gen_statem:call(?CHANNEL(Name), is_ready). %% @doc Picks a subchannel from a pool using the configured strategy. -spec pick(name(), unary | stream) -> {ok, {pid(), grpcbox_client:interceptor() | undefined}} | {error, undefined_channel | no_endpoints}. pick(Name, CallType) -> try case gproc_pool:pick_worker(Name) of false -> {error, no_endpoints}; Pid when is_pid(Pid) -> {ok, {Pid, interceptor(Name, CallType)}} end catch error:badarg -> {error, undefined_channel} end. -spec interceptor(name(), unary | stream) -> grpcbox_client:interceptor() | undefined. interceptor(Name, CallType) -> case ets:lookup(?CHANNELS_TAB, {Name, CallType}) of [] -> undefined; [{_, I}] -> I end. stop(Name) -> stop(Name, {shutdown, force_delete}). stop(Name, Reason) -> gen_statem:stop(?CHANNEL(Name), Reason, infinity). init([Name, Endpoints, Options]) -> process_flag(trap_exit, true), Endpoints1 = normalize_endpoints(Endpoints), BalancerType = maps:get(balancer, Options, round_robin), Encoding = maps:get(encoding, Options, identity), StatsHandler = maps:get(stats_handler, Options, undefined), insert_interceptors(Name, Options), gproc_pool:new(Name, BalancerType, [{size, length(Endpoints)}, {auto_size, true}]), Data = #data{ pool = Name, encoding = Encoding, stats_handler = StatsHandler, endpoints = Endpoints1 }, case maps:get(sync_start, Options, false) of false -> {ok, idle, Data, [{next_event, internal, connect}]}; true -> _ = start_workers(Name, StatsHandler, Encoding, Endpoints1), {ok, connected, Data} end. callback_mode() -> state_functions. connected({call, From}, is_ready, _Data) -> {keep_state_and_data, [{reply, From, true}]}; connected(EventType, EventContent, Data) -> handle_event(EventType, EventContent, Data). idle(internal, connect, Data=#data{pool=Pool, stats_handler=StatsHandler, encoding=Encoding, endpoints=Endpoints}) -> _ = start_workers(Pool, StatsHandler, Encoding, Endpoints), {next_state, connected, Data}; idle({call, From}, is_ready, _Data) -> {keep_state_and_data, [{reply, From, false}]}; idle(EventType, EventContent, Data) -> handle_event(EventType, EventContent, Data). handle_event(_, _, Data) -> {keep_state, Data}. terminate({shutdown, force_delete}, _State, #data{pool=Name}) -> gproc_pool:force_delete(Name); terminate(Reason, _State, #data{pool=Name}) -> [grpcbox_subchannel:stop(Pid, Reason) || {_Channel, Pid} <- gproc_pool:active_workers(Name)], gproc_pool:delete(Name), ok. insert_interceptors(Name, Interceptors) -> insert_unary_interceptor(Name, Interceptors), insert_stream_interceptor(Name, stream_interceptor, Interceptors). insert_unary_interceptor(Name, Interceptors) -> case maps:get(unary_interceptor, Interceptors, undefined) of undefined -> ok; {Interceptor, Arg} -> ets:insert(?CHANNELS_TAB, {{Name, unary}, Interceptor(Arg)}); Interceptor -> ets:insert(?CHANNELS_TAB, {{Name, unary}, Interceptor}) end. insert_stream_interceptor(Name, _Type, Interceptors) -> case maps:get(stream_interceptor, Interceptors, undefined) of undefined -> ok; {Interceptor, Arg} -> ets:insert(?CHANNELS_TAB, {{Name, stream}, Interceptor(Arg)}); Interceptor when is_atom(Interceptor) -> ets:insert(?CHANNELS_TAB, {{Name, stream}, #{new_stream => fun Interceptor:new_stream/6, send_msg => fun Interceptor:send_msg/3, recv_msg => fun Interceptor:recv_msg/3}}); Interceptor=#{new_stream := _, send_msg := _, recv_msg := _} -> ets:insert(?CHANNELS_TAB, {{Name, stream}, Interceptor}) end. start_workers(Pool, StatsHandler, Encoding, Endpoints) -> [begin gproc_pool:add_worker(Pool, Endpoint), {ok, Pid} = grpcbox_subchannel:start_link(Endpoint, Pool, {Transport, Host, Port, SSLOptions, ConnectionSettings}, Encoding, StatsHandler), Pid end || Endpoint={Transport, Host, Port, SSLOptions, ConnectionSettings} <- Endpoints]. %% add the chatterbox connection settings map to the endpoint if it isn't there already normalize_endpoints(Endpoints) -> lists:map(fun({Transport, Host, Port, SSLOptions}) -> {Transport, Host, Port, SSLOptions, #{}}; ({Transport, Host, Port, SSLOptions, ConnectionSettings}) -> {Transport, Host, Port, SSLOptions, ConnectionSettings} end, Endpoints). ================================================ FILE: src/grpcbox_channel_sup.erl ================================================ %%%------------------------------------------------------------------- %% @doc grpcbox client connection supervisor. %% @end %%%------------------------------------------------------------------- -module(grpcbox_channel_sup). -behaviour(supervisor). -export([start_link/0, channel_spec/3, start_child/3]). -export([init/1]). -include("grpcbox.hrl"). -define(SERVER, ?MODULE). start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). %% @doc Start a channel under the grpcbox channel supervisor. -spec start_child(grpcbox_channel:name(), [grpcbox_channel:endpoint()], grpcbox_channel:options()) -> supervisor:startchild_ret(). start_child(Name, Endpoints, Options) -> supervisor:start_child(?SERVER, [Name, Endpoints, Options]). %% @doc Create a default child spec for starting a channel -spec channel_spec(grpcbox_channel:name(), [grpcbox_channel:endpoint()], grpcbox_channel:options()) -> supervisor:child_spec(). channel_spec(Name, Endpoints, Options) -> #{id => grpcbox_channel, start => {grpcbox_channel, start_link, [Name, Endpoints, Options]}, type => worker}. init(_Args) -> ets:new(?CHANNELS_TAB, [named_table, set, public, {read_concurrency, true}]), SupFlags = #{strategy => simple_one_for_one, intensity => 5, period => 10}, ChildSpecs = [#{id => grpcbox_channel, start => {grpcbox_channel, start_link, []}, type => worker, restart => transient, shutdown => 1000} ], {ok, {SupFlags, ChildSpecs}}. ================================================ FILE: src/grpcbox_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc grpc client %% @end %%%------------------------------------------------------------------- -module(grpcbox_client). -export([unary/6, unary/5, stream/4, stream/5, send/2, recv_headers/1, recv_headers/2, recv_data/1, recv_data/2, recv_trailers/1, recv_trailers/2, close_and_recv/1, close_send/1]). -include_lib("chatterbox/include/http2.hrl"). -include("grpcbox.hrl"). -type options() :: #{channel => grpcbox_channel:t(), encoding => grpcbox:encoding(), atom() => any()}. -type unary_interceptor() :: term(). -type stream_interceptor() :: term(). -type interceptor() :: unary_interceptor() | stream_interceptor(). -type stream() :: #{channel => pid(), stream_id => stream_id(), stream_pid => pid(), monitor_ref => reference(), service_def => #grpcbox_def{}, encoding => grpcbox:encoding()}. -export_type([stream/0, options/0, unary_interceptor/0, stream_interceptor/0, interceptor/0]). get_channel(Options, Type) -> Channel = maps:get(channel, Options, default_channel), grpcbox_channel:pick(Channel, Type). unary(Ctx, Service, Method, Input, Def, Options) -> unary(Ctx, filename:join([<<>>, Service, Method]), Input, Def, Options). unary(Ctx, Path, Input, Def, Options) -> case get_channel(Options, unary) of {ok, {Channel, Interceptor}} -> Handler = fun(Ctx1, Input1) -> unary_handler(Ctx1, Channel, Path, Input1, Def, Options) end, case Interceptor of undefined -> Handler(Ctx, Input); _ -> Interceptor(Ctx, Channel, Handler, Path, Input, Def, Options) end; {error, _Reason}=Error -> Error end. unary_handler(Ctx, Channel, Path, Input, Def, Options) -> try case grpcbox_client_stream:send_request(Ctx, Channel, Path, Input, Def, Options) of {ok, _Conn, Stream, Pid} -> Ref = erlang:monitor(process, Pid), S = #{channel => Channel, stream_id => Stream, stream_pid => Pid, monitor_ref => Ref, service_def => Def}, case recv_end(S, grpcbox_utils:get_timeout_from_ctx(Ctx, 5000)) of eos -> case recv_headers(S, 0) of {ok, Headers} -> case recv_trailers(S) of {ok, {<<"0">>, _, Metadata}} -> case recv_data(S, 0) of {ok, Data} -> {ok, Data, #{headers => Headers, trailers => Metadata}}; stream_finished -> {ok, <<>>, #{headers => Headers, trailers => Metadata}} end; {ok, {Status, Message, Trailers}} -> {error, {Status, Message}, #{headers => Headers, trailers => Trailers}}; {error, _}=Error -> Error end; {http_error, Status, Headers} -> %% different from an `error' in that it isn't from the grpc layer {http_error, {Status, <<>>}, #{headers => Headers, trailers => #{}}}; {error, _}=Error -> Error end; {error, _}=Error -> Error end; {error, {shutdown, econnrefused}} -> {error, econnrefused}; {error, _}=Error -> Error end catch error:{badmatch, {error, {shutdown,econnrefused}}} -> {error, econnrefused}; throw:{error, _}=E -> E end. %% no input: bidrectional stream(Ctx, Path, Def, Options) -> case get_channel(Options, stream) of {ok, {Channel, Interceptor}} -> case Interceptor of undefined -> grpcbox_client_stream:new_stream(Ctx, Channel, Path, Def, Options); #{new_stream := NewStream} -> case NewStream(Ctx, Channel, Path, Def, fun grpcbox_client_stream:new_stream/5, Options) of {ok, S} -> {ok, S#{stream_interceptor => Interceptor}}; {error, _}=Error -> Error end; _ -> grpcbox_client_stream:new_stream(Ctx, Channel, Path, Def, Options) end; {error, _Reason}=Error -> Error end. close_and_recv(Stream) -> close_send(Stream), case recv_end(Stream, 5000) of eos -> recv_data(Stream, 0); {error, _}=Error -> Error end. close_send(#{channel := Conn, stream_id := StreamId}) -> ok = h2_connection:send_body(Conn, StreamId, <<>>, [{send_end_stream, true}]). %% h2_connection:send_trailers(Conn, StreamId, [], [{send_end_stream, true}]). send(Stream=#{stream_interceptor := #{send_msg := SendMsg}}, Input) -> SendMsg(Stream, fun grpcbox_client_stream:send_msg/2, Input); send(Stream, Input) -> grpcbox_client_stream:send_msg(Stream, Input). %% input given, stream response stream(Ctx, Path, Input, Def, Options) -> case get_channel(Options, stream) of {ok, {Channel, _Interceptor}} -> case grpcbox_client_stream:send_request(Ctx, Channel, Path, Input, Def, Options) of {ok, Conn, Stream, Pid} -> Ref = erlang:monitor(process, Pid), {ok, #{channel => Conn, stream_id => Stream, stream_pid => Pid, monitor_ref => Ref, service_def => Def}}; {error, _Reason} = Error -> Error end; {error, _Reason} = Error -> Error end. recv_data(Stream) -> recv_data(Stream, 500). recv_data(Stream=#{stream_interceptor := #{recv_msg := RecvMsg}}, Timeout) -> RecvMsg(Stream, fun grpcbox_client_stream:recv_msg/2, Timeout); recv_data(Stream, Timeout) -> grpcbox_client_stream:recv_msg(Stream, Timeout). recv_headers(S) -> recv_headers(S, 500). recv_headers(S, Timeout) -> case recv(headers, S, Timeout) of {ok, Headers} -> case maps:get(<<":status">>, Headers, undefined) of <<"200">> -> {ok, Headers}; ErrorStatus -> {http_error, ErrorStatus, Headers} end; {error, _Reason}=Error -> Error end. recv_trailers(S) -> recv_trailers(S, 500). recv_trailers(S, Timeout) -> recv(trailers, S, Timeout). recv(Type, #{stream_id := Id, monitor_ref := Ref, stream_pid := Pid}, Timeout) -> receive {Type, Id, V} -> {ok, V}; {'DOWN', Ref, process, Pid, _Reason} -> receive {trailers, Id, {Status, Message, Metadata}} -> {ok, {Status, Message, Metadata}} after 0 -> {error, unknown} end after Timeout -> {error, timeout} end. recv_end(#{stream_id := StreamId, stream_pid := Pid, monitor_ref := Ref}, Timeout) -> receive {eos, StreamId} -> erlang:demonitor(Ref, [flush]), receive {'END_STREAM', StreamId} -> eos after Timeout -> %% actually, this Timeout will never happen because of outer receive Timeout {error, eos} end; {'DOWN', Ref, process, Pid, normal} -> %% this is sent by h2_connection after the stream process has ended receive {'END_STREAM', StreamId} -> eos after Timeout -> {error, {stream_down, normal}} end; {'DOWN', Ref, process, Pid, Reason} -> {error, {stream_down, Reason}} after Timeout -> {error, timeout} end. ================================================ FILE: src/grpcbox_client_stream.erl ================================================ -module(grpcbox_client_stream). -export([new_stream/5, send_request/6, send_msg/2, recv_msg/2, init/3, on_receive_headers/2, on_receive_data/2, on_end_stream/1, handle_info/2]). -include("grpcbox.hrl"). new_stream(Ctx, Channel, Path, Def=#grpcbox_def{service=Service, message_type=MessageType, marshal_fun=MarshalFun, unmarshal_fun=UnMarshalFun}, Options) -> case grpcbox_subchannel:conn(Channel, grpcbox_utils:get_timeout_from_ctx(Ctx, infinity)) of {ok, Conn, #{scheme := Scheme, authority := Authority, encoding := DefaultEncoding, stats_handler := StatsHandler}} -> Encoding = maps:get(encoding, Options, DefaultEncoding), RequestHeaders = headers(Scheme, Authority, Path, encoding_to_binary(Encoding), MessageType, metadata_headers(Ctx)), case h2_connection:new_stream(Conn, ?MODULE, [#{service => Service, marshal_fun => MarshalFun, unmarshal_fun => UnMarshalFun, path => Path, buffer => <<>>, stats_handler => StatsHandler, stats => #{}, client_pid => self()}], RequestHeaders, [], self()) of {error, _Code} = Err -> Err; {StreamId, Pid} -> Ref = erlang:monitor(process, Pid), {ok, #{channel => Conn, stream_id => StreamId, stream_pid => Pid, monitor_ref => Ref, service_def => Def, encoding => Encoding}} end; {error, _}=Error -> Error end. send_request(Ctx, Channel, Path, Input, #grpcbox_def{service=Service, message_type=MessageType, marshal_fun=MarshalFun, unmarshal_fun=UnMarshalFun}, Options) -> case grpcbox_subchannel:conn(Channel, grpcbox_utils:get_timeout_from_ctx(Ctx, infinity)) of {ok, Conn, #{scheme := Scheme, authority := Authority, encoding := DefaultEncoding, stats_handler := StatsHandler}} -> Encoding = maps:get(encoding, Options, DefaultEncoding), Body = grpcbox_frame:encode(Encoding, MarshalFun(Input)), Headers = headers(Scheme, Authority, Path, encoding_to_binary(Encoding), MessageType, metadata_headers(Ctx)), %% headers are sent in the same request as creating a new stream to ensure %% concurrent calls can't end up interleaving the sending of headers in such %% a way that a lower stream id's headers are sent after another's, which results %% in the server closing the connection when it gets them out of order case h2_connection:new_stream(Conn, grpcbox_client_stream, [#{service => Service, marshal_fun => MarshalFun, unmarshal_fun => UnMarshalFun, path => Path, buffer => <<>>, stats_handler => StatsHandler, stats => #{}, client_pid => self()}], Headers, Body, [], self()) of {error, _Code} = Err -> Err; {StreamId, Pid} -> {ok, Conn, StreamId, Pid} end; {error, _}=Error -> Error end. send_msg(#{channel := Conn, stream_id := StreamId, encoding := Encoding, service_def := #grpcbox_def{marshal_fun=MarshalFun}}, Input) -> OutFrame = grpcbox_frame:encode(Encoding, MarshalFun(Input)), h2_connection:send_body(Conn, StreamId, OutFrame, [{send_end_stream, false}]). recv_msg(S=#{stream_id := Id, stream_pid := Pid, monitor_ref := Ref}, Timeout) -> receive {data, Id, V} -> {ok, V}; {'DOWN', Ref, process, Pid, _Reason} -> case grpcbox_client:recv_trailers(S, 0) of {ok, {<<"0">> = _Status, _Message, _Metadata}} -> stream_finished; {ok, {Status, Message, Metadata}} -> {error, {Status, Message}, #{trailers => Metadata}}; {error, _} -> stream_finished end after Timeout -> case erlang:is_process_alive(Pid) of true -> timeout; false -> stream_finished end end. metadata_headers(Ctx) -> case ctx:deadline(Ctx) of D when D =:= undefined ; D =:= infinity -> grpcbox_utils:encode_headers(maps:to_list(grpcbox_metadata:from_outgoing_ctx(Ctx))); {T, _} -> TimeMs = erlang:convert_time_unit(T - erlang:monotonic_time(), native, millisecond), Timeout = {<<"grpc-timeout">>, <<(integer_to_binary(TimeMs))/binary, "m">>}, grpcbox_utils:encode_headers([Timeout | maps:to_list(grpcbox_metadata:from_outgoing_ctx(Ctx))]) end. %% callbacks init(_ConnectionPid, StreamId, [_, State=#{path := Path}]) -> _ = process_flag(trap_exit, true), Ctx1 = ctx:with_value(ctx:new(), grpc_client_method, Path), State1 = stats_handler(Ctx1, rpc_begin, {}, State), {ok, State1#{stream_id => StreamId}}; init(_, _, State) -> {ok, State}. %% trailers on_receive_headers(H, State=#{resp_headers := _, ctx := Ctx, stream_id := StreamId, client_pid := Pid}) -> Status = proplists:get_value(<<"grpc-status">>, H, undefined), Message = proplists:get_value(<<"grpc-message">>, H, undefined), Metadata = grpcbox_utils:headers_to_metadata(H), Pid ! {trailers, StreamId, {Status, Message, Metadata}}, Ctx1 = ctx:with_value(Ctx, grpc_client_status, grpcbox_utils:status_to_string(Status)), {ok, State#{ctx => Ctx1, resp_trailers => H}}; %% headers on_receive_headers(H, State=#{stream_id := StreamId, ctx := Ctx, client_pid := Pid}) -> Encoding = proplists:get_value(<<"grpc-encoding">>, H, identity), Metadata = grpcbox_utils:headers_to_metadata(H), Pid ! {headers, StreamId, Metadata}, %% TODO: better way to know if it is a Trailers-Only response? %% maybe chatterbox should include information about the end of the stream case proplists:get_value(<<"grpc-status">>, H, undefined) of undefined -> {ok, State#{resp_headers => H, encoding => encoding_to_atom(Encoding)}}; Status -> Message = proplists:get_value(<<"grpc-message">>, H, undefined), Pid ! {trailers, StreamId, {Status, Message, Metadata}}, Ctx1 = ctx:with_value(Ctx, grpc_client_status, grpcbox_utils:status_to_string(Status)), {ok, State#{resp_headers => H, ctx => Ctx1, status => Status, encoding => encoding_to_atom(Encoding)}} end. on_receive_data(Data, State=#{stream_id := StreamId, client_pid := Pid, buffer := Buffer, encoding := Encoding, unmarshal_fun := UnmarshalFun}) -> {Remaining, Messages} = grpcbox_frame:split(<>, Encoding), [Pid ! {data, StreamId, UnmarshalFun(Message)} || Message <- Messages], {ok, State#{buffer => Remaining}}; on_receive_data(_Data, State) -> {ok, State}. on_end_stream(State=#{stream_id := StreamId, ctx := Ctx, client_pid := Pid}) -> Pid ! {eos, StreamId}, State1 = stats_handler(Ctx, rpc_end, {}, State), {ok, State1}. handle_info(_, State) -> State. %% stats_handler(Ctx, _, _, State=#{stats_handler := undefined}) -> State#{ctx => Ctx}; stats_handler(Ctx, Event, Stats, State=#{stats_handler := StatsHandler, stats := StatsState}) -> {Ctx1, StatsState1} = StatsHandler:handle(Ctx, client, Event, Stats, StatsState), State#{ctx => Ctx1, stats => StatsState1}. encoding_to_atom(identity) -> identity; encoding_to_atom(<<"identity">>) -> identity; encoding_to_atom(<<"gzip">>) -> gzip; encoding_to_atom(<<"deflate">>) -> deflate; encoding_to_atom(<<"snappy">>) -> snappy; encoding_to_atom(Custom) -> binary_to_atom(Custom, latin1). encoding_to_binary(identity) -> <<"identity">>; encoding_to_binary(gzip) -> <<"gzip">>; encoding_to_binary(deflate) -> <<"deflate">>; encoding_to_binary(snappy) -> <<"snappy">>; encoding_to_binary(Custom) -> atom_to_binary(Custom, latin1). headers(Scheme, Host, Path, Encoding, MessageType, MD) -> {UserAgent, FilteredMD} = case lists:keytake(<<"user-agent">>, 1, MD) of {value, {<<"user-agent">>, MDUserAgent}, MD1} -> {MDUserAgent, MD1}; false -> {<<"grpc-erlang/0.9.2">>, MD} end, [ {<<":method">>, <<"POST">>}, {<<":path">>, Path}, {<<":scheme">>, Scheme}, {<<":authority">>, Host}, {<<"grpc-encoding">>, Encoding}, {<<"grpc-message-type">>, MessageType}, {<<"content-type">>, <<"application/grpc+proto">>}, {<<"user-agent">>, UserAgent}, {<<"te">>, <<"trailers">>} | FilteredMD]. ================================================ FILE: src/grpcbox_frame.erl ================================================ -module(grpcbox_frame). -export([encode/2, split/2]). -include("grpcbox.hrl"). encode(gzip, Bin) -> CompressedBin = zlib:gzip(Bin), Length = byte_size(CompressedBin), <<1, Length:32, CompressedBin/binary>>; encode(identity, Bin) -> Length = byte_size(Bin), <<0, Length:32, Bin/binary>>; encode(Encoding, _) -> throw({error, {unknown_encoding, Encoding}}). split(Frame, Encoding) -> split(Frame, Encoding, []). split(<<>>, _Encoding, Acc) -> {<<>>, lists:reverse(Acc)}; split(<<0, Length:32, Encoded:Length/binary, Rest/binary>>, Encoding, Acc) -> split(Rest, Encoding, [Encoded | Acc]); split(<<1, Length:32, Compressed:Length/binary, Rest/binary>>, Encoding, Acc) -> Encoded = case Encoding of gzip -> try zlib:gunzip(Compressed) catch error:data_error -> ?THROW(?GRPC_STATUS_INTERNAL, <<"Could not decompress but compression algorithm ", (atom_to_binary(Encoding, utf8))/binary, " is supported">>) end; _ -> ?THROW(?GRPC_STATUS_UNIMPLEMENTED, <<"Compression mechanism ", (atom_to_binary(Encoding, utf8))/binary, " used for received frame not supported">>) end, split(Rest, Encoding, [Encoded | Acc]); split(Bin, _Encoding, Acc) -> {Bin, lists:reverse(Acc)}. ================================================ FILE: src/grpcbox_health_bhvr.erl ================================================ %%%------------------------------------------------------------------- %% @doc Behaviour to implement for grpc service grpc.health.v1.Health. %% @end %%%------------------------------------------------------------------- %% this module was generated and should not be modified manually -module(grpcbox_health_bhvr). %% Unary RPC -callback check(ctx:t(), grpcbox_health_pb:health_check_request()) -> {ok, grpcbox_health_pb:health_check_response(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% -callback watch(grpcbox_health_pb:health_check_request(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). ================================================ FILE: src/grpcbox_health_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc Client module for grpc service grpc.health.v1.Health. %% @end %%%------------------------------------------------------------------- %% this module was generated and should not be modified manually -module(grpcbox_health_client). -compile(export_all). -compile(nowarn_export_all). -include_lib("grpcbox/include/grpcbox.hrl"). -define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). -define(SERVICE, 'grpc.health.v1.Health'). -define(PROTO_MODULE, 'grpcbox_health_pb'). -define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). -define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). -define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, message_type=MessageType, marshal_fun=?MARSHAL_FUN(Input), unmarshal_fun=?UNMARSHAL_FUN(Output)}). %% @doc Unary RPC -spec check(grpcbox_health_pb:health_check_request()) -> {ok, grpcbox_health_pb:health_check_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. check(Input) -> check(ctx:new(), Input, #{}). -spec check(ctx:t() | grpcbox_health_pb:health_check_request(), grpcbox_health_pb:health_check_request() | grpcbox_client:options()) -> {ok, grpcbox_health_pb:health_check_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. check(Ctx, Input) when ?is_ctx(Ctx) -> check(Ctx, Input, #{}); check(Input, Options) -> check(ctx:new(), Input, Options). -spec check(ctx:t(), grpcbox_health_pb:health_check_request(), grpcbox_client:options()) -> {ok, grpcbox_health_pb:health_check_response(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response() | {error, any()}. check(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/grpc.health.v1.Health/Check">>, Input, ?DEF(health_check_request, health_check_response, <<"grpc.health.v1.HealthCheckRequest">>), Options). %% @doc -spec watch(grpcbox_health_pb:health_check_request()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. watch(Input) -> watch(ctx:new(), Input, #{}). -spec watch(ctx:t() | grpcbox_health_pb:health_check_request(), grpcbox_health_pb:health_check_request() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. watch(Ctx, Input) when ?is_ctx(Ctx) -> watch(Ctx, Input, #{}); watch(Input, Options) -> watch(ctx:new(), Input, Options). -spec watch(ctx:t(), grpcbox_health_pb:health_check_request(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. watch(Ctx, Input, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.health.v1.Health/Watch">>, Input, ?DEF(health_check_request, health_check_response, <<"grpc.health.v1.HealthCheckRequest">>), Options). ================================================ FILE: src/grpcbox_health_pb.erl ================================================ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit %% Generated by gpb_compile version 4.7.3 -module(grpcbox_health_pb). -export([encode_msg/2, encode_msg/3]). -export([decode_msg/2, decode_msg/3]). -export([merge_msgs/3, merge_msgs/4]). -export([verify_msg/2, verify_msg/3]). -export([get_msg_defs/0]). -export([get_msg_names/0]). -export([get_group_names/0]). -export([get_msg_or_group_names/0]). -export([get_enum_names/0]). -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). -export(['enum_symbol_by_value_health_check_response.ServingStatus'/1, 'enum_value_by_symbol_health_check_response.ServingStatus'/1]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). -export([find_rpc_def/2, fetch_rpc_def/2]). -export([fqbin_to_service_name/1]). -export([service_name_to_fqbin/1]). -export([fqbins_to_service_and_rpc_name/2]). -export([service_and_rpc_name_to_fqbins/2]). -export([fqbin_to_msg_name/1]). -export([msg_name_to_fqbin/1]). -export([fqbin_to_enum_name/1]). -export([enum_name_to_fqbin/1]). -export([get_package_name/0]). -export([uses_packages/0]). -export([source_basename/0]). -export([get_all_source_basenames/0]). -export([get_all_proto_names/0]). -export([get_msg_containment/1]). -export([get_pkg_containment/1]). -export([get_service_containment/1]). -export([get_rpc_containment/1]). -export([get_enum_containment/1]). -export([get_proto_by_msg_name_as_fqbin/1]). -export([get_proto_by_service_name_as_fqbin/1]). -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([descriptor/0, descriptor/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). %% enumerated types -type 'health_check_response.ServingStatus'() :: 'UNKNOWN' | 'SERVING' | 'NOT_SERVING' | 'SERVICE_UNKNOWN'. -export_type(['health_check_response.ServingStatus'/0]). %% message types -type health_check_request() :: #{service => iodata() % = 1 }. -type health_check_response() :: #{status => 'UNKNOWN' | 'SERVING' | 'NOT_SERVING' | 'SERVICE_UNKNOWN' | integer() % = 1, enum health_check_response.ServingStatus }. -export_type(['health_check_request'/0, 'health_check_response'/0]). -spec encode_msg(health_check_request() | health_check_response(), atom()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). -spec encode_msg(health_check_request() | health_check_response(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> case proplists:get_bool(verify, Opts) of true -> verify_msg(Msg, MsgName, Opts); false -> ok end, TrUserData = proplists:get_value(user_data, Opts), case MsgName of health_check_request -> encode_msg_health_check_request(id(Msg, TrUserData), TrUserData); health_check_response -> encode_msg_health_check_response(id(Msg, TrUserData), TrUserData) end. encode_msg_health_check_request(Msg, TrUserData) -> encode_msg_health_check_request(Msg, <<>>, TrUserData). encode_msg_health_check_request(#{} = M, Bin, TrUserData) -> case M of #{service := F1} -> begin TrF1 = id(F1, TrUserData), case is_empty_string(TrF1) of true -> Bin; false -> e_type_string(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_health_check_response(Msg, TrUserData) -> encode_msg_health_check_response(Msg, <<>>, TrUserData). encode_msg_health_check_response(#{} = M, Bin, TrUserData) -> case M of #{status := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 'UNKNOWN'; TrF1 =:= 0 -> Bin; true -> 'e_enum_health_check_response.ServingStatus'(TrF1, <>, TrUserData) end end; _ -> Bin end. 'e_enum_health_check_response.ServingStatus'('UNKNOWN', Bin, _TrUserData) -> <>; 'e_enum_health_check_response.ServingStatus'('SERVING', Bin, _TrUserData) -> <>; 'e_enum_health_check_response.ServingStatus'('NOT_SERVING', Bin, _TrUserData) -> <>; 'e_enum_health_check_response.ServingStatus'('SERVICE_UNKNOWN', Bin, _TrUserData) -> <>; 'e_enum_health_check_response.ServingStatus'(V, Bin, _TrUserData) -> e_varint(V, Bin). -compile({nowarn_unused_function,e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). e_type_bool(true, Bin, _TrUserData) -> <>; e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_string/3}). e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -compile({nowarn_unused_function,e_type_bytes/3}). e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). e_type_float(V, Bin, _) when is_number(V) -> <>; e_type_float(infinity, Bin, _) -> <>; e_type_float('-infinity', Bin, _) -> <>; e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). e_type_double(V, Bin, _) when is_number(V) -> <>; e_type_double(infinity, Bin, _) -> <>; e_type_double('-infinity', Bin, _) -> <>; e_type_double(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). -compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, e_varint(N bsr 7, Bin2). is_empty_string("") -> true; is_empty_string(<<>>) -> true; is_empty_string(L) when is_list(L) -> not string_has_chars(L); is_empty_string(B) when is_binary(B) -> false. string_has_chars([C | _]) when is_integer(C) -> true; string_has_chars([H | T]) -> case string_has_chars(H) of true -> true; false -> string_has_chars(T) end; string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; string_has_chars(C) when is_integer(C) -> true; string_has_chars(<<>>) -> false; string_has_chars([]) -> false. decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), decode_msg_1_catch(Bin, MsgName, TrUserData). -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason -> StackTrace = erlang:get_stacktrace(), error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. decode_msg_2_doit(health_check_request, Bin, TrUserData) -> id(decode_msg_health_check_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(health_check_response, Bin, TrUserData) -> id(decode_msg_health_check_response(Bin, TrUserData), TrUserData). decode_msg_health_check_request(Bin, TrUserData) -> dfp_read_field_def_health_check_request(Bin, 0, 0, id(<<>>, TrUserData), TrUserData). dfp_read_field_def_health_check_request(<<10, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_health_check_request_service(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_health_check_request(<<>>, 0, 0, F@_1, _) -> #{service => F@_1}; dfp_read_field_def_health_check_request(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_health_check_request(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_health_check_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_health_check_request(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_health_check_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_health_check_request_service(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_health_check_request(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_health_check_request(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_health_check_request(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_health_check_request(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_health_check_request(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_health_check_request(<<>>, 0, 0, F@_1, _) -> #{service => F@_1}. d_field_health_check_request_service(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_health_check_request_service(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_health_check_request_service(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_health_check_request(RestF, 0, 0, NewFValue, TrUserData). skip_varint_health_check_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_health_check_request(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_health_check_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_health_check_request(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_health_check_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_health_check_request(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_health_check_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_health_check_request(Rest2, 0, 0, F@_1, TrUserData). skip_group_health_check_request(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_health_check_request(Rest, 0, Z2, F@_1, TrUserData). skip_32_health_check_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_health_check_request(Rest, Z1, Z2, F@_1, TrUserData). skip_64_health_check_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_health_check_request(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_health_check_response(Bin, TrUserData) -> dfp_read_field_def_health_check_response(Bin, 0, 0, id('UNKNOWN', TrUserData), TrUserData). dfp_read_field_def_health_check_response(<<8, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_health_check_response_status(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_health_check_response(<<>>, 0, 0, F@_1, _) -> #{status => F@_1}; dfp_read_field_def_health_check_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_health_check_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_health_check_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_health_check_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_health_check_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_health_check_response_status(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_health_check_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_health_check_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_health_check_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_health_check_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_health_check_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_health_check_response(<<>>, 0, 0, F@_1, _) -> #{status => F@_1}. d_field_health_check_response_status(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_health_check_response_status(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_health_check_response_status(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = {id('d_enum_health_check_response.ServingStatus'(begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end), TrUserData), Rest}, dfp_read_field_def_health_check_response(RestF, 0, 0, NewFValue, TrUserData). skip_varint_health_check_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_health_check_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_health_check_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_health_check_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_health_check_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_health_check_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_health_check_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_health_check_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_health_check_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_health_check_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_health_check_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_health_check_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_health_check_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_health_check_response(Rest, Z1, Z2, F@_1, TrUserData). 'd_enum_health_check_response.ServingStatus'(0) -> 'UNKNOWN'; 'd_enum_health_check_response.ServingStatus'(1) -> 'SERVING'; 'd_enum_health_check_response.ServingStatus'(2) -> 'NOT_SERVING'; 'd_enum_health_check_response.ServingStatus'(3) -> 'SERVICE_UNKNOWN'; 'd_enum_health_check_response.ServingStatus'(V) -> V. read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, {Group, Rest}. %% Like skipping over fields, but record the total length, %% Each field is <(FieldNum bsl 3) bor FieldType> ++ %% Record the length because varints may be non-optimally encoded. %% %% Groups can be nested, but assume the same FieldNum cannot be nested %% because group field numbers are shared with the rest of the fields %% numbers. Thus we can search just for an group-end with the same %% field number. %% %% (The only time the same group field number could occur would %% be in a nested sub message, but then it would be inside a %% length-delimited entry, which we skip-read by length.) read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) when N < (32-7) -> read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) -> Key = X bsl N + Acc, TagLen1 = TagLen + 1, case {Key bsr 3, Key band 7} of {FieldNum, 4} -> % 4 = group_end {NumBytes, TagLen1}; {_, 0} -> % 0 = varint read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); {_, 1} -> % 1 = bits64 <<_:64, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); {_, 2} -> % 2 = length_delimited read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); {_, 3} -> % 3 = group_start read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 4} -> % 4 = group_end read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 5} -> % 5 = bits32 <<_:32, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) end. read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) when N < (64-7) -> read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) when N < (64-7) -> read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> Len = X bsl N + Acc, NumBytes1 = NumBytes + 1, <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of health_check_request -> merge_msg_health_check_request(Prev, New, TrUserData); health_check_response -> merge_msg_health_check_response(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_health_check_request/3}). merge_msg_health_check_request(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{service := NFservice}} -> S1#{service => NFservice}; {#{service := PFservice}, _} -> S1#{service => PFservice}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_health_check_response/3}). merge_msg_health_check_response(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{status := NFstatus}} -> S1#{status => NFstatus}; {#{status := PFstatus}, _} -> S1#{status => PFstatus}; _ -> S1 end. verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of health_check_request -> v_msg_health_check_request(Msg, [MsgName], TrUserData); health_check_response -> v_msg_health_check_response(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_health_check_request/3}). -dialyzer({nowarn_function,v_msg_health_check_request/3}). v_msg_health_check_request(#{} = M, Path, TrUserData) -> case M of #{service := F1} -> v_type_string(F1, [service | Path], TrUserData); _ -> ok end, lists:foreach(fun (service) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_health_check_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), health_check_request}, M, Path); v_msg_health_check_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, health_check_request}, X, Path). -compile({nowarn_unused_function,v_msg_health_check_response/3}). -dialyzer({nowarn_function,v_msg_health_check_response/3}). v_msg_health_check_response(#{} = M, Path, TrUserData) -> case M of #{status := F1} -> 'v_enum_health_check_response.ServingStatus'(F1, [status | Path], TrUserData); _ -> ok end, lists:foreach(fun (status) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_health_check_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), health_check_response}, M, Path); v_msg_health_check_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, health_check_response}, X, Path). -compile({nowarn_unused_function,'v_enum_health_check_response.ServingStatus'/3}). -dialyzer({nowarn_function,'v_enum_health_check_response.ServingStatus'/3}). 'v_enum_health_check_response.ServingStatus'('UNKNOWN', _Path, _TrUserData) -> ok; 'v_enum_health_check_response.ServingStatus'('SERVING', _Path, _TrUserData) -> ok; 'v_enum_health_check_response.ServingStatus'('NOT_SERVING', _Path, _TrUserData) -> ok; 'v_enum_health_check_response.ServingStatus'('SERVICE_UNKNOWN', _Path, _TrUserData) -> ok; 'v_enum_health_check_response.ServingStatus'(V, Path, TrUserData) when is_integer(V) -> v_type_sint32(V, Path, TrUserData); 'v_enum_health_check_response.ServingStatus'(X, Path, _TrUserData) -> mk_type_error({invalid_enum, 'health_check_response.ServingStatus'}, X, Path). -compile({nowarn_unused_function,v_type_sint32/3}). -dialyzer({nowarn_function,v_type_sint32/3}). v_type_sint32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_sint32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, sint32, signed, 32}, N, Path); v_type_sint32(X, Path, _TrUserData) -> mk_type_error({bad_integer, sint32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; prettify_path(PathR) -> list_to_atom(lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR))))). -compile({nowarn_unused_function,id/2}). -compile({inline,id/2}). id(X, _TrUserData) -> X. -compile({nowarn_unused_function,v_ok/3}). -compile({inline,v_ok/3}). v_ok(_Value, _Path, _TrUserData) -> ok. -compile({nowarn_unused_function,m_overwrite/3}). -compile({inline,m_overwrite/3}). m_overwrite(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. -compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). -compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. get_msg_defs() -> [{{enum, 'health_check_response.ServingStatus'}, [{'UNKNOWN', 0}, {'SERVING', 1}, {'NOT_SERVING', 2}, {'SERVICE_UNKNOWN', 3}]}, {{msg, health_check_request}, [#{name => service, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, {{msg, health_check_response}, [#{name => status, fnum => 1, rnum => 2, type => {enum, 'health_check_response.ServingStatus'}, occurrence => optional, opts => []}]}]. get_msg_names() -> [health_check_request, health_check_response]. get_group_names() -> []. get_msg_or_group_names() -> [health_check_request, health_check_response]. get_enum_names() -> ['health_check_response.ServingStatus']. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of Fs when is_list(Fs) -> Fs; error -> erlang:error({no_such_msg, MsgName}) end. fetch_enum_def(EnumName) -> case find_enum_def(EnumName) of Es when is_list(Es) -> Es; error -> erlang:error({no_such_enum, EnumName}) end. find_msg_def(health_check_request) -> [#{name => service, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; find_msg_def(health_check_response) -> [#{name => status, fnum => 1, rnum => 2, type => {enum, 'health_check_response.ServingStatus'}, occurrence => optional, opts => []}]; find_msg_def(_) -> error. find_enum_def('health_check_response.ServingStatus') -> [{'UNKNOWN', 0}, {'SERVING', 1}, {'NOT_SERVING', 2}, {'SERVICE_UNKNOWN', 3}]; find_enum_def(_) -> error. enum_symbol_by_value('health_check_response.ServingStatus', Value) -> 'enum_symbol_by_value_health_check_response.ServingStatus'(Value). enum_value_by_symbol('health_check_response.ServingStatus', Sym) -> 'enum_value_by_symbol_health_check_response.ServingStatus'(Sym). 'enum_symbol_by_value_health_check_response.ServingStatus'(0) -> 'UNKNOWN'; 'enum_symbol_by_value_health_check_response.ServingStatus'(1) -> 'SERVING'; 'enum_symbol_by_value_health_check_response.ServingStatus'(2) -> 'NOT_SERVING'; 'enum_symbol_by_value_health_check_response.ServingStatus'(3) -> 'SERVICE_UNKNOWN'. 'enum_value_by_symbol_health_check_response.ServingStatus'('UNKNOWN') -> 0; 'enum_value_by_symbol_health_check_response.ServingStatus'('SERVING') -> 1; 'enum_value_by_symbol_health_check_response.ServingStatus'('NOT_SERVING') -> 2; 'enum_value_by_symbol_health_check_response.ServingStatus'('SERVICE_UNKNOWN') -> 3. get_service_names() -> ['grpc.health.v1.Health']. get_service_def('grpc.health.v1.Health') -> {{service, 'grpc.health.v1.Health'}, [#{name => 'Check', input => health_check_request, output => health_check_response, input_stream => false, output_stream => false, opts => []}, #{name => 'Watch', input => health_check_request, output => health_check_response, input_stream => false, output_stream => true, opts => []}]}; get_service_def(_) -> error. get_rpc_names('grpc.health.v1.Health') -> ['Check', 'Watch']; get_rpc_names(_) -> error. find_rpc_def('grpc.health.v1.Health', RpcName) -> 'find_rpc_def_grpc.health.v1.Health'(RpcName); find_rpc_def(_, _) -> error. 'find_rpc_def_grpc.health.v1.Health'('Check') -> #{name => 'Check', input => health_check_request, output => health_check_response, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_grpc.health.v1.Health'('Watch') -> #{name => 'Watch', input => health_check_request, output => health_check_response, input_stream => false, output_stream => true, opts => []}; 'find_rpc_def_grpc.health.v1.Health'(_) -> error. fetch_rpc_def(ServiceName, RpcName) -> case find_rpc_def(ServiceName, RpcName) of Def when is_map(Def) -> Def; error -> erlang:error({no_such_rpc, ServiceName, RpcName}) end. %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. fqbin_to_service_name(<<"grpc.health.v1.Health">>) -> 'grpc.health.v1.Health'; fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. service_name_to_fqbin('grpc.health.v1.Health') -> <<"grpc.health.v1.Health">>; service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. fqbins_to_service_and_rpc_name(<<"grpc.health.v1.Health">>, <<"Check">>) -> {'grpc.health.v1.Health', 'Check'}; fqbins_to_service_and_rpc_name(<<"grpc.health.v1.Health">>, <<"Watch">>) -> {'grpc.health.v1.Health', 'Watch'}; fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. service_and_rpc_name_to_fqbins('grpc.health.v1.Health', 'Check') -> {<<"grpc.health.v1.Health">>, <<"Check">>}; service_and_rpc_name_to_fqbins('grpc.health.v1.Health', 'Watch') -> {<<"grpc.health.v1.Health">>, <<"Watch">>}; service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"grpc.health.v1.HealthCheckRequest">>) -> health_check_request; fqbin_to_msg_name(<<"grpc.health.v1.HealthCheckResponse">>) -> health_check_response; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin(health_check_request) -> <<"grpc.health.v1.HealthCheckRequest">>; msg_name_to_fqbin(health_check_response) -> <<"grpc.health.v1.HealthCheckResponse">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). fqbin_to_enum_name(<<"grpc.health.v1.HealthCheckResponse.ServingStatus">>) -> 'health_check_response.ServingStatus'; fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). enum_name_to_fqbin('health_check_response.ServingStatus') -> <<"grpc.health.v1.HealthCheckResponse.ServingStatus">>; enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'grpc.health.v1'. %% Whether or not the message names %% are prepended with package name or not. uses_packages() -> true. source_basename() -> "health.proto". %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension get_all_source_basenames() -> ["health.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. get_all_proto_names() -> ["health"]. get_msg_containment("health") -> [health_check_request, health_check_response]; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("health") -> 'grpc.health.v1'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("health") -> ['grpc.health.v1.Health']; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("health") -> [{'grpc.health.v1.Health', 'Check'}, {'grpc.health.v1.Health', 'Watch'}]; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("health") -> ['health_check_response.ServingStatus']; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"grpc.health.v1.HealthCheckRequest">>) -> "health"; get_proto_by_msg_name_as_fqbin(<<"grpc.health.v1.HealthCheckResponse">>) -> "health"; get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). get_proto_by_service_name_as_fqbin(<<"grpc.health.v1.Health">>) -> "health"; get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). get_proto_by_enum_name_as_fqbin(<<"grpc.health.v1.HealthCheckResponse.ServingStatus">>) -> "health"; get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). get_protos_by_pkg_name_as_fqbin(<<"grpc.health.v1">>) -> ["health"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). descriptor() -> <<10, 191, 3, 10, 27, 103, 114, 112, 99, 47, 104, 101, 97, 108, 116, 104, 47, 118, 49, 47, 104, 101, 97, 108, 116, 104, 46, 112, 114, 111, 116, 111, 18, 14, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 34, 37, 10, 18, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 113, 117, 101, 115, 116, 18, 15, 10, 7, 115, 101, 114, 118, 105, 99, 101, 24, 1, 32, 1, 40, 9, 34, 169, 1, 10, 19, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 18, 65, 10, 6, 115, 116, 97, 116, 117, 115, 24, 1, 32, 1, 40, 14, 50, 49, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 46, 83, 101, 114, 118, 105, 110, 103, 83, 116, 97, 116, 117, 115, 34, 79, 10, 13, 83, 101, 114, 118, 105, 110, 103, 83, 116, 97, 116, 117, 115, 18, 11, 10, 7, 85, 78, 75, 78, 79, 87, 78, 16, 0, 18, 11, 10, 7, 83, 69, 82, 86, 73, 78, 71, 16, 1, 18, 15, 10, 11, 78, 79, 84, 95, 83, 69, 82, 86, 73, 78, 71, 16, 2, 18, 19, 10, 15, 83, 69, 82, 86, 73, 67, 69, 95, 85, 78, 75, 78, 79, 87, 78, 16, 3, 50, 180, 1, 10, 6, 72, 101, 97, 108, 116, 104, 18, 84, 10, 5, 67, 104, 101, 99, 107, 18, 34, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 113, 117, 101, 115, 116, 26, 35, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 84, 10, 5, 87, 97, 116, 99, 104, 18, 34, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 113, 117, 101, 115, 116, 26, 35, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>. descriptor("health") -> <<10, 27, 103, 114, 112, 99, 47, 104, 101, 97, 108, 116, 104, 47, 118, 49, 47, 104, 101, 97, 108, 116, 104, 46, 112, 114, 111, 116, 111, 18, 14, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 34, 37, 10, 18, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 113, 117, 101, 115, 116, 18, 15, 10, 7, 115, 101, 114, 118, 105, 99, 101, 24, 1, 32, 1, 40, 9, 34, 169, 1, 10, 19, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 18, 65, 10, 6, 115, 116, 97, 116, 117, 115, 24, 1, 32, 1, 40, 14, 50, 49, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 46, 83, 101, 114, 118, 105, 110, 103, 83, 116, 97, 116, 117, 115, 34, 79, 10, 13, 83, 101, 114, 118, 105, 110, 103, 83, 116, 97, 116, 117, 115, 18, 11, 10, 7, 85, 78, 75, 78, 79, 87, 78, 16, 0, 18, 11, 10, 7, 83, 69, 82, 86, 73, 78, 71, 16, 1, 18, 15, 10, 11, 78, 79, 84, 95, 83, 69, 82, 86, 73, 78, 71, 16, 2, 18, 19, 10, 15, 83, 69, 82, 86, 73, 67, 69, 95, 85, 78, 75, 78, 79, 87, 78, 16, 3, 50, 180, 1, 10, 6, 72, 101, 97, 108, 116, 104, 18, 84, 10, 5, 67, 104, 101, 99, 107, 18, 34, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 113, 117, 101, 115, 116, 26, 35, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 18, 84, 10, 5, 87, 97, 116, 99, 104, 18, 34, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 113, 117, 101, 115, 116, 26, 35, 46, 103, 114, 112, 99, 46, 104, 101, 97, 108, 116, 104, 46, 118, 49, 46, 72, 101, 97, 108, 116, 104, 67, 104, 101, 99, 107, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor(X) -> error({gpb_error, {badname, X}}). gpb_version_as_string() -> "4.7.3". gpb_version_as_list() -> [4,7,3]. ================================================ FILE: src/grpcbox_health_service.erl ================================================ -module(grpcbox_health_service). -export([check/2, watch/2]). check(Ctx, #{service := <<>>}) -> {ok, #{status => 'SERVING'}, Ctx}; check(Ctx, #{service := _Service}) -> %% TODO: lookup if we are serving this service {ok, #{status => 'UNKNOWN'}, Ctx}. watch(_Request, _Stream) -> ok. ================================================ FILE: src/grpcbox_metadata.erl ================================================ -module(grpcbox_metadata). -export([new/1, new_incoming_ctx/1, append_to_outgoing_ctx/2, pairs/1, join/1, from_incoming_ctx/1, from_outgoing_ctx/1]). -export_type([t/0, key/0, value/0]). -type key() :: unicode:chardata(). %% but only ASCII allowed? -type value() :: unicode:chardata(). -type t() :: #{key() => value()}. %% New creates an MD from a given key-value map. %% %% Only the following ASCII characters are allowed in keys: %% - digits: 0-9 %% - uppercase letters: A-Z (normalized to lower) %% - lowercase letters: a-z %% - special characters: -_. %% Uppercase letters are automatically converted to lowercase. %% %% Keys beginning with "grpc-" are reserved for grpc-internal use only and may %% result in errors if set in metadata. -spec new(#{unicode:chardata() => unicode:chardata()}) -> t(). new(Map) -> maps:fold(fun(K, V, Acc) -> maps:put(string:lowercase(K), V, Acc) end, #{}, Map). new_incoming_ctx(Map) -> ctx:with_value(md_incoming_key, new(Map)). append_to_outgoing_ctx(Ctx, Map) -> ctx:with_value(Ctx, md_outgoing_key, join([from_outgoing_ctx(Ctx), new(Map)])). -spec pairs([{key(), value()}]) -> t(). pairs(List) -> lists:foldl(fun({Key, Value}, Map) -> update(Key, Value, Map) end, #{}, List). -spec join([t()]) -> t(). join(Metadatas) -> lists:foldl(fun(Map, Acc) -> maps:fold(fun(Key, Value, Acc1) -> update(Key, Value, Acc1) end, Acc, Map) end, #{}, Metadatas). -spec from_incoming_ctx(ctx:t()) -> t(). from_incoming_ctx(Ctx) -> ctx:get(Ctx, md_incoming_key, #{}). -spec from_outgoing_ctx(ctx:t()) -> t(). from_outgoing_ctx(Ctx) -> ctx:get(Ctx, md_outgoing_key, #{}). %% internal update(Key, Value, Map) -> maps:update_with(Key, fun(V) when is_list(V) -> [Value | V ]; (V) -> [Value, V] end, Value, Map). ================================================ FILE: src/grpcbox_name_resolver.erl ================================================ -module(grpcbox_name_resolver). -export([resolve/1]). %% dns:///localhost %% ipv4:///127.0.0.1 resolve(Name) -> case uri_string:parse(Name) of #{scheme := _Scheme, host := _Authority, port := Port, path := Endpoint} -> {Endpoint, Port}; _ -> {"127.0.0.1", 8080} end. ================================================ FILE: src/grpcbox_oc_stats.erl ================================================ -module(grpcbox_oc_stats). -export([register_measures/0, register_measures/1, subscribe_views/0, default_views/0, default_views/1, extra_views/0, extra_views/1]). %% grpc_client_method Full gRPC method name, including package, service and method, %% e.g. google.bigtable.v2.Bigtable/CheckAndMutateRow %% grpc_client_status gRPC server status code received, e.g. OK, CANCELLED, DEADLINE_EXCEEDED %% grpc_server_method Full gRPC method name, including package, service and method, %% e.g. com.exampleapi.v4.BookshelfService/Checkout %% grpc_server_status gRPC server status code returned, e.g. OK, CANCELLED, DEADLINE_EXCEEDED register_measures() -> register_measures(client), register_measures(server). -spec register_measures(client | server) -> ok. register_measures(Type) -> [oc_stat_measure:new(Name, Desc, Unit) || {Name, Desc, Unit} <- register_measures_(Type)], ok. register_measures_(client) -> [{'grpc.io/client/sent_messages_per_rpc', "Number of messages sent in each RPC (always 1 for non-streaming RPCs).", none}, {'grpc.io/client/sent_bytes_per_rpc', "Total bytes sent in across all request messages per RPC.", bytes}, {'grpc.io/client/received_messages_per_rpc', "Number of response messages received per RPC (always 1 for non-streaming RPCs).", none}, {'grpc.io/client/received_bytes_per_rpc', "Total bytes received across all response messages per RPC.", bytes}, {'grpc.io/client/roundtrip_latency', "Time between first byte of request sent to last byte of response received, or terminal error.", microsecond}, {'grpc.io/client/server_latency', "Propagated from the server and should have the same value as grpc.io/server/latency.", microsecond}, {'grpc.io/client/started_rpcs', "The total number of client RPCs ever opened, including those that have not completed.", none}]; register_measures_(server) -> [{'grpc.io/server/received_messages_per_rpc', "Number of messages received in each RPC. Has value 1 for non-streaming RPCs.", none}, {'grpc.io/server/received_bytes_per_rpc', "Total bytes received across all messages per RPC.", bytes}, {'grpc.io/server/sent_messages_per_rpc', "Number of messages sent in each RPC. Has value 1 for non-streaming RPCs.", none}, {'grpc.io/server/sent_bytes_per_rpc', "Total bytes sent in across all response messages per RPC.", bytes}, {'grpc.io/server/server_latency', "Time between first byte of request received to last byte of response sent, or terminal error.", microsecond}, {'grpc.io/server/started_rpcs', "The total number of server RPCs ever opened, including those that have not completed.", none}]. subscribe_views() -> [oc_stat_view:subscribe(V) || V <- default_views()]. default_views() -> default_views(client) ++ default_views(server). default_views(client) -> [#{name => "grpc.io/client/sent_bytes_per_rpc", description => "Distribution of total bytes sent per RPC", tags => [grpc_client_method], measure => 'grpc.io/client/sent_bytes_per_rpc', aggregation => default_size_distribution()}, #{name => "grpc.io/client/received_bytes_per_rpc", description => "Distribution of total bytes received per RPC", tags => [grpc_client_method], measure => 'grpc.io/client/received_bytes_per_rpc', aggregation => default_size_distribution()}, #{name => "grpc.io/client/roundtrip_latency", description => "Distribution of time taken by request.", tags => [grpc_client_method], measure => 'grpc.io/client/roundtrip_latency', unit => microsecond, aggregation => default_latency_distribution()}, #{name => "grpc.io/client/completed_rpcs", description => "Total count of completed rpcs", tags => [grpc_client_method, grpc_client_status], measure => 'grpc.io/client/roundtrip_latency', aggregation => oc_stat_aggregation_count}, #{name => "grpc.io/client/started_rpcs", description => "The total number of client RPCs ever opened, including those that have not completed.", tags => [grpc_client_method], measure => 'grpc.io/client/started_rpcs', aggregation => oc_stat_aggregation_count}]; default_views(server) -> [#{name => "grpc.io/server/received_bytes_per_rpc", description => "Distribution of total bytes received per RPC", tags => [grpc_server_method], measure => 'grpc.io/server/received_bytes_per_rpc', aggregation => default_size_distribution()}, #{name => "grpc.io/server/sent_bytes_per_rpc", description => "Distribution of total bytes sent per RPC", tags => [grpc_server_method], measure => 'grpc.io/server/sent_bytes_per_rpc', aggregation => default_size_distribution()}, #{name => "grpc.io/server/server_latency", description => "Distribution of time taken by request.", tags => [grpc_server_method], measure => 'grpc.io/server/server_latency', unit => microsecond, aggregation => default_latency_distribution()}, #{name => "grpc.io/server/completed_rpcs", description => "Total count of completed rpcs", tags => [grpc_server_method, grpc_server_status], measure => 'grpc.io/server/server_latency', aggregation => oc_stat_aggregation_count}, #{name => "grpc.io/server/started_rpcs", description => "The total number of server RPCs ever opened, including those that have not completed.", tags => [grpc_server_method], measure => 'grpc.io/server/started_rpcs', aggregation => oc_stat_aggregation_count}]. extra_views() -> extra_views(client), extra_views(server). extra_views(client) -> [#{name => "grpc.io/client/received_messages_per_rpc", description => "Distribution of messages received per RPC", tags => [grpc_client_method], measure => 'grpc.io/client/received_messages_per_rpc', unit => microsecond, aggregation => default_latency_distribution()}, #{name => "grpc.io/client/sent_messages_per_rpc", description => "Distribution of messages sent per RPC", tags => [grpc_client_method], measure => 'grpc.io/client/sent_messages_per_rpc', aggregation => default_size_distribution()}, #{name => "grpc.io/client/server_latency", description => "Distribution of latency value propagated from the server.", tags => [grpc_client_method], measure => 'grpc.io/client/server_latency', unit => microsecond, aggregation => default_latency_distribution()}]; extra_views(server) -> [#{name => "grpc.io/server/received_messages_per_rpc", description => "Distribution of messages received per RPC", tags => [grpc_server_method], measure => 'grpc.io/server/received_messages_per_rpc', unit => microsecond, aggregation => default_latency_distribution()}, #{name => "grpc.io/server/sent_messages_per_rpc", description => "Distribution of messages sent per RPC", tags => [grpc_server_method], measure => 'grpc.io/server/sent_messages_per_rpc', aggregation => default_size_distribution()}]. default_size_distribution() -> {oc_stat_aggregation_distribution, [{buckets, [0, 1024, 2048, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824, 4294967296]}]}. default_latency_distribution() -> {oc_stat_aggregation_distribution, [{buckets, [0, 1000, 2000, 3000, 4000, 5000, 6000, 8000, 10000, 13000, 16000, 20000, 25000, 30000, 40000, 50000, 65000, 80000, 100000, 130000, 160000, 200000, 250000, 300000, 400000, 500000, 650000, 800000, 1000000, 2000000, 5000000, 10000000, 20000000, 50000000, 100000000]}]}. ================================================ FILE: src/grpcbox_oc_stats_handler.erl ================================================ -module(grpcbox_oc_stats_handler). -export([init/0, init/1, handle/5]). -record(stats, {recv_bytes = 0 :: integer(), sent_bytes = 0 :: integer(), recv_count = 0 :: integer(), sent_count = 0 :: integer(), start_time :: integer() | undefined, end_time :: integer() | undefined}). init() -> init(client), init(server). -spec init(server | client) -> ok. init(Type) -> grpcbox_oc_stats:register_measures(Type). handle(Ctx, server, rpc_begin, _, _) -> Method = ctx:get(Ctx, grpc_server_method), Tags = #{grpc_server_method => Method}, oc_stat:record(Tags, [{'grpc.io/server/started_rpcs', 1}]), {oc_tags:new(Ctx, Tags), #stats{start_time=erlang:monotonic_time(microsecond)}}; handle(Ctx, client, rpc_begin, _, _) -> Method = ctx:get(Ctx, grpc_client_method), Tags = #{grpc_client_method => Method}, oc_stat:record(Tags, 'grpc.io/client/started_rpcs', 1), {oc_tags:new(Ctx, Tags), #stats{start_time=erlang:monotonic_time(microsecond)}}; handle(Ctx, _, out_payload, #{uncompressed_size := USize, compressed_size := _CSize}, Stats=#stats{sent_count=SentCount, sent_bytes=SentBytes}) -> %% set span message event {Ctx, Stats#stats{sent_count=SentCount+1, sent_bytes=SentBytes+USize}}; handle(Ctx, _, in_payload, #{uncompressed_size := USize, compressed_size := _CSize}, Stats=#stats{recv_count=SentCount, recv_bytes=SentBytes}) -> %% set span message event {Ctx, Stats#stats{recv_count=SentCount+1, recv_bytes=SentBytes+USize}}; handle(Ctx, server, rpc_end, _, Stats=#stats{start_time=StartTime, sent_count=SentCount, sent_bytes=SentBytes, recv_count=RecvCount, recv_bytes=RecvBytes}) -> EndTime = erlang:monotonic_time(microsecond), Status = ctx:get(Ctx, grpc_server_status), Ctx1 = oc_tags:new(Ctx, #{grpc_server_status => Status}), oc_stat:record(Ctx1, [{'grpc.io/server/server_latency', EndTime - StartTime}, {'grpc.io/server/sent_bytes_per_rpc', SentBytes}, {'grpc.io/server/received_bytes_per_rpc', RecvBytes}, {'grpc.io/server/received_messages_per_rpc', RecvCount}, {'grpc.io/server/sent_messages_per_rpc', SentCount}]), {Ctx1, Stats#stats{end_time=EndTime}}; handle(Ctx, client, rpc_end, _, Stats=#stats{start_time=StartTime, sent_count=SentCount, sent_bytes=SentBytes, recv_count=RecvCount, recv_bytes=RecvBytes}) -> EndTime = erlang:monotonic_time(microsecond), Status = ctx:get(Ctx, grpc_client_status), Ctx1 = oc_tags:new(Ctx, #{grpc_client_status => Status}), oc_stat:record(Ctx1, [{'grpc.io/client/roundtrip_latency', EndTime - StartTime}, {'grpc.io/client/sent_bytes_per_rpc', SentBytes}, {'grpc.io/client/received_bytes_per_rpc', RecvBytes}, {'grpc.io/client/received_messages_per_rpc', RecvCount}, {'grpc.io/client/sent_messages_per_rpc', SentCount}]), {Ctx1, Stats#stats{end_time=EndTime}}; handle(Ctx, _, _, _, Stats=#stats{}) -> {Ctx, Stats}. ================================================ FILE: src/grpcbox_pool.erl ================================================ -module(grpcbox_pool). -behaviour(acceptor_pool). -export([start_link/4, accept_socket/3]). -export([init/1]). start_link(Name, ServerOpts, ChatterboxOpts, TransportOpts) -> acceptor_pool:start_link({local, Name}, ?MODULE, [ServerOpts, ChatterboxOpts, TransportOpts]). accept_socket(Pool, Socket, Acceptors) -> acceptor_pool:accept_socket(Pool, Socket, Acceptors). init([ServerOpts, ChatterboxOpts, TransportOpts]) -> {Transport, SslOpts} = case TransportOpts of #{ssl := true, keyfile := KeyFile, certfile := CertFile, cacertfile := CACertFile} -> {ssl, [{keyfile, KeyFile}, {certfile, CertFile}, {honor_cipher_order, false}, {cacertfile, CACertFile}, {fail_if_no_peer_cert, true}, {verify, verify_peer}, {versions, ['tlsv1.2']}, {next_protocols_advertised, [<<"h2">>]}]}; _ -> {gen_tcp, []} end, Conn = #{id => grpcbox_acceptor, start => {grpcbox_acceptor, {Transport, ServerOpts, ChatterboxOpts, SslOpts}, []}, grace => 5000}, {ok, {#{}, [Conn]}}. ================================================ FILE: src/grpcbox_reflection_bhvr.erl ================================================ %%%------------------------------------------------------------------- %% @doc Behaviour to implement for grpc service grpc.reflection.v1alpha.ServerReflection. %% @end %%%------------------------------------------------------------------- %% this module was generated and should not be modified manually -module(grpcbox_reflection_bhvr). %% -callback server_reflection_info(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). ================================================ FILE: src/grpcbox_reflection_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc Client module for grpc service grpc.reflection.v1alpha.ServerReflection. %% @end %%%------------------------------------------------------------------- %% this module was generated and should not be modified manually -module(grpcbox_reflection_client). -compile(export_all). -compile(nowarn_export_all). -include_lib("grpcbox/include/grpcbox.hrl"). -define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). -define(SERVICE, 'grpc.reflection.v1alpha.ServerReflection'). -define(PROTO_MODULE, 'grpcbox_reflection_pb'). -define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). -define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). -define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, message_type=MessageType, marshal_fun=?MARSHAL_FUN(Input), unmarshal_fun=?UNMARSHAL_FUN(Output)}). %% @doc -spec server_reflection_info() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. server_reflection_info() -> server_reflection_info(ctx:new(), #{}). -spec server_reflection_info(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. server_reflection_info(Ctx) when ?is_ctx(Ctx) -> server_reflection_info(Ctx, #{}); server_reflection_info(Options) -> server_reflection_info(ctx:new(), Options). -spec server_reflection_info(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response() | {error, any()}. server_reflection_info(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo">>, ?DEF(server_reflection_request, server_reflection_response, <<"grpc.reflection.v1alpha.ServerReflectionRequest">>), Options). ================================================ FILE: src/grpcbox_reflection_pb.erl ================================================ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit %% Generated by gpb_compile version 4.7.3 -module(grpcbox_reflection_pb). -export([encode_msg/2, encode_msg/3]). -export([decode_msg/2, decode_msg/3]). -export([merge_msgs/3, merge_msgs/4]). -export([verify_msg/2, verify_msg/3]). -export([get_msg_defs/0]). -export([get_msg_names/0]). -export([get_group_names/0]). -export([get_msg_or_group_names/0]). -export([get_enum_names/0]). -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). -export([find_rpc_def/2, fetch_rpc_def/2]). -export([fqbin_to_service_name/1]). -export([service_name_to_fqbin/1]). -export([fqbins_to_service_and_rpc_name/2]). -export([service_and_rpc_name_to_fqbins/2]). -export([fqbin_to_msg_name/1]). -export([msg_name_to_fqbin/1]). -export([fqbin_to_enum_name/1]). -export([enum_name_to_fqbin/1]). -export([get_package_name/0]). -export([uses_packages/0]). -export([source_basename/0]). -export([get_all_source_basenames/0]). -export([get_all_proto_names/0]). -export([get_msg_containment/1]). -export([get_pkg_containment/1]). -export([get_service_containment/1]). -export([get_rpc_containment/1]). -export([get_enum_containment/1]). -export([get_proto_by_msg_name_as_fqbin/1]). -export([get_proto_by_service_name_as_fqbin/1]). -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([descriptor/0, descriptor/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). %% enumerated types -export_type([]). %% message types -type server_reflection_request() :: #{host => iodata(), % = 1 message_request => {file_by_filename, iodata()} | {file_containing_symbol, iodata()} | {file_containing_extension, extension_request()} | {all_extension_numbers_of_type, iodata()} | {list_services, iodata()} % oneof }. -type extension_request() :: #{containing_type => iodata(), % = 1 extension_number => integer() % = 2, 32 bits }. -type server_reflection_response() :: #{valid_host => iodata(), % = 1 original_request => server_reflection_request(), % = 2 message_response => {file_descriptor_response, file_descriptor_response()} | {all_extension_numbers_response, extension_number_response()} | {list_services_response, list_service_response()} | {error_response, error_response()} % oneof }. -type file_descriptor_response() :: #{file_descriptor_proto => [iodata()] % = 1 }. -type extension_number_response() :: #{base_type_name => iodata(), % = 1 extension_number => [integer()] % = 2, 32 bits }. -type list_service_response() :: #{service => [service_response()] % = 1 }. -type service_response() :: #{name => iodata() % = 1 }. -type error_response() :: #{error_code => integer(), % = 1, 32 bits error_message => iodata() % = 2 }. -export_type(['server_reflection_request'/0, 'extension_request'/0, 'server_reflection_response'/0, 'file_descriptor_response'/0, 'extension_number_response'/0, 'list_service_response'/0, 'service_response'/0, 'error_response'/0]). -spec encode_msg(server_reflection_request() | extension_request() | server_reflection_response() | file_descriptor_response() | extension_number_response() | list_service_response() | service_response() | error_response(), atom()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). -spec encode_msg(server_reflection_request() | extension_request() | server_reflection_response() | file_descriptor_response() | extension_number_response() | list_service_response() | service_response() | error_response(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> case proplists:get_bool(verify, Opts) of true -> verify_msg(Msg, MsgName, Opts); false -> ok end, TrUserData = proplists:get_value(user_data, Opts), case MsgName of server_reflection_request -> encode_msg_server_reflection_request(id(Msg, TrUserData), TrUserData); extension_request -> encode_msg_extension_request(id(Msg, TrUserData), TrUserData); server_reflection_response -> encode_msg_server_reflection_response(id(Msg, TrUserData), TrUserData); file_descriptor_response -> encode_msg_file_descriptor_response(id(Msg, TrUserData), TrUserData); extension_number_response -> encode_msg_extension_number_response(id(Msg, TrUserData), TrUserData); list_service_response -> encode_msg_list_service_response(id(Msg, TrUserData), TrUserData); service_response -> encode_msg_service_response(id(Msg, TrUserData), TrUserData); error_response -> encode_msg_error_response(id(Msg, TrUserData), TrUserData) end. encode_msg_server_reflection_request(Msg, TrUserData) -> encode_msg_server_reflection_request(Msg, <<>>, TrUserData). encode_msg_server_reflection_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{host := F1} -> begin TrF1 = id(F1, TrUserData), case is_empty_string(TrF1) of true -> Bin; false -> e_type_string(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{message_request := F2} -> case id(F2, TrUserData) of {file_by_filename, TF2} -> begin TrTF2 = id(TF2, TrUserData), e_type_string(TrTF2, <>, TrUserData) end; {file_containing_symbol, TF2} -> begin TrTF2 = id(TF2, TrUserData), e_type_string(TrTF2, <>, TrUserData) end; {file_containing_extension, TF2} -> begin TrTF2 = id(TF2, TrUserData), e_mfield_server_reflection_request_file_containing_extension(TrTF2, <>, TrUserData) end; {all_extension_numbers_of_type, TF2} -> begin TrTF2 = id(TF2, TrUserData), e_type_string(TrTF2, <>, TrUserData) end; {list_services, TF2} -> begin TrTF2 = id(TF2, TrUserData), e_type_string(TrTF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_extension_request(Msg, TrUserData) -> encode_msg_extension_request(Msg, <<>>, TrUserData). encode_msg_extension_request(#{} = M, Bin, TrUserData) -> B1 = case M of #{containing_type := F1} -> begin TrF1 = id(F1, TrUserData), case is_empty_string(TrF1) of true -> Bin; false -> e_type_string(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{extension_number := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_server_reflection_response(Msg, TrUserData) -> encode_msg_server_reflection_response(Msg, <<>>, TrUserData). encode_msg_server_reflection_response(#{} = M, Bin, TrUserData) -> B1 = case M of #{valid_host := F1} -> begin TrF1 = id(F1, TrUserData), case is_empty_string(TrF1) of true -> Bin; false -> e_type_string(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{original_request := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= undefined -> B1; true -> e_mfield_server_reflection_response_original_request(TrF2, <>, TrUserData) end end; _ -> B1 end, case M of #{message_response := F3} -> case id(F3, TrUserData) of {file_descriptor_response, TF3} -> begin TrTF3 = id(TF3, TrUserData), e_mfield_server_reflection_response_file_descriptor_response(TrTF3, <>, TrUserData) end; {all_extension_numbers_response, TF3} -> begin TrTF3 = id(TF3, TrUserData), e_mfield_server_reflection_response_all_extension_numbers_response(TrTF3, <>, TrUserData) end; {list_services_response, TF3} -> begin TrTF3 = id(TF3, TrUserData), e_mfield_server_reflection_response_list_services_response(TrTF3, <>, TrUserData) end; {error_response, TF3} -> begin TrTF3 = id(TF3, TrUserData), e_mfield_server_reflection_response_error_response(TrTF3, <>, TrUserData) end end; _ -> B2 end. encode_msg_file_descriptor_response(Msg, TrUserData) -> encode_msg_file_descriptor_response(Msg, <<>>, TrUserData). encode_msg_file_descriptor_response(#{} = M, Bin, TrUserData) -> case M of #{file_descriptor_proto := F1} -> TrF1 = id(F1, TrUserData), if TrF1 == [] -> Bin; true -> e_field_file_descriptor_response_file_descriptor_proto(TrF1, Bin, TrUserData) end; _ -> Bin end. encode_msg_extension_number_response(Msg, TrUserData) -> encode_msg_extension_number_response(Msg, <<>>, TrUserData). encode_msg_extension_number_response(#{} = M, Bin, TrUserData) -> B1 = case M of #{base_type_name := F1} -> begin TrF1 = id(F1, TrUserData), case is_empty_string(TrF1) of true -> Bin; false -> e_type_string(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{extension_number := F2} -> TrF2 = id(F2, TrUserData), if TrF2 == [] -> B1; true -> e_field_extension_number_response_extension_number(TrF2, B1, TrUserData) end; _ -> B1 end. encode_msg_list_service_response(Msg, TrUserData) -> encode_msg_list_service_response(Msg, <<>>, TrUserData). encode_msg_list_service_response(#{} = M, Bin, TrUserData) -> case M of #{service := F1} -> TrF1 = id(F1, TrUserData), if TrF1 == [] -> Bin; true -> e_field_list_service_response_service(TrF1, Bin, TrUserData) end; _ -> Bin end. encode_msg_service_response(Msg, TrUserData) -> encode_msg_service_response(Msg, <<>>, TrUserData). encode_msg_service_response(#{} = M, Bin, TrUserData) -> case M of #{name := F1} -> begin TrF1 = id(F1, TrUserData), case is_empty_string(TrF1) of true -> Bin; false -> e_type_string(TrF1, <>, TrUserData) end end; _ -> Bin end. encode_msg_error_response(Msg, TrUserData) -> encode_msg_error_response(Msg, <<>>, TrUserData). encode_msg_error_response(#{} = M, Bin, TrUserData) -> B1 = case M of #{error_code := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{error_message := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end. e_mfield_server_reflection_request_file_containing_extension(Msg, Bin, TrUserData) -> SubBin = encode_msg_extension_request(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_server_reflection_response_original_request(Msg, Bin, TrUserData) -> SubBin = encode_msg_server_reflection_request(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_server_reflection_response_file_descriptor_response(Msg, Bin, TrUserData) -> SubBin = encode_msg_file_descriptor_response(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_server_reflection_response_all_extension_numbers_response(Msg, Bin, TrUserData) -> SubBin = encode_msg_extension_number_response(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_server_reflection_response_list_services_response(Msg, Bin, TrUserData) -> SubBin = encode_msg_list_service_response(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_server_reflection_response_error_response(Msg, Bin, TrUserData) -> SubBin = encode_msg_error_response(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_file_descriptor_response_file_descriptor_proto([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, Bin3 = e_type_bytes(id(Elem, TrUserData), Bin2, TrUserData), e_field_file_descriptor_response_file_descriptor_proto(Rest, Bin3, TrUserData); e_field_file_descriptor_response_file_descriptor_proto([], Bin, _TrUserData) -> Bin. e_field_extension_number_response_extension_number(Elems, Bin, TrUserData) when Elems =/= [] -> SubBin = e_pfield_extension_number_response_extension_number(Elems, <<>>, TrUserData), Bin2 = <>, Bin3 = e_varint(byte_size(SubBin), Bin2), <>; e_field_extension_number_response_extension_number([], Bin, _TrUserData) -> Bin. e_pfield_extension_number_response_extension_number([Value | Rest], Bin, TrUserData) -> Bin2 = e_type_int32(id(Value, TrUserData), Bin, TrUserData), e_pfield_extension_number_response_extension_number(Rest, Bin2, TrUserData); e_pfield_extension_number_response_extension_number([], Bin, _TrUserData) -> Bin. e_mfield_list_service_response_service(Msg, Bin, TrUserData) -> SubBin = encode_msg_service_response(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_field_list_service_response_service([Elem | Rest], Bin, TrUserData) -> Bin2 = <>, Bin3 = e_mfield_list_service_response_service(id(Elem, TrUserData), Bin2, TrUserData), e_field_list_service_response_service(Rest, Bin3, TrUserData); e_field_list_service_response_service([], Bin, _TrUserData) -> Bin. -compile({nowarn_unused_function,e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). e_type_bool(true, Bin, _TrUserData) -> <>; e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_string/3}). e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -compile({nowarn_unused_function,e_type_bytes/3}). e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). e_type_float(V, Bin, _) when is_number(V) -> <>; e_type_float(infinity, Bin, _) -> <>; e_type_float('-infinity', Bin, _) -> <>; e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). e_type_double(V, Bin, _) when is_number(V) -> <>; e_type_double(infinity, Bin, _) -> <>; e_type_double('-infinity', Bin, _) -> <>; e_type_double(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). -compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, e_varint(N bsr 7, Bin2). is_empty_string("") -> true; is_empty_string(<<>>) -> true; is_empty_string(L) when is_list(L) -> not string_has_chars(L); is_empty_string(B) when is_binary(B) -> false. string_has_chars([C | _]) when is_integer(C) -> true; string_has_chars([H | T]) -> case string_has_chars(H) of true -> true; false -> string_has_chars(T) end; string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; string_has_chars(C) when is_integer(C) -> true; string_has_chars(<<>>) -> false; string_has_chars([]) -> false. decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), decode_msg_1_catch(Bin, MsgName, TrUserData). -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason -> StackTrace = erlang:get_stacktrace(), error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. decode_msg_2_doit(server_reflection_request, Bin, TrUserData) -> id(decode_msg_server_reflection_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(extension_request, Bin, TrUserData) -> id(decode_msg_extension_request(Bin, TrUserData), TrUserData); decode_msg_2_doit(server_reflection_response, Bin, TrUserData) -> id(decode_msg_server_reflection_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(file_descriptor_response, Bin, TrUserData) -> id(decode_msg_file_descriptor_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(extension_number_response, Bin, TrUserData) -> id(decode_msg_extension_number_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(list_service_response, Bin, TrUserData) -> id(decode_msg_list_service_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(service_response, Bin, TrUserData) -> id(decode_msg_service_response(Bin, TrUserData), TrUserData); decode_msg_2_doit(error_response, Bin, TrUserData) -> id(decode_msg_error_response(Bin, TrUserData), TrUserData). decode_msg_server_reflection_request(Bin, TrUserData) -> dfp_read_field_def_server_reflection_request(Bin, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_server_reflection_request(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_server_reflection_request_host(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_server_reflection_request(<<26, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_server_reflection_request_file_by_filename(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_server_reflection_request(<<34, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_server_reflection_request_file_containing_symbol(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_server_reflection_request(<<42, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_server_reflection_request_file_containing_extension(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_server_reflection_request(<<50, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_server_reflection_request_all_extension_numbers_of_type(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_server_reflection_request(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_server_reflection_request_list_services(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_server_reflection_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{host => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{message_request => F@_2} end; dfp_read_field_def_server_reflection_request(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_server_reflection_request(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_server_reflection_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_server_reflection_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_server_reflection_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_server_reflection_request_host(Rest, 0, 0, F@_1, F@_2, TrUserData); 26 -> d_field_server_reflection_request_file_by_filename(Rest, 0, 0, F@_1, F@_2, TrUserData); 34 -> d_field_server_reflection_request_file_containing_symbol(Rest, 0, 0, F@_1, F@_2, TrUserData); 42 -> d_field_server_reflection_request_file_containing_extension(Rest, 0, 0, F@_1, F@_2, TrUserData); 50 -> d_field_server_reflection_request_all_extension_numbers_of_type(Rest, 0, 0, F@_1, F@_2, TrUserData); 58 -> d_field_server_reflection_request_list_services(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_server_reflection_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_server_reflection_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_server_reflection_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_server_reflection_request(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_server_reflection_request(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_server_reflection_request(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{host => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{message_request => F@_2} end. d_field_server_reflection_request_host(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_server_reflection_request_host(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_server_reflection_request_host(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_request(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_server_reflection_request_file_by_filename(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_server_reflection_request_file_by_filename(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_server_reflection_request_file_by_filename(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_request(RestF, 0, 0, F@_1, id({file_by_filename, NewFValue}, TrUserData), TrUserData). d_field_server_reflection_request_file_containing_symbol(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_server_reflection_request_file_containing_symbol(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_server_reflection_request_file_containing_symbol(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_request(RestF, 0, 0, F@_1, id({file_containing_symbol, NewFValue}, TrUserData), TrUserData). d_field_server_reflection_request_file_containing_extension(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_server_reflection_request_file_containing_extension(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_server_reflection_request_file_containing_extension(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_extension_request(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_request(RestF, 0, 0, F@_1, case Prev of '$undef' -> id({file_containing_extension, NewFValue}, TrUserData); {file_containing_extension, MVPrev} -> id({file_containing_extension, merge_msg_extension_request(MVPrev, NewFValue, TrUserData)}, TrUserData); _ -> id({file_containing_extension, NewFValue}, TrUserData) end, TrUserData). d_field_server_reflection_request_all_extension_numbers_of_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_server_reflection_request_all_extension_numbers_of_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_server_reflection_request_all_extension_numbers_of_type(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_request(RestF, 0, 0, F@_1, id({all_extension_numbers_of_type, NewFValue}, TrUserData), TrUserData). d_field_server_reflection_request_list_services(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_server_reflection_request_list_services(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_server_reflection_request_list_services(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_request(RestF, 0, 0, F@_1, id({list_services, NewFValue}, TrUserData), TrUserData). skip_varint_server_reflection_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_server_reflection_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_server_reflection_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_server_reflection_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_server_reflection_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_server_reflection_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_server_reflection_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_server_reflection_request(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_server_reflection_request(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_server_reflection_request(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_server_reflection_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_server_reflection_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_server_reflection_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_server_reflection_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_extension_request(Bin, TrUserData) -> dfp_read_field_def_extension_request(Bin, 0, 0, id(<<>>, TrUserData), id(0, TrUserData), TrUserData). dfp_read_field_def_extension_request(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_extension_request_containing_type(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_extension_request(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_extension_request_extension_number(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_extension_request(<<>>, 0, 0, F@_1, F@_2, _) -> #{containing_type => F@_1, extension_number => F@_2}; dfp_read_field_def_extension_request(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_extension_request(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_extension_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_extension_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_extension_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_extension_request_containing_type(Rest, 0, 0, F@_1, F@_2, TrUserData); 16 -> d_field_extension_request_extension_number(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_extension_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_extension_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_extension_request(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_extension_request(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_extension_request(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_extension_request(<<>>, 0, 0, F@_1, F@_2, _) -> #{containing_type => F@_1, extension_number => F@_2}. d_field_extension_request_containing_type(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_extension_request_containing_type(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_extension_request_containing_type(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_extension_request(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_extension_request_extension_number(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_extension_request_extension_number(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_extension_request_extension_number(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_extension_request(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_extension_request(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_extension_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_extension_request(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_extension_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_extension_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_extension_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_extension_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_extension_request(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_extension_request(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_extension_request(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_extension_request(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_extension_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_extension_request(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_extension_request(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_server_reflection_response(Bin, TrUserData) -> dfp_read_field_def_server_reflection_response(Bin, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_server_reflection_response(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_server_reflection_response_valid_host(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_server_reflection_response(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_server_reflection_response_original_request(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_server_reflection_response(<<34, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_server_reflection_response_file_descriptor_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_server_reflection_response(<<42, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_server_reflection_response_all_extension_numbers_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_server_reflection_response(<<50, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_server_reflection_response_list_services_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_server_reflection_response(<<58, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> d_field_server_reflection_response_error_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); dfp_read_field_def_server_reflection_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{valid_host => F@_1}, S2 = if F@_2 == '$undef' -> S1; true -> S1#{original_request => F@_2} end, if F@_3 == '$undef' -> S2; true -> S2#{message_response => F@_3} end; dfp_read_field_def_server_reflection_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dg_read_field_def_server_reflection_response(Other, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). dg_read_field_def_server_reflection_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 32 - 7 -> dg_read_field_def_server_reflection_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); dg_read_field_def_server_reflection_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_server_reflection_response_valid_host(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 18 -> d_field_server_reflection_response_original_request(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 34 -> d_field_server_reflection_response_file_descriptor_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 42 -> d_field_server_reflection_response_all_extension_numbers_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 50 -> d_field_server_reflection_response_list_services_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 58 -> d_field_server_reflection_response_error_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_server_reflection_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 1 -> skip_64_server_reflection_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 2 -> skip_length_delimited_server_reflection_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData); 3 -> skip_group_server_reflection_response(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, TrUserData); 5 -> skip_32_server_reflection_response(Rest, 0, 0, F@_1, F@_2, F@_3, TrUserData) end end; dg_read_field_def_server_reflection_response(<<>>, 0, 0, F@_1, F@_2, F@_3, _) -> S1 = #{valid_host => F@_1}, S2 = if F@_2 == '$undef' -> S1; true -> S1#{original_request => F@_2} end, if F@_3 == '$undef' -> S2; true -> S2#{message_response => F@_3} end. d_field_server_reflection_response_valid_host(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_server_reflection_response_valid_host(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_server_reflection_response_valid_host(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_response(RestF, 0, 0, NewFValue, F@_2, F@_3, TrUserData). d_field_server_reflection_response_original_request(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_server_reflection_response_original_request(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_server_reflection_response_original_request(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, F@_3, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_server_reflection_request(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_response(RestF, 0, 0, F@_1, if Prev == '$undef' -> NewFValue; true -> merge_msg_server_reflection_request(Prev, NewFValue, TrUserData) end, F@_3, TrUserData). d_field_server_reflection_response_file_descriptor_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_server_reflection_response_file_descriptor_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_server_reflection_response_file_descriptor_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_file_descriptor_response(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_response(RestF, 0, 0, F@_1, F@_2, case Prev of '$undef' -> id({file_descriptor_response, NewFValue}, TrUserData); {file_descriptor_response, MVPrev} -> id({file_descriptor_response, merge_msg_file_descriptor_response(MVPrev, NewFValue, TrUserData)}, TrUserData); _ -> id({file_descriptor_response, NewFValue}, TrUserData) end, TrUserData). d_field_server_reflection_response_all_extension_numbers_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_server_reflection_response_all_extension_numbers_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_server_reflection_response_all_extension_numbers_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_extension_number_response(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_response(RestF, 0, 0, F@_1, F@_2, case Prev of '$undef' -> id({all_extension_numbers_response, NewFValue}, TrUserData); {all_extension_numbers_response, MVPrev} -> id({all_extension_numbers_response, merge_msg_extension_number_response(MVPrev, NewFValue, TrUserData)}, TrUserData); _ -> id({all_extension_numbers_response, NewFValue}, TrUserData) end, TrUserData). d_field_server_reflection_response_list_services_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_server_reflection_response_list_services_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_server_reflection_response_list_services_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_list_service_response(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_response(RestF, 0, 0, F@_1, F@_2, case Prev of '$undef' -> id({list_services_response, NewFValue}, TrUserData); {list_services_response, MVPrev} -> id({list_services_response, merge_msg_list_service_response(MVPrev, NewFValue, TrUserData)}, TrUserData); _ -> id({list_services_response, NewFValue}, TrUserData) end, TrUserData). d_field_server_reflection_response_error_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> d_field_server_reflection_response_error_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); d_field_server_reflection_response_error_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_error_response(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_server_reflection_response(RestF, 0, 0, F@_1, F@_2, case Prev of '$undef' -> id({error_response, NewFValue}, TrUserData); {error_response, MVPrev} -> id({error_response, merge_msg_error_response(MVPrev, NewFValue, TrUserData)}, TrUserData); _ -> id({error_response, NewFValue}, TrUserData) end, TrUserData). skip_varint_server_reflection_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> skip_varint_server_reflection_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData); skip_varint_server_reflection_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_server_reflection_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_length_delimited_server_reflection_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) when N < 57 -> skip_length_delimited_server_reflection_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData); skip_length_delimited_server_reflection_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_server_reflection_response(Rest2, 0, 0, F@_1, F@_2, F@_3, TrUserData). skip_group_server_reflection_response(Bin, FNum, Z2, F@_1, F@_2, F@_3, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_server_reflection_response(Rest, 0, Z2, F@_1, F@_2, F@_3, TrUserData). skip_32_server_reflection_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_server_reflection_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). skip_64_server_reflection_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, TrUserData) -> dfp_read_field_def_server_reflection_response(Rest, Z1, Z2, F@_1, F@_2, F@_3, TrUserData). decode_msg_file_descriptor_response(Bin, TrUserData) -> dfp_read_field_def_file_descriptor_response(Bin, 0, 0, id([], TrUserData), TrUserData). dfp_read_field_def_file_descriptor_response(<<10, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_file_descriptor_response_file_descriptor_proto(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_file_descriptor_response(<<>>, 0, 0, R1, TrUserData) -> #{file_descriptor_proto => lists_reverse(R1, TrUserData)}; dfp_read_field_def_file_descriptor_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_file_descriptor_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_file_descriptor_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_file_descriptor_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_file_descriptor_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_file_descriptor_response_file_descriptor_proto(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_file_descriptor_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_file_descriptor_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_file_descriptor_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_file_descriptor_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_file_descriptor_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_file_descriptor_response(<<>>, 0, 0, R1, TrUserData) -> #{file_descriptor_proto => lists_reverse(R1, TrUserData)}. d_field_file_descriptor_response_file_descriptor_proto(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_file_descriptor_response_file_descriptor_proto(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_file_descriptor_response_file_descriptor_proto(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_file_descriptor_response(RestF, 0, 0, cons(NewFValue, Prev, TrUserData), TrUserData). skip_varint_file_descriptor_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_file_descriptor_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_file_descriptor_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_file_descriptor_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_file_descriptor_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_file_descriptor_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_file_descriptor_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_file_descriptor_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_file_descriptor_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_file_descriptor_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_file_descriptor_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_file_descriptor_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_file_descriptor_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_file_descriptor_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_extension_number_response(Bin, TrUserData) -> dfp_read_field_def_extension_number_response(Bin, 0, 0, id(<<>>, TrUserData), id([], TrUserData), TrUserData). dfp_read_field_def_extension_number_response(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_extension_number_response_base_type_name(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_extension_number_response(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_pfield_extension_number_response_extension_number(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_extension_number_response(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_extension_number_response_extension_number(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_extension_number_response(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{base_type_name => F@_1, extension_number => lists_reverse(R1, TrUserData)}; dfp_read_field_def_extension_number_response(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_extension_number_response(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_extension_number_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_extension_number_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_extension_number_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_extension_number_response_base_type_name(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_pfield_extension_number_response_extension_number(Rest, 0, 0, F@_1, F@_2, TrUserData); 16 -> d_field_extension_number_response_extension_number(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_extension_number_response(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_extension_number_response(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_extension_number_response(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_extension_number_response(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_extension_number_response(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_extension_number_response(<<>>, 0, 0, F@_1, R1, TrUserData) -> #{base_type_name => F@_1, extension_number => lists_reverse(R1, TrUserData)}. d_field_extension_number_response_base_type_name(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_extension_number_response_base_type_name(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_extension_number_response_base_type_name(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_extension_number_response(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_extension_number_response_extension_number(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_extension_number_response_extension_number(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_extension_number_response_extension_number(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_extension_number_response(RestF, 0, 0, F@_1, cons(NewFValue, Prev, TrUserData), TrUserData). d_pfield_extension_number_response_extension_number(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_pfield_extension_number_response_extension_number(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_pfield_extension_number_response_extension_number(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, E, TrUserData) -> Len = X bsl N + Acc, <> = Rest, NewSeq = d_packed_field_extension_number_response_extension_number(PackedBytes, 0, 0, E, TrUserData), dfp_read_field_def_extension_number_response(Rest2, 0, 0, F@_1, NewSeq, TrUserData). d_packed_field_extension_number_response_extension_number(<<1:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) when N < 57 -> d_packed_field_extension_number_response_extension_number(Rest, N + 7, X bsl N + Acc, AccSeq, TrUserData); d_packed_field_extension_number_response_extension_number(<<0:1, X:7, Rest/binary>>, N, Acc, AccSeq, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, d_packed_field_extension_number_response_extension_number(RestF, 0, 0, [NewFValue | AccSeq], TrUserData); d_packed_field_extension_number_response_extension_number(<<>>, 0, 0, AccSeq, _) -> AccSeq. skip_varint_extension_number_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_extension_number_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_extension_number_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_extension_number_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_extension_number_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_extension_number_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_extension_number_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_extension_number_response(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_extension_number_response(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_extension_number_response(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_extension_number_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_extension_number_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_extension_number_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_extension_number_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_list_service_response(Bin, TrUserData) -> dfp_read_field_def_list_service_response(Bin, 0, 0, id([], TrUserData), TrUserData). dfp_read_field_def_list_service_response(<<10, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_list_service_response_service(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_list_service_response(<<>>, 0, 0, R1, TrUserData) -> S1 = #{}, if R1 == '$undef' -> S1; true -> S1#{service => lists_reverse(R1, TrUserData)} end; dfp_read_field_def_list_service_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_list_service_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_list_service_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_list_service_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_list_service_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_list_service_response_service(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_list_service_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_list_service_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_list_service_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_list_service_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_list_service_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_list_service_response(<<>>, 0, 0, R1, TrUserData) -> S1 = #{}, if R1 == '$undef' -> S1; true -> S1#{service => lists_reverse(R1, TrUserData)} end. d_field_list_service_response_service(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_list_service_response_service(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_list_service_response_service(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_service_response(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_list_service_response(RestF, 0, 0, cons(NewFValue, Prev, TrUserData), TrUserData). skip_varint_list_service_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_list_service_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_list_service_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_list_service_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_list_service_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_list_service_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_list_service_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_list_service_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_list_service_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_list_service_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_list_service_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_list_service_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_list_service_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_list_service_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_service_response(Bin, TrUserData) -> dfp_read_field_def_service_response(Bin, 0, 0, id(<<>>, TrUserData), TrUserData). dfp_read_field_def_service_response(<<10, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> d_field_service_response_name(Rest, Z1, Z2, F@_1, TrUserData); dfp_read_field_def_service_response(<<>>, 0, 0, F@_1, _) -> #{name => F@_1}; dfp_read_field_def_service_response(Other, Z1, Z2, F@_1, TrUserData) -> dg_read_field_def_service_response(Other, Z1, Z2, F@_1, TrUserData). dg_read_field_def_service_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 32 - 7 -> dg_read_field_def_service_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); dg_read_field_def_service_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_service_response_name(Rest, 0, 0, F@_1, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_service_response(Rest, 0, 0, F@_1, TrUserData); 1 -> skip_64_service_response(Rest, 0, 0, F@_1, TrUserData); 2 -> skip_length_delimited_service_response(Rest, 0, 0, F@_1, TrUserData); 3 -> skip_group_service_response(Rest, Key bsr 3, 0, F@_1, TrUserData); 5 -> skip_32_service_response(Rest, 0, 0, F@_1, TrUserData) end end; dg_read_field_def_service_response(<<>>, 0, 0, F@_1, _) -> #{name => F@_1}. d_field_service_response_name(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> d_field_service_response_name(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); d_field_service_response_name(<<0:1, X:7, Rest/binary>>, N, Acc, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_service_response(RestF, 0, 0, NewFValue, TrUserData). skip_varint_service_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> skip_varint_service_response(Rest, Z1, Z2, F@_1, TrUserData); skip_varint_service_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_service_response(Rest, Z1, Z2, F@_1, TrUserData). skip_length_delimited_service_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) when N < 57 -> skip_length_delimited_service_response(Rest, N + 7, X bsl N + Acc, F@_1, TrUserData); skip_length_delimited_service_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_service_response(Rest2, 0, 0, F@_1, TrUserData). skip_group_service_response(Bin, FNum, Z2, F@_1, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_service_response(Rest, 0, Z2, F@_1, TrUserData). skip_32_service_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_service_response(Rest, Z1, Z2, F@_1, TrUserData). skip_64_service_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, TrUserData) -> dfp_read_field_def_service_response(Rest, Z1, Z2, F@_1, TrUserData). decode_msg_error_response(Bin, TrUserData) -> dfp_read_field_def_error_response(Bin, 0, 0, id(0, TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_error_response(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_error_response_error_code(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_error_response(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_error_response_error_message(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_error_response(<<>>, 0, 0, F@_1, F@_2, _) -> #{error_code => F@_1, error_message => F@_2}; dfp_read_field_def_error_response(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_error_response(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_error_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_error_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_error_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_error_response_error_code(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_error_response_error_message(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_error_response(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_error_response(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_error_response(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_error_response(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_error_response(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_error_response(<<>>, 0, 0, F@_1, F@_2, _) -> #{error_code => F@_1, error_message => F@_2}. d_field_error_response_error_code(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_error_response_error_code(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_error_response_error_code(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_error_response(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_error_response_error_message(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_error_response_error_message(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_error_response_error_message(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_error_response(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_error_response(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_error_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_error_response(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_error_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_error_response(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_error_response(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_error_response(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_error_response(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_error_response(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_error_response(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_error_response(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_error_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_error_response(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_error_response(Rest, Z1, Z2, F@_1, F@_2, TrUserData). read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, {Group, Rest}. %% Like skipping over fields, but record the total length, %% Each field is <(FieldNum bsl 3) bor FieldType> ++ %% Record the length because varints may be non-optimally encoded. %% %% Groups can be nested, but assume the same FieldNum cannot be nested %% because group field numbers are shared with the rest of the fields %% numbers. Thus we can search just for an group-end with the same %% field number. %% %% (The only time the same group field number could occur would %% be in a nested sub message, but then it would be inside a %% length-delimited entry, which we skip-read by length.) read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) when N < (32-7) -> read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) -> Key = X bsl N + Acc, TagLen1 = TagLen + 1, case {Key bsr 3, Key band 7} of {FieldNum, 4} -> % 4 = group_end {NumBytes, TagLen1}; {_, 0} -> % 0 = varint read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); {_, 1} -> % 1 = bits64 <<_:64, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); {_, 2} -> % 2 = length_delimited read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); {_, 3} -> % 3 = group_start read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 4} -> % 4 = group_end read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 5} -> % 5 = bits32 <<_:32, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) end. read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) when N < (64-7) -> read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) when N < (64-7) -> read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> Len = X bsl N + Acc, NumBytes1 = NumBytes + 1, <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of server_reflection_request -> merge_msg_server_reflection_request(Prev, New, TrUserData); extension_request -> merge_msg_extension_request(Prev, New, TrUserData); server_reflection_response -> merge_msg_server_reflection_response(Prev, New, TrUserData); file_descriptor_response -> merge_msg_file_descriptor_response(Prev, New, TrUserData); extension_number_response -> merge_msg_extension_number_response(Prev, New, TrUserData); list_service_response -> merge_msg_list_service_response(Prev, New, TrUserData); service_response -> merge_msg_service_response(Prev, New, TrUserData); error_response -> merge_msg_error_response(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_server_reflection_request/3}). merge_msg_server_reflection_request(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{host := NFhost}} -> S1#{host => NFhost}; {#{host := PFhost}, _} -> S1#{host => PFhost}; _ -> S1 end, case {PMsg, NMsg} of {#{message_request := {file_containing_extension, OPFmessage_request}}, #{message_request := {file_containing_extension, ONFmessage_request}}} -> S2#{message_request => {file_containing_extension, merge_msg_extension_request(OPFmessage_request, ONFmessage_request, TrUserData)}}; {_, #{message_request := NFmessage_request}} -> S2#{message_request => NFmessage_request}; {#{message_request := PFmessage_request}, _} -> S2#{message_request => PFmessage_request}; {_, _} -> S2 end. -compile({nowarn_unused_function,merge_msg_extension_request/3}). merge_msg_extension_request(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{containing_type := NFcontaining_type}} -> S1#{containing_type => NFcontaining_type}; {#{containing_type := PFcontaining_type}, _} -> S1#{containing_type => PFcontaining_type}; _ -> S1 end, case {PMsg, NMsg} of {_, #{extension_number := NFextension_number}} -> S2#{extension_number => NFextension_number}; {#{extension_number := PFextension_number}, _} -> S2#{extension_number => PFextension_number}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_server_reflection_response/3}). merge_msg_server_reflection_response(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{valid_host := NFvalid_host}} -> S1#{valid_host => NFvalid_host}; {#{valid_host := PFvalid_host}, _} -> S1#{valid_host => PFvalid_host}; _ -> S1 end, S3 = case {PMsg, NMsg} of {#{original_request := PForiginal_request}, #{original_request := NForiginal_request}} -> S2#{original_request => merge_msg_server_reflection_request(PForiginal_request, NForiginal_request, TrUserData)}; {_, #{original_request := NForiginal_request}} -> S2#{original_request => NForiginal_request}; {#{original_request := PForiginal_request}, _} -> S2#{original_request => PForiginal_request}; {_, _} -> S2 end, case {PMsg, NMsg} of {#{message_response := {file_descriptor_response, OPFmessage_response}}, #{message_response := {file_descriptor_response, ONFmessage_response}}} -> S3#{message_response => {file_descriptor_response, merge_msg_file_descriptor_response(OPFmessage_response, ONFmessage_response, TrUserData)}}; {#{message_response := {all_extension_numbers_response, OPFmessage_response}}, #{message_response := {all_extension_numbers_response, ONFmessage_response}}} -> S3#{message_response => {all_extension_numbers_response, merge_msg_extension_number_response(OPFmessage_response, ONFmessage_response, TrUserData)}}; {#{message_response := {list_services_response, OPFmessage_response}}, #{message_response := {list_services_response, ONFmessage_response}}} -> S3#{message_response => {list_services_response, merge_msg_list_service_response(OPFmessage_response, ONFmessage_response, TrUserData)}}; {#{message_response := {error_response, OPFmessage_response}}, #{message_response := {error_response, ONFmessage_response}}} -> S3#{message_response => {error_response, merge_msg_error_response(OPFmessage_response, ONFmessage_response, TrUserData)}}; {_, #{message_response := NFmessage_response}} -> S3#{message_response => NFmessage_response}; {#{message_response := PFmessage_response}, _} -> S3#{message_response => PFmessage_response}; {_, _} -> S3 end. -compile({nowarn_unused_function,merge_msg_file_descriptor_response/3}). merge_msg_file_descriptor_response(PMsg, NMsg, TrUserData) -> S1 = #{}, case {PMsg, NMsg} of {#{file_descriptor_proto := PFfile_descriptor_proto}, #{file_descriptor_proto := NFfile_descriptor_proto}} -> S1#{file_descriptor_proto => 'erlang_++'(PFfile_descriptor_proto, NFfile_descriptor_proto, TrUserData)}; {_, #{file_descriptor_proto := NFfile_descriptor_proto}} -> S1#{file_descriptor_proto => NFfile_descriptor_proto}; {#{file_descriptor_proto := PFfile_descriptor_proto}, _} -> S1#{file_descriptor_proto => PFfile_descriptor_proto}; {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_extension_number_response/3}). merge_msg_extension_number_response(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{base_type_name := NFbase_type_name}} -> S1#{base_type_name => NFbase_type_name}; {#{base_type_name := PFbase_type_name}, _} -> S1#{base_type_name => PFbase_type_name}; _ -> S1 end, case {PMsg, NMsg} of {#{extension_number := PFextension_number}, #{extension_number := NFextension_number}} -> S2#{extension_number => 'erlang_++'(PFextension_number, NFextension_number, TrUserData)}; {_, #{extension_number := NFextension_number}} -> S2#{extension_number => NFextension_number}; {#{extension_number := PFextension_number}, _} -> S2#{extension_number => PFextension_number}; {_, _} -> S2 end. -compile({nowarn_unused_function,merge_msg_list_service_response/3}). merge_msg_list_service_response(PMsg, NMsg, TrUserData) -> S1 = #{}, case {PMsg, NMsg} of {#{service := PFservice}, #{service := NFservice}} -> S1#{service => 'erlang_++'(PFservice, NFservice, TrUserData)}; {_, #{service := NFservice}} -> S1#{service => NFservice}; {#{service := PFservice}, _} -> S1#{service => PFservice}; {_, _} -> S1 end. -compile({nowarn_unused_function,merge_msg_service_response/3}). merge_msg_service_response(PMsg, NMsg, _) -> S1 = #{}, case {PMsg, NMsg} of {_, #{name := NFname}} -> S1#{name => NFname}; {#{name := PFname}, _} -> S1#{name => PFname}; _ -> S1 end. -compile({nowarn_unused_function,merge_msg_error_response/3}). merge_msg_error_response(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{error_code := NFerror_code}} -> S1#{error_code => NFerror_code}; {#{error_code := PFerror_code}, _} -> S1#{error_code => PFerror_code}; _ -> S1 end, case {PMsg, NMsg} of {_, #{error_message := NFerror_message}} -> S2#{error_message => NFerror_message}; {#{error_message := PFerror_message}, _} -> S2#{error_message => PFerror_message}; _ -> S2 end. verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of server_reflection_request -> v_msg_server_reflection_request(Msg, [MsgName], TrUserData); extension_request -> v_msg_extension_request(Msg, [MsgName], TrUserData); server_reflection_response -> v_msg_server_reflection_response(Msg, [MsgName], TrUserData); file_descriptor_response -> v_msg_file_descriptor_response(Msg, [MsgName], TrUserData); extension_number_response -> v_msg_extension_number_response(Msg, [MsgName], TrUserData); list_service_response -> v_msg_list_service_response(Msg, [MsgName], TrUserData); service_response -> v_msg_service_response(Msg, [MsgName], TrUserData); error_response -> v_msg_error_response(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_server_reflection_request/3}). -dialyzer({nowarn_function,v_msg_server_reflection_request/3}). v_msg_server_reflection_request(#{} = M, Path, TrUserData) -> case M of #{host := F1} -> v_type_string(F1, [host | Path], TrUserData); _ -> ok end, case M of #{message_request := {file_by_filename, OF2}} -> v_type_string(OF2, [file_by_filename, message_request | Path], TrUserData); #{message_request := {file_containing_symbol, OF2}} -> v_type_string(OF2, [file_containing_symbol, message_request | Path], TrUserData); #{message_request := {file_containing_extension, OF2}} -> v_msg_extension_request(OF2, [file_containing_extension, message_request | Path], TrUserData); #{message_request := {all_extension_numbers_of_type, OF2}} -> v_type_string(OF2, [all_extension_numbers_of_type, message_request | Path], TrUserData); #{message_request := {list_services, OF2}} -> v_type_string(OF2, [list_services, message_request | Path], TrUserData); #{message_request := F2} -> mk_type_error(invalid_oneof, F2, [message_request | Path]); _ -> ok end, lists:foreach(fun (host) -> ok; (message_request) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_server_reflection_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), server_reflection_request}, M, Path); v_msg_server_reflection_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, server_reflection_request}, X, Path). -compile({nowarn_unused_function,v_msg_extension_request/3}). -dialyzer({nowarn_function,v_msg_extension_request/3}). v_msg_extension_request(#{} = M, Path, TrUserData) -> case M of #{containing_type := F1} -> v_type_string(F1, [containing_type | Path], TrUserData); _ -> ok end, case M of #{extension_number := F2} -> v_type_int32(F2, [extension_number | Path], TrUserData); _ -> ok end, lists:foreach(fun (containing_type) -> ok; (extension_number) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_extension_request(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), extension_request}, M, Path); v_msg_extension_request(X, Path, _TrUserData) -> mk_type_error({expected_msg, extension_request}, X, Path). -compile({nowarn_unused_function,v_msg_server_reflection_response/3}). -dialyzer({nowarn_function,v_msg_server_reflection_response/3}). v_msg_server_reflection_response(#{} = M, Path, TrUserData) -> case M of #{valid_host := F1} -> v_type_string(F1, [valid_host | Path], TrUserData); _ -> ok end, case M of #{original_request := F2} -> v_msg_server_reflection_request(F2, [original_request | Path], TrUserData); _ -> ok end, case M of #{message_response := {file_descriptor_response, OF3}} -> v_msg_file_descriptor_response(OF3, [file_descriptor_response, message_response | Path], TrUserData); #{message_response := {all_extension_numbers_response, OF3}} -> v_msg_extension_number_response(OF3, [all_extension_numbers_response, message_response | Path], TrUserData); #{message_response := {list_services_response, OF3}} -> v_msg_list_service_response(OF3, [list_services_response, message_response | Path], TrUserData); #{message_response := {error_response, OF3}} -> v_msg_error_response(OF3, [error_response, message_response | Path], TrUserData); #{message_response := F3} -> mk_type_error(invalid_oneof, F3, [message_response | Path]); _ -> ok end, lists:foreach(fun (valid_host) -> ok; (original_request) -> ok; (message_response) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_server_reflection_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), server_reflection_response}, M, Path); v_msg_server_reflection_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, server_reflection_response}, X, Path). -compile({nowarn_unused_function,v_msg_file_descriptor_response/3}). -dialyzer({nowarn_function,v_msg_file_descriptor_response/3}). v_msg_file_descriptor_response(#{} = M, Path, TrUserData) -> case M of #{file_descriptor_proto := F1} -> if is_list(F1) -> _ = [v_type_bytes(Elem, [file_descriptor_proto | Path], TrUserData) || Elem <- F1], ok; true -> mk_type_error({invalid_list_of, bytes}, F1, [file_descriptor_proto | Path]) end; _ -> ok end, lists:foreach(fun (file_descriptor_proto) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_file_descriptor_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), file_descriptor_response}, M, Path); v_msg_file_descriptor_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, file_descriptor_response}, X, Path). -compile({nowarn_unused_function,v_msg_extension_number_response/3}). -dialyzer({nowarn_function,v_msg_extension_number_response/3}). v_msg_extension_number_response(#{} = M, Path, TrUserData) -> case M of #{base_type_name := F1} -> v_type_string(F1, [base_type_name | Path], TrUserData); _ -> ok end, case M of #{extension_number := F2} -> if is_list(F2) -> _ = [v_type_int32(Elem, [extension_number | Path], TrUserData) || Elem <- F2], ok; true -> mk_type_error({invalid_list_of, int32}, F2, [extension_number | Path]) end; _ -> ok end, lists:foreach(fun (base_type_name) -> ok; (extension_number) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_extension_number_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), extension_number_response}, M, Path); v_msg_extension_number_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, extension_number_response}, X, Path). -compile({nowarn_unused_function,v_msg_list_service_response/3}). -dialyzer({nowarn_function,v_msg_list_service_response/3}). v_msg_list_service_response(#{} = M, Path, TrUserData) -> case M of #{service := F1} -> if is_list(F1) -> _ = [v_msg_service_response(Elem, [service | Path], TrUserData) || Elem <- F1], ok; true -> mk_type_error({invalid_list_of, {msg, service_response}}, F1, [service | Path]) end; _ -> ok end, lists:foreach(fun (service) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_list_service_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), list_service_response}, M, Path); v_msg_list_service_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, list_service_response}, X, Path). -compile({nowarn_unused_function,v_msg_service_response/3}). -dialyzer({nowarn_function,v_msg_service_response/3}). v_msg_service_response(#{} = M, Path, TrUserData) -> case M of #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); _ -> ok end, lists:foreach(fun (name) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_service_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), service_response}, M, Path); v_msg_service_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, service_response}, X, Path). -compile({nowarn_unused_function,v_msg_error_response/3}). -dialyzer({nowarn_function,v_msg_error_response/3}). v_msg_error_response(#{} = M, Path, TrUserData) -> case M of #{error_code := F1} -> v_type_int32(F1, [error_code | Path], TrUserData); _ -> ok end, case M of #{error_message := F2} -> v_type_string(F2, [error_message | Path], TrUserData); _ -> ok end, lists:foreach(fun (error_code) -> ok; (error_message) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_error_response(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), error_response}, M, Path); v_msg_error_response(X, Path, _TrUserData) -> mk_type_error({expected_msg, error_response}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -dialyzer({nowarn_function,v_type_int32/3}). v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,v_type_bytes/3}). -dialyzer({nowarn_function,v_type_bytes/3}). v_type_bytes(B, _Path, _TrUserData) when is_binary(B) -> ok; v_type_bytes(B, _Path, _TrUserData) when is_list(B) -> ok; v_type_bytes(X, Path, _TrUserData) -> mk_type_error(bad_binary_value, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; prettify_path(PathR) -> list_to_atom(lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR))))). -compile({nowarn_unused_function,id/2}). -compile({inline,id/2}). id(X, _TrUserData) -> X. -compile({nowarn_unused_function,v_ok/3}). -compile({inline,v_ok/3}). v_ok(_Value, _Path, _TrUserData) -> ok. -compile({nowarn_unused_function,m_overwrite/3}). -compile({inline,m_overwrite/3}). m_overwrite(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. -compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). -compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. get_msg_defs() -> [{{msg, server_reflection_request}, [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => message_request, rnum => 3, fields => [#{name => file_by_filename, fnum => 3, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => file_containing_symbol, fnum => 4, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => file_containing_extension, fnum => 5, rnum => 3, type => {msg, extension_request}, occurrence => optional, opts => []}, #{name => all_extension_numbers_of_type, fnum => 6, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => list_services, fnum => 7, rnum => 3, type => string, occurrence => optional, opts => []}]}]}, {{msg, extension_request}, [#{name => containing_type, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => extension_number, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}, {{msg, server_reflection_response}, [#{name => valid_host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => original_request, fnum => 2, rnum => 3, type => {msg, server_reflection_request}, occurrence => optional, opts => []}, #{name => message_response, rnum => 4, fields => [#{name => file_descriptor_response, fnum => 4, rnum => 4, type => {msg, file_descriptor_response}, occurrence => optional, opts => []}, #{name => all_extension_numbers_response, fnum => 5, rnum => 4, type => {msg, extension_number_response}, occurrence => optional, opts => []}, #{name => list_services_response, fnum => 6, rnum => 4, type => {msg, list_service_response}, occurrence => optional, opts => []}, #{name => error_response, fnum => 7, rnum => 4, type => {msg, error_response}, occurrence => optional, opts => []}]}]}, {{msg, file_descriptor_response}, [#{name => file_descriptor_proto, fnum => 1, rnum => 2, type => bytes, occurrence => repeated, opts => []}]}, {{msg, extension_number_response}, [#{name => base_type_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => extension_number, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]}, {{msg, list_service_response}, [#{name => service, fnum => 1, rnum => 2, type => {msg, service_response}, occurrence => repeated, opts => []}]}, {{msg, service_response}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]}, {{msg, error_response}, [#{name => error_code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => error_message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}]. get_msg_names() -> [server_reflection_request, extension_request, server_reflection_response, file_descriptor_response, extension_number_response, list_service_response, service_response, error_response]. get_group_names() -> []. get_msg_or_group_names() -> [server_reflection_request, extension_request, server_reflection_response, file_descriptor_response, extension_number_response, list_service_response, service_response, error_response]. get_enum_names() -> []. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of Fs when is_list(Fs) -> Fs; error -> erlang:error({no_such_msg, MsgName}) end. -spec fetch_enum_def(_) -> no_return(). fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). find_msg_def(server_reflection_request) -> [#{name => host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => message_request, rnum => 3, fields => [#{name => file_by_filename, fnum => 3, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => file_containing_symbol, fnum => 4, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => file_containing_extension, fnum => 5, rnum => 3, type => {msg, extension_request}, occurrence => optional, opts => []}, #{name => all_extension_numbers_of_type, fnum => 6, rnum => 3, type => string, occurrence => optional, opts => []}, #{name => list_services, fnum => 7, rnum => 3, type => string, occurrence => optional, opts => []}]}]; find_msg_def(extension_request) -> [#{name => containing_type, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => extension_number, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; find_msg_def(server_reflection_response) -> [#{name => valid_host, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => original_request, fnum => 2, rnum => 3, type => {msg, server_reflection_request}, occurrence => optional, opts => []}, #{name => message_response, rnum => 4, fields => [#{name => file_descriptor_response, fnum => 4, rnum => 4, type => {msg, file_descriptor_response}, occurrence => optional, opts => []}, #{name => all_extension_numbers_response, fnum => 5, rnum => 4, type => {msg, extension_number_response}, occurrence => optional, opts => []}, #{name => list_services_response, fnum => 6, rnum => 4, type => {msg, list_service_response}, occurrence => optional, opts => []}, #{name => error_response, fnum => 7, rnum => 4, type => {msg, error_response}, occurrence => optional, opts => []}]}]; find_msg_def(file_descriptor_response) -> [#{name => file_descriptor_proto, fnum => 1, rnum => 2, type => bytes, occurrence => repeated, opts => []}]; find_msg_def(extension_number_response) -> [#{name => base_type_name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => extension_number, fnum => 2, rnum => 3, type => int32, occurrence => repeated, opts => [packed]}]; find_msg_def(list_service_response) -> [#{name => service, fnum => 1, rnum => 2, type => {msg, service_response}, occurrence => repeated, opts => []}]; find_msg_def(service_response) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}]; find_msg_def(error_response) -> [#{name => error_code, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => error_message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; find_msg_def(_) -> error. find_enum_def(_) -> error. -spec enum_symbol_by_value(_, _) -> no_return(). enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). -spec enum_value_by_symbol(_, _) -> no_return(). enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). get_service_names() -> ['grpc.reflection.v1alpha.ServerReflection']. get_service_def('grpc.reflection.v1alpha.ServerReflection') -> {{service, 'grpc.reflection.v1alpha.ServerReflection'}, [#{name => 'ServerReflectionInfo', input => server_reflection_request, output => server_reflection_response, input_stream => true, output_stream => true, opts => []}]}; get_service_def(_) -> error. get_rpc_names('grpc.reflection.v1alpha.ServerReflection') -> ['ServerReflectionInfo']; get_rpc_names(_) -> error. find_rpc_def('grpc.reflection.v1alpha.ServerReflection', RpcName) -> 'find_rpc_def_grpc.reflection.v1alpha.ServerReflection'(RpcName); find_rpc_def(_, _) -> error. 'find_rpc_def_grpc.reflection.v1alpha.ServerReflection'('ServerReflectionInfo') -> #{name => 'ServerReflectionInfo', input => server_reflection_request, output => server_reflection_response, input_stream => true, output_stream => true, opts => []}; 'find_rpc_def_grpc.reflection.v1alpha.ServerReflection'(_) -> error. fetch_rpc_def(ServiceName, RpcName) -> case find_rpc_def(ServiceName, RpcName) of Def when is_map(Def) -> Def; error -> erlang:error({no_such_rpc, ServiceName, RpcName}) end. %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. fqbin_to_service_name(<<"grpc.reflection.v1alpha.ServerReflection">>) -> 'grpc.reflection.v1alpha.ServerReflection'; fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. service_name_to_fqbin('grpc.reflection.v1alpha.ServerReflection') -> <<"grpc.reflection.v1alpha.ServerReflection">>; service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. fqbins_to_service_and_rpc_name(<<"grpc.reflection.v1alpha.ServerReflection">>, <<"ServerReflectionInfo">>) -> {'grpc.reflection.v1alpha.ServerReflection', 'ServerReflectionInfo'}; fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. service_and_rpc_name_to_fqbins('grpc.reflection.v1alpha.ServerReflection', 'ServerReflectionInfo') -> {<<"grpc.reflection.v1alpha.ServerReflection">>, <<"ServerReflectionInfo">>}; service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"grpc.reflection.v1alpha.ServerReflectionRequest">>) -> server_reflection_request; fqbin_to_msg_name(<<"grpc.reflection.v1alpha.ExtensionRequest">>) -> extension_request; fqbin_to_msg_name(<<"grpc.reflection.v1alpha.ServerReflectionResponse">>) -> server_reflection_response; fqbin_to_msg_name(<<"grpc.reflection.v1alpha.FileDescriptorResponse">>) -> file_descriptor_response; fqbin_to_msg_name(<<"grpc.reflection.v1alpha.ExtensionNumberResponse">>) -> extension_number_response; fqbin_to_msg_name(<<"grpc.reflection.v1alpha.ListServiceResponse">>) -> list_service_response; fqbin_to_msg_name(<<"grpc.reflection.v1alpha.ServiceResponse">>) -> service_response; fqbin_to_msg_name(<<"grpc.reflection.v1alpha.ErrorResponse">>) -> error_response; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin(server_reflection_request) -> <<"grpc.reflection.v1alpha.ServerReflectionRequest">>; msg_name_to_fqbin(extension_request) -> <<"grpc.reflection.v1alpha.ExtensionRequest">>; msg_name_to_fqbin(server_reflection_response) -> <<"grpc.reflection.v1alpha.ServerReflectionResponse">>; msg_name_to_fqbin(file_descriptor_response) -> <<"grpc.reflection.v1alpha.FileDescriptorResponse">>; msg_name_to_fqbin(extension_number_response) -> <<"grpc.reflection.v1alpha.ExtensionNumberResponse">>; msg_name_to_fqbin(list_service_response) -> <<"grpc.reflection.v1alpha.ListServiceResponse">>; msg_name_to_fqbin(service_response) -> <<"grpc.reflection.v1alpha.ServiceResponse">>; msg_name_to_fqbin(error_response) -> <<"grpc.reflection.v1alpha.ErrorResponse">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec fqbin_to_enum_name(_) -> no_return(). fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). -spec enum_name_to_fqbin(_) -> no_return(). enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> 'grpc.reflection.v1alpha'. %% Whether or not the message names %% are prepended with package name or not. uses_packages() -> true. source_basename() -> "reflection.proto". %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension get_all_source_basenames() -> ["reflection.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. get_all_proto_names() -> ["reflection"]. get_msg_containment("reflection") -> [error_response, extension_number_response, extension_request, file_descriptor_response, list_service_response, server_reflection_request, server_reflection_response, service_response]; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("reflection") -> 'grpc.reflection.v1alpha'; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("reflection") -> ['grpc.reflection.v1alpha.ServerReflection']; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("reflection") -> [{'grpc.reflection.v1alpha.ServerReflection', 'ServerReflectionInfo'}]; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("reflection") -> []; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.ServerReflectionRequest">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.ExtensionRequest">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.ServiceResponse">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.ServerReflectionResponse">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.ListServiceResponse">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.FileDescriptorResponse">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.ExtensionNumberResponse">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(<<"grpc.reflection.v1alpha.ErrorResponse">>) -> "reflection"; get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). get_proto_by_service_name_as_fqbin(<<"grpc.reflection.v1alpha.ServerReflection">>) -> "reflection"; get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). -spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). get_protos_by_pkg_name_as_fqbin(<<"grpc.reflection.v1alpha">>) -> ["reflection"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). descriptor() -> <<10, 202, 10, 10, 40, 103, 114, 112, 99, 47, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 47, 118, 49, 97, 108, 112, 104, 97, 47, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 112, 114, 111, 116, 111, 18, 23, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 34, 58, 10, 13, 69, 114, 114, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 18, 18, 10, 10, 101, 114, 114, 111, 114, 95, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 21, 10, 13, 101, 114, 114, 111, 114, 95, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 87, 10, 23, 69, 120, 116, 101, 110, 115, 105, 111, 110, 78, 117, 109, 98, 101, 114, 82, 101, 115, 112, 111, 110, 115, 101, 18, 22, 10, 14, 98, 97, 115, 101, 95, 116, 121, 112, 101, 95, 110, 97, 109, 101, 24, 1, 32, 1, 40, 9, 18, 36, 10, 16, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 69, 10, 16, 69, 120, 116, 101, 110, 115, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 18, 23, 10, 15, 99, 111, 110, 116, 97, 105, 110, 105, 110, 103, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 9, 18, 24, 10, 16, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 24, 2, 32, 1, 40, 5, 34, 55, 10, 22, 70, 105, 108, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 18, 29, 10, 21, 102, 105, 108, 101, 95, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 95, 112, 114, 111, 116, 111, 24, 1, 32, 3, 40, 12, 34, 80, 10, 19, 76, 105, 115, 116, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 57, 10, 7, 115, 101, 114, 118, 105, 99, 101, 24, 1, 32, 3, 40, 11, 50, 40, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 34, 138, 2, 10, 23, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 18, 12, 10, 4, 104, 111, 115, 116, 24, 1, 32, 1, 40, 9, 18, 26, 10, 16, 102, 105, 108, 101, 95, 98, 121, 95, 102, 105, 108, 101, 110, 97, 109, 101, 24, 3, 32, 1, 40, 9, 72, 0, 18, 32, 10, 22, 102, 105, 108, 101, 95, 99, 111, 110, 116, 97, 105, 110, 105, 110, 103, 95, 115, 121, 109, 98, 111, 108, 24, 4, 32, 1, 40, 9, 72, 0, 18, 78, 10, 25, 102, 105, 108, 101, 95, 99, 111, 110, 116, 97, 105, 110, 105, 110, 103, 95, 101, 120, 116, 101, 110, 115, 105, 111, 110, 24, 5, 32, 1, 40, 11, 50, 41, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 69, 120, 116, 101, 110, 115, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 72, 0, 18, 39, 10, 29, 97, 108, 108, 95, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 115, 95, 111, 102, 95, 116, 121, 112, 101, 24, 6, 32, 1, 40, 9, 72, 0, 18, 23, 10, 13, 108, 105, 115, 116, 95, 115, 101, 114, 118, 105, 99, 101, 115, 24, 7, 32, 1, 40, 9, 72, 0, 66, 17, 10, 15, 109, 101, 115, 115, 97, 103, 101, 95, 114, 101, 113, 117, 101, 115, 116, 34, 209, 3, 10, 24, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 115, 112, 111, 110, 115, 101, 18, 18, 10, 10, 118, 97, 108, 105, 100, 95, 104, 111, 115, 116, 24, 1, 32, 1, 40, 9, 18, 74, 10, 16, 111, 114, 105, 103, 105, 110, 97, 108, 95, 114, 101, 113, 117, 101, 115, 116, 24, 2, 32, 1, 40, 11, 50, 48, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 18, 83, 10, 24, 102, 105, 108, 101, 95, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 4, 32, 1, 40, 11, 50, 47, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 70, 105, 108, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 18, 90, 10, 30, 97, 108, 108, 95, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 115, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 5, 32, 1, 40, 11, 50, 48, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 69, 120, 116, 101, 110, 115, 105, 111, 110, 78, 117, 109, 98, 101, 114, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 18, 78, 10, 22, 108, 105, 115, 116, 95, 115, 101, 114, 118, 105, 99, 101, 115, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 6, 32, 1, 40, 11, 50, 44, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 76, 105, 115, 116, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 18, 64, 10, 14, 101, 114, 114, 111, 114, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 7, 32, 1, 40, 11, 50, 38, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 69, 114, 114, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 66, 18, 10, 16, 109, 101, 115, 115, 97, 103, 101, 95, 114, 101, 115, 112, 111, 110, 115, 101, 34, 31, 10, 15, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 12, 10, 4, 110, 97, 109, 101, 24, 1, 32, 1, 40, 9, 50, 147, 1, 10, 16, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 18, 127, 10, 20, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 73, 110, 102, 111, 18, 48, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 26, 49, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>. descriptor("reflection") -> <<10, 40, 103, 114, 112, 99, 47, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 47, 118, 49, 97, 108, 112, 104, 97, 47, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 112, 114, 111, 116, 111, 18, 23, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 34, 58, 10, 13, 69, 114, 114, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 18, 18, 10, 10, 101, 114, 114, 111, 114, 95, 99, 111, 100, 101, 24, 1, 32, 1, 40, 5, 18, 21, 10, 13, 101, 114, 114, 111, 114, 95, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 87, 10, 23, 69, 120, 116, 101, 110, 115, 105, 111, 110, 78, 117, 109, 98, 101, 114, 82, 101, 115, 112, 111, 110, 115, 101, 18, 22, 10, 14, 98, 97, 115, 101, 95, 116, 121, 112, 101, 95, 110, 97, 109, 101, 24, 1, 32, 1, 40, 9, 18, 36, 10, 16, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 24, 2, 32, 3, 40, 5, 66, 10, 8, 0, 16, 1, 48, 0, 40, 0, 80, 0, 34, 69, 10, 16, 69, 120, 116, 101, 110, 115, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 18, 23, 10, 15, 99, 111, 110, 116, 97, 105, 110, 105, 110, 103, 95, 116, 121, 112, 101, 24, 1, 32, 1, 40, 9, 18, 24, 10, 16, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 24, 2, 32, 1, 40, 5, 34, 55, 10, 22, 70, 105, 108, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 18, 29, 10, 21, 102, 105, 108, 101, 95, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 95, 112, 114, 111, 116, 111, 24, 1, 32, 3, 40, 12, 34, 80, 10, 19, 76, 105, 115, 116, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 57, 10, 7, 115, 101, 114, 118, 105, 99, 101, 24, 1, 32, 3, 40, 11, 50, 40, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 34, 138, 2, 10, 23, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 18, 12, 10, 4, 104, 111, 115, 116, 24, 1, 32, 1, 40, 9, 18, 26, 10, 16, 102, 105, 108, 101, 95, 98, 121, 95, 102, 105, 108, 101, 110, 97, 109, 101, 24, 3, 32, 1, 40, 9, 72, 0, 18, 32, 10, 22, 102, 105, 108, 101, 95, 99, 111, 110, 116, 97, 105, 110, 105, 110, 103, 95, 115, 121, 109, 98, 111, 108, 24, 4, 32, 1, 40, 9, 72, 0, 18, 78, 10, 25, 102, 105, 108, 101, 95, 99, 111, 110, 116, 97, 105, 110, 105, 110, 103, 95, 101, 120, 116, 101, 110, 115, 105, 111, 110, 24, 5, 32, 1, 40, 11, 50, 41, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 69, 120, 116, 101, 110, 115, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 72, 0, 18, 39, 10, 29, 97, 108, 108, 95, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 115, 95, 111, 102, 95, 116, 121, 112, 101, 24, 6, 32, 1, 40, 9, 72, 0, 18, 23, 10, 13, 108, 105, 115, 116, 95, 115, 101, 114, 118, 105, 99, 101, 115, 24, 7, 32, 1, 40, 9, 72, 0, 66, 17, 10, 15, 109, 101, 115, 115, 97, 103, 101, 95, 114, 101, 113, 117, 101, 115, 116, 34, 209, 3, 10, 24, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 115, 112, 111, 110, 115, 101, 18, 18, 10, 10, 118, 97, 108, 105, 100, 95, 104, 111, 115, 116, 24, 1, 32, 1, 40, 9, 18, 74, 10, 16, 111, 114, 105, 103, 105, 110, 97, 108, 95, 114, 101, 113, 117, 101, 115, 116, 24, 2, 32, 1, 40, 11, 50, 48, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 18, 83, 10, 24, 102, 105, 108, 101, 95, 100, 101, 115, 99, 114, 105, 112, 116, 111, 114, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 4, 32, 1, 40, 11, 50, 47, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 70, 105, 108, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 18, 90, 10, 30, 97, 108, 108, 95, 101, 120, 116, 101, 110, 115, 105, 111, 110, 95, 110, 117, 109, 98, 101, 114, 115, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 5, 32, 1, 40, 11, 50, 48, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 69, 120, 116, 101, 110, 115, 105, 111, 110, 78, 117, 109, 98, 101, 114, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 18, 78, 10, 22, 108, 105, 115, 116, 95, 115, 101, 114, 118, 105, 99, 101, 115, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 6, 32, 1, 40, 11, 50, 44, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 76, 105, 115, 116, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 18, 64, 10, 14, 101, 114, 114, 111, 114, 95, 114, 101, 115, 112, 111, 110, 115, 101, 24, 7, 32, 1, 40, 11, 50, 38, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 69, 114, 114, 111, 114, 82, 101, 115, 112, 111, 110, 115, 101, 72, 0, 66, 18, 10, 16, 109, 101, 115, 115, 97, 103, 101, 95, 114, 101, 115, 112, 111, 110, 115, 101, 34, 31, 10, 15, 83, 101, 114, 118, 105, 99, 101, 82, 101, 115, 112, 111, 110, 115, 101, 18, 12, 10, 4, 110, 97, 109, 101, 24, 1, 32, 1, 40, 9, 50, 147, 1, 10, 16, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 18, 127, 10, 20, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 73, 110, 102, 111, 18, 48, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 113, 117, 101, 115, 116, 26, 49, 46, 103, 114, 112, 99, 46, 114, 101, 102, 108, 101, 99, 116, 105, 111, 110, 46, 118, 49, 97, 108, 112, 104, 97, 46, 83, 101, 114, 118, 101, 114, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 82, 101, 115, 112, 111, 110, 115, 101, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor(X) -> error({gpb_error, {badname, X}}). gpb_version_as_string() -> "4.7.3". gpb_version_as_list() -> [4,7,3]. ================================================ FILE: src/grpcbox_reflection_service.erl ================================================ -module(grpcbox_reflection_service). -export([server_reflection_info/2]). -include("grpcbox.hrl"). -define(UNIMPLEMENTED_RESPONSE, {error_response, #{error_code => 12, error_message => "unimplemented method since extensions removed in proto3"}}). server_reflection_info(Ref, Stream) -> receive {Ref, eos} -> ok; {Ref, Message} -> handle_message(Message, Stream), server_reflection_info(Ref, Stream) end. handle_message(#{message_request := {list_services, _}}=OriginalRequest, Stream) -> Services = list_services(), grpcbox_stream:send(#{original_request => OriginalRequest, message_response => {list_services_response, #{service => Services}}}, Stream); handle_message(#{message_request := {file_by_filename, Filename}}=OriginalRequest, Stream) -> Response = file_by_filename(Filename), grpcbox_stream:send(#{original_request => OriginalRequest, message_response => Response}, Stream); handle_message(#{message_request := {file_containing_symbol, Symbol}}=OriginalRequest, Stream) -> Response = file_containing_symbol(Symbol), grpcbox_stream:send(#{original_request => OriginalRequest, message_response => Response}, Stream); %% proto3 dropped extensions so we'll just return an empty result handle_message(#{message_request := {all_extension_numbers_of_type, _}}=OriginalRequest, Stream) -> grpcbox_stream:send(#{original_request => OriginalRequest, message_response => ?UNIMPLEMENTED_RESPONSE}, Stream); handle_message(#{message_request := {file_containing_extension, _}}=OriginalRequest, Stream) -> grpcbox_stream:send(#{original_request => OriginalRequest, message_response => ?UNIMPLEMENTED_RESPONSE}, Stream). %% list_services() -> ServiceSups = supervisor:which_children(grpcbox_services_simple_sup), lists:usort(lists:flatmap(fun services/1, ServiceSups)). %% Find the name of the services for a service supervisor services({_, Pid, _, _}) -> {registered_name, Name} = erlang:process_info(Pid, registered_name), [#{name => Service} || Service <- ets:select(Name, [{#method{key={'$1', '_'}, _='_'}, [], ['$1']}])]. file_by_filename(Filename) -> FilenameList = binary_to_list(Filename), {file_descriptor_response, #{file_descriptor_proto => [grpcbox_health_pb:descriptor(FilenameList)]}}. file_containing_symbol(Symbol) -> ServiceSups = supervisor:which_children(grpcbox_services_simple_sup), ServicePbModules = lists:usort(lists:flatmap(fun proto_modules/1, ServiceSups)), find(ServicePbModules, Symbol). %% looks up all protobuf modules generated by gpb related to a service supervisor proto_modules({_, Pid, _, _}) -> {registered_name, Name} = erlang:process_info(Pid, registered_name), [Module || Module <- ets:select(Name, [{#method{proto='$1', _='_'}, [], ['$1']}])]. %% check all the fqbin lookup functions for the provided symbol find([], _) -> {error_response, #{error_code => 5, error_message => "symbol not found"}}; find([M | T], Symbol) -> case find_all(fun(F) -> find_symbol(M, F, Symbol) end, [get_proto_by_msg_name_as_fqbin, get_proto_by_service_name_as_fqbin, get_proto_by_enum_name_as_fqbin, get_protos_by_pkg_name_as_fqbin]) of [P | _] -> {file_descriptor_response, #{file_descriptor_proto => [M:descriptor(P)]}}; [] -> find(T, Symbol) end. find_symbol(M, F, Symbol) -> try M:F(Symbol) of Proto -> Proto catch _:_ -> false end. find_all(F, L) -> find_all(F, L, []). find_all(_, [], Acc) -> Acc; find_all(F, [H | T], Acc) -> case F(H) of false -> find_all(F, T, Acc); Proto -> find_all(F, T, [Proto | Acc]) end. ================================================ FILE: src/grpcbox_services_simple_sup.erl ================================================ %%%------------------------------------------------------------------- %% @doc grpcbox services simple one for one supervisor. %% @end %%%------------------------------------------------------------------- -module(grpcbox_services_simple_sup). -behaviour(supervisor). -export([start_link/0, start_child/1, terminate_child/1]). -export([init/1]). -include("grpcbox.hrl"). -define(SERVER, ?MODULE). start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). start_child(Opts) -> GrpcOpts = maps:get(grpc_opts, Opts, #{}), ServerOpts = maps:get(server_opts, Opts, #{}), ListenOpts = maps:get(listen_opts, Opts, #{}), PoolOpts = maps:get(pool_opts, Opts, #{}), TransportOpts = maps:get(transport_opts, Opts, #{}), supervisor:start_child(?SERVER, [ServerOpts, GrpcOpts, ListenOpts, PoolOpts, TransportOpts]). terminate_child(ListenOpts) -> case whereis(grpcbox_services_sup:services_sup_name(ListenOpts)) of undefined -> ok; Pid -> supervisor:terminate_child(?SERVER, Pid) end. init(_Args) -> SupFlags = #{strategy => simple_one_for_one, intensity => 5, period => 10}, ChildSpecs = [#{id => grpcbox_services_sup, start => {grpcbox_services_sup, start_link, []}, type => supervisor, restart => transient, shutdown => 1000}], {ok, {SupFlags, ChildSpecs}}. ================================================ FILE: src/grpcbox_services_sup.erl ================================================ %%%------------------------------------------------------------------- %% @doc grpcbox supervisor for set of services on a port. %% @end %%%------------------------------------------------------------------- -module(grpcbox_services_sup). -behaviour(supervisor). -export([start_link/5, services_sup_name/1, pool_name/1, name/2]). -export([init/1]). -include("grpcbox.hrl"). start_link(ServerOpts, GrpcOpts, ListenOpts, PoolOpts, TransportOpts) -> %% give the services_sup a name because in the future we might want to reference it easily for %% debugging purposes or live configuration changes ServicesSupName = services_sup_name(ListenOpts), supervisor:start_link({local, ServicesSupName}, ?MODULE, [ServerOpts, GrpcOpts, ListenOpts, PoolOpts, TransportOpts, ServicesSupName]). interceptor(Type, Opts) -> case maps:get(Type, Opts, undefined) of {Module, Function} -> fun Module:Function/4; Fun when is_function(Fun, 4) -> Fun; undefined -> undefined end. init([ServerOpts, GrpcOpts, ListenOpts, PoolOpts, TransportOpts, ServiceSupName]) -> Tid = ets:new(ServiceSupName, [protected, named_table, set, {read_concurrency, true}, {keypos, 2}]), ServicePbModules = maps:get(service_protos, GrpcOpts), Services = maps:get(services, GrpcOpts, #{}), load_services(ServicePbModules, Services, Tid), AuthFun = get_authfun(maps:get(ssl, TransportOpts, false), GrpcOpts), UnaryInterceptor = interceptor(unary_interceptor, GrpcOpts), StreamInterceptor = interceptor(stream_interceptor, GrpcOpts), StatsHandler = maps:get(stats_handler, GrpcOpts, undefined), ChatterboxOpts = #{stream_callback_mod => grpcbox_stream, stream_callback_opts => [Tid, AuthFun, UnaryInterceptor, StreamInterceptor, StatsHandler]}, %% unique name for pool based on the ip and port it will listen on Name = pool_name(ListenOpts), RestartStrategy = #{strategy => rest_for_one}, Pool = #{id => grpcbox_pool, start => {grpcbox_pool, start_link, [Name, chatterbox:settings(server, ServerOpts), ChatterboxOpts, TransportOpts]}}, Socket = #{id => grpcbox_socket, start => {grpcbox_socket, start_link, [Name, ListenOpts, PoolOpts]}}, {ok, {RestartStrategy, [Pool, Socket]}}. %% services_sup_name(ListenOpts) -> name("grpcbox_services_sup", ListenOpts). pool_name(ListenOpts) -> name("grpcbox_pool", ListenOpts). name(Prefix, ListenOpts) -> Port = maps:get(port, ListenOpts, 8080), IPAddress = maps:get(ip, ListenOpts, {0, 0, 0, 0}), list_to_atom(Prefix ++ "_" ++ inet_parse:ntoa(IPAddress) ++ "_" ++ integer_to_list(Port)). get_authfun(true, Options) -> case maps:get(auth_fun, Options, undefined) of undefined -> case maps:get(client_cert_dir, Options, undefined) of undefined -> undefined; Dir -> auth_fun(Dir) end; Fun -> Fun end; get_authfun(_, _) -> undefined. -spec auth_fun(Directory::string()) -> fun(((public_key:der_encoded())) -> {true, string()} | false). auth_fun(Directory) -> Ids = issuer_ids_from_directory(Directory), fun(Cert) -> {ok, IssuerID} = public_key:pkix_issuer_id(Cert, self), case maps:find(IssuerID, Ids) of {ok, Identity} -> {true, Identity}; error -> false end end. issuer_ids_from_directory(Dir) -> {ok, Filenames} = file:list_dir(Dir), Keyfiles = lists:filter(fun(N) -> case filename:extension(N) of ".pem" -> true; ".crt" -> true; _ -> false end end, Filenames), maps:from_list([issuer_id_from_file(filename:join([Dir, F])) || F <- Keyfiles]). issuer_id_from_file(Filename) -> {certfile_to_issuer_id(Filename), filename:rootname(filename:basename(Filename))}. certfile_to_issuer_id(Filename) -> {ok, Data} = file:read_file(Filename), [{'Certificate', Cert, not_encrypted}] = public_key:pem_decode(Data), {ok, IssuerID} = public_key:pkix_issuer_id(Cert, self), IssuerID. %% grpc requests are of the form `./` in camelcase. For this reason we %% have gpb keep the service definitions in their original form and convert to snake case here %% to know what module:function to call for each. load_services([], _, _) -> ok; load_services([ServicePbModule | Rest], Services, ServicesTable) -> ServiceNames = ServicePbModule:get_service_names(), [begin {{service, _}, Methods} = ServicePbModule:get_service_def(ServiceName), %% throws exception if ServiceName isn't in the map or doesn't exist try ServiceModule = maps:get(ServiceName, Services), {ServiceModule, ServiceModule:module_info(exports)} of {ServiceModule1, Exports} -> [begin SnakedMethodName = atom_snake_case(Name), case lists:member({SnakedMethodName, 2}, Exports) of true -> ets:insert(ServicesTable, #method{key={atom_to_binary(ServiceName, utf8), atom_to_binary(Name, utf8)}, module=ServiceModule1, function=SnakedMethodName, proto=ServicePbModule, input={Input, InputStream}, output={Output, OutputStream}, opts=Opts}); false -> %% TODO: error? log? insert into ets as unimplemented? unimplemented_method end end || #{name := Name, input := Input, output := Output, input_stream := InputStream, output_stream := OutputStream, opts := Opts} <- Methods] catch _:_ -> %% TODO: error? log? insert into ets as unimplemented? unimplemented_service end end || ServiceName <- ServiceNames], load_services(Rest, Services, ServicesTable). atom_snake_case(Name) -> NameString = atom_to_list(Name), Snaked = lists:foldl(fun(RE, Snaking) -> re:replace(Snaking, RE, "\\1_\\2", [{return, list}, global]) end, NameString, [%% uppercase followed by lowercase "(.)([A-Z][a-z]+)", %% any consecutive digits "(.)([0-9]+)", %% uppercase with lowercase %% or digit before it "([a-z0-9])([A-Z])"]), Snaked1 = string:replace(Snaked, ".", "_", all), Snaked2 = string:replace(Snaked1, "__", "_", all), list_to_atom(string:to_lower(unicode:characters_to_list(Snaked2))). ================================================ FILE: src/grpcbox_socket.erl ================================================ -module(grpcbox_socket). -behaviour(gen_server). -export([start_link/3]). -export([init/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3, terminate/2]). %% public api start_link(Pool, ListenOpts, AcceptorOpts) -> gen_server:start_link(?MODULE, [Pool, ListenOpts, AcceptorOpts], []). %% gen_server api init([Pool, ListenOpts, PoolOpts]) -> Port = maps:get(port, ListenOpts, 8080), IPAddress = maps:get(ip, ListenOpts, {0, 0, 0, 0}), AcceptorPoolSize = maps:get(size, PoolOpts, 10), SocketOpts = maps:get(socket_options, ListenOpts, [{reuseaddr, true}, {nodelay, true}, {reuseaddr, true}, {backlog, 32768}, {keepalive, true}]), %% Trapping exit so can close socket in terminate/2 _ = process_flag(trap_exit, true), Opts = [{active, false}, {mode, binary}, {packet, raw}, {ip, IPAddress} | SocketOpts], {LPort, LOpts} = maybe_adjust_port_opts_for_fdopt(Port, Opts), case gen_tcp:listen(LPort, LOpts) of {ok, Socket} -> %% acceptor could close the socket if there is a problem MRef = monitor(port, Socket), grpcbox_pool:accept_socket(Pool, Socket, AcceptorPoolSize), {ok, {Socket, MRef}}; {error, Reason} -> {stop, Reason} end. maybe_adjust_port_opts_for_fdopt(Port, Opts) -> case lists:keymember(fd, 1, Opts) of true -> %% If an already opened (bound) file descriptor is passed, %% we must not set port or ip, or there will be an error %% when it would have gotten bound again. {0, lists:keydelete(ip, 1, Opts)}; false -> {Port, Opts} end. handle_call(Req, _, State) -> {stop, {bad_call, Req}, State}. handle_cast(Req, State) -> {stop, {bad_cast, Req}, State}. handle_info({'DOWN', MRef, port, Socket, Reason}, {Socket, MRef} = State) -> {stop, Reason, State}; handle_info(_, State) -> {noreply, State}. code_change(_, State, _) -> {ok, State}. terminate(_, {Socket, MRef}) -> %% Socket may already be down but need to ensure it is closed to avoid %% eaddrinuse error on restart case demonitor(MRef, [flush, info]) of true -> gen_tcp:close(Socket); false -> ok end. ================================================ FILE: src/grpcbox_stream.erl ================================================ -module(grpcbox_stream). -include_lib("chatterbox/include/http2.hrl"). -include_lib("kernel/include/logger.hrl"). -include("grpcbox.hrl"). -behaviour(h2_stream). -export([send/2, send/3, send_headers/2, add_headers/2, add_trailers/2, set_trailers/2, code_to_status/1, error/2, ctx/1, ctx/2, handle_streams/2, handle_call/2, handle_info/2]). -export([init/3, on_receive_headers/2, on_send_push_promise/2, on_receive_data/2, on_end_stream/1, terminate/1]). -export_type([t/0, grpc_status/0, grpc_status_message/0, grpc_error/0, grpc_error_response/0, grpc_callback_error/0, grpc_error_data/0, grpc_extended_error_response/0]). -record(state, {handler :: pid(), socket, auth_fun, buffer :: binary(), ctx :: ctx:t() | undefined, services_table :: ets:tid(), req_headers=[] :: list(), full_method :: binary() | undefined, input_ref :: reference() | undefined, callback_pid :: pid() | undefined, connection :: h2_stream_set:stream_set(), request_encoding :: gzip | identity | undefined, response_encoding :: gzip | identity | undefined, content_type :: proto | json | undefined, resp_headers=[] :: list(), resp_trailers=[] :: list(), headers_sent=false :: boolean(), trailers_sent=false :: boolean(), unary_interceptor :: fun() | undefined, stream_interceptor :: fun() | undefined, stream_id :: stream_id(), method :: #method{} | undefined, stats_handler :: module() | undefined, stats :: term() | undefined}). -type t() :: #state{}. -type grpc_status_message() :: unicode:chardata() | undefined. -type grpc_status() :: binary() | undefined. -type http_status() :: integer(). -type grpc_error() :: {unicode:unicode_binary(), % containing a grpc_status() value as text grpc_status_message()}. -type grpc_error_response() :: {error, grpc_error(), #{headers => map(), trailers => #{}}} | {http_error, {http_status(), unicode:chardata()}, #{headers => map(), trailers => #{}}} | {error, term()}. -type grpc_callback_error() :: {error, grpc_error(), #{headers => map(), trailers => #{}}}. -type grpc_error_data() :: #{ status := grpc_status(), message := grpc_status_message(), trailers => map() }. -type grpc_extended_error_response() :: {grpc_extended_error, grpc_error_data()}. init(Conn, StreamId, [Socket, ServicesTable, AuthFun, UnaryInterceptor, StreamInterceptor, StatsHandler]) -> process_flag(trap_exit, true), State = #state{connection=Conn, stream_id=StreamId, services_table=ServicesTable, buffer = <<>>, auth_fun=AuthFun, unary_interceptor=UnaryInterceptor, stream_interceptor=StreamInterceptor, socket=Socket, handler=self(), stats_handler=StatsHandler}, {ok, State}. on_receive_headers(Headers, State=#state{ctx=_Ctx}) -> %% proplists:get_value(<<":method">>, Headers) =:= <<"POST">>, Metadata = grpcbox_utils:headers_to_metadata(Headers), Ctx = case parse_options(<<"grpc-timeout">>, Headers) of infinity -> grpcbox_metadata:new_incoming_ctx(Metadata); D -> Deadline = max(0, erlang:convert_time_unit(D, nanosecond, millisecond)), erlang:start_timer(Deadline, self(), <<"grpc-timeout">>), ctx:with_deadline_after(grpcbox_metadata:new_incoming_ctx(Metadata), D, nanosecond) end, FullPath = proplists:get_value(<<":path">>, Headers), %% wait to rpc_begin here since we need to know the method Ctx1 = ctx:with_value(Ctx, grpc_server_method, FullPath), State1=#state{ctx=Ctx2} = stats_handler(Ctx1, rpc_begin, {}, State#state{full_method=FullPath}), RequestEncoding = parse_options(<<"grpc-encoding">>, Headers), ResponseEncoding = parse_options(<<"grpc-accept-encoding">>, Headers), ContentType = parse_options(<<"content-type">>, Headers), RespHeaders = [{<<":status">>, <<"200">>}, {<<"user-agent">>, <<"grpc-erlang/0.1.0">>}, {<<"content-type">>, content_type(ContentType)} | response_encoding(ResponseEncoding)], handle_service_lookup(Ctx2, string:lexemes(FullPath, "/"), State1#state{resp_headers=RespHeaders, req_headers=Headers, request_encoding=RequestEncoding, response_encoding=ResponseEncoding, content_type=ContentType}). handle_service_lookup(Ctx, [Service, Method], State=#state{services_table=ServicesTable}) -> case ets:lookup(ServicesTable, {Service, Method}) of [M=#method{}] -> State1 = State#state{ctx=Ctx, method=M}, handle_auth(Ctx, State1); _ -> end_stream(?GRPC_STATUS_UNIMPLEMENTED, <<"Method not found on server">>, State) end; handle_service_lookup(_, _, State) -> State1 = State#state{resp_headers=[{<<":status">>, <<"200">>}, {<<"user-agent">>, <<"grpc-erlang/0.1.0">>}]}, end_stream(?GRPC_STATUS_UNIMPLEMENTED, <<"failed parsing path">>, State1), {ok, State1}. handle_auth(_Ctx, State=#state{auth_fun=AuthFun, socket=Socket, method=#method{input={_, InputStreaming}}}) -> case authenticate(sock:peercert(Socket), AuthFun) of {true, _Identity} -> case InputStreaming of true -> Ref = make_ref(), Pid = proc_lib:spawn_link(?MODULE, handle_streams, [Ref, State#state{handler=self()}]), {ok, State#state{input_ref=Ref, callback_pid=Pid}}; _ -> {ok, State} end; _ -> end_stream(?GRPC_STATUS_UNAUTHENTICATED, <<"">>, State) end. authenticate(_, undefined) -> {true, undefined}; authenticate({ok, Cert}, Fun) -> Fun(Cert); authenticate(_, _) -> false. handle_streams(Ref, State=#state{full_method=FullMethod, stream_interceptor=StreamInterceptor, method=#method{module=Module, function=Function, output={_, false}}}) -> case (case StreamInterceptor of undefined -> Module:Function(Ref, State); _ -> ServerInfo = #{full_method => FullMethod, service => Module, input_stream => true, output_stream => false}, StreamInterceptor(Ref, State, ServerInfo, fun Module:Function/2) end) of {ok, Response, State2} -> send(Response, State2); E={grpc_error, _} -> throw(E); E={grpc_extended_error, _} -> throw(E) end; handle_streams(Ref, State=#state{full_method=FullMethod, stream_interceptor=StreamInterceptor, method=#method{module=Module, function=Function, output={_, true}}}) -> case StreamInterceptor of undefined -> Module:Function(Ref, State); _ -> ServerInfo = #{full_method => FullMethod, service => Module, input_stream => true, output_stream => true}, StreamInterceptor(Ref, State, ServerInfo, fun Module:Function/2) end. on_send_push_promise(_, State) -> {ok, State}. ctx_with_stream(Ctx, Stream) -> ctx:set(Ctx, ctx_stream_key, Stream). from_ctx(Ctx) -> ctx:get(Ctx, ctx_stream_key). on_receive_data(_, State=#state{method=undefined}) -> {ok, State}; on_receive_data(Bin, State=#state{request_encoding=Encoding, buffer=Buffer}) -> try {NewBuffer, Messages} = grpcbox_frame:split(<>, Encoding), State1 = lists:foldl(fun(EncodedMessage, StateAcc=#state{}) -> StateAcc1 = handle_message(EncodedMessage, StateAcc), StateAcc1 end, State, Messages), {ok, State1#state{buffer=NewBuffer}} catch throw:{grpc_error, {Status, Message}} -> end_stream(Status, Message, State); throw:{grpc_extended_error, #{status := Status, message := Message} = ErrorData} -> State2 = add_trailers_from_error_data(ErrorData, State), end_stream(Status, Message, State2); C:E:S -> ?LOG_INFO("crash: class=~p exception=~p stacktrace=~p", [C, E, S]), end_stream(?GRPC_STATUS_UNKNOWN, <<>>, State) end. handle_message(EncodedMessage, State=#state{input_ref=Ref, ctx=Ctx, callback_pid=Pid, method=#method{proto=Proto, input={Input, InputStream}, output={_Output, OutputStream}}}) -> try Proto:decode_msg(EncodedMessage, Input) of Message -> State1=#state{ctx=Ctx1} = stats_handler(Ctx, in_payload, #{uncompressed_size => erlang:external_size(Message), compressed_size => size(EncodedMessage)}, State), case {InputStream, OutputStream} of {true, _} -> Pid ! {Ref, Message}, State1; {false, true} -> _ = proc_lib:spawn_link(?MODULE, handle_streams, [Message, State1#state{handler=self()}]), State1; {false, false} -> handle_unary(Ctx1, Message, State1) end catch error:{gpb_error, _} -> ?THROW(?GRPC_STATUS_INTERNAL, <<"Error parsing request protocol buffer">>) end. handle_unary(Ctx, Message, State=#state{unary_interceptor=UnaryInterceptor, full_method=FullMethod, method=#method{module=Module, function=Function, proto=_Proto, input={_Input, _InputStream}, output={_Output, _OutputStream}}}) -> Ctx1 = ctx_with_stream(Ctx, State), case (case UnaryInterceptor of undefined -> Module:Function(Ctx1, Message); _ -> ServerInfo = #{full_method => FullMethod, service => Module}, UnaryInterceptor(Ctx1, Message, ServerInfo, fun Module:Function/2) end) of {ok, Response, Ctx2} -> State1 = from_ctx(Ctx2), send(false, Response, State1); E={grpc_error, _} -> throw(E); E={grpc_extended_error, _} -> throw(E) end. on_end_stream(State) -> on_end_stream_(State). on_end_stream_(State=#state{input_ref=Ref, callback_pid=Pid, method=#method{input={_Input, true}, output={_Output, false}}}) -> Pid ! {Ref, eos}, {ok, State}; on_end_stream_(State=#state{input_ref=Ref, callback_pid=Pid, method=#method{input={_Input, true}, output={_Output, true}}}) -> Pid ! {Ref, eos}, {ok, State}; on_end_stream_(State=#state{input_ref=_Ref, callback_pid=_Pid, method=#method{input={_Input, false}, output={_Output, true}}}) -> {ok, State}; on_end_stream_(State=#state{method=#method{output={_Output, false}}}) -> end_stream(State); on_end_stream_(State) -> end_stream(State). terminate(State) -> on_end_stream(State). %% Internal stats_handler(Ctx, _, _, State=#state{stats_handler=undefined}) -> State#state{ctx=Ctx}; stats_handler(Ctx, Event, Stats, State=#state{stats_handler=StatsHandler, stats=StatsState}) -> {Ctx1, StatsState1} = StatsHandler:handle(Ctx, server, Event, Stats, StatsState), State#state{ctx=Ctx1, stats=StatsState1}. end_stream(State) -> end_stream(?GRPC_STATUS_OK, <<>>, State). end_stream(Status, Message, State=#state{headers_sent=false}) -> end_stream(Status, Message, send_headers(State)); end_stream(_Status, _Message, State=#state{trailers_sent=true}) -> {ok, State}; end_stream(Status, Message, State=#state{connection=Conn, stream_id=StreamId, ctx=Ctx, resp_trailers=Trailers}) -> EncodedTrailers = grpcbox_utils:encode_headers(Trailers), h2_connection:send_trailers(Conn, StreamId, [{<<"grpc-status">>, Status}, {<<"grpc-message">>, Message} | EncodedTrailers], [{send_end_stream, true}]), Ctx1 = ctx:with_value(Ctx, grpc_server_status, grpcbox_utils:status_to_string(Status)), State1 = stats_handler(Ctx1, rpc_end, {}, State), {ok, State1#state{trailers_sent=true}}. set_trailers(Ctx, Trailers) -> State = from_ctx(Ctx), ctx_with_stream(Ctx, State#state{resp_trailers=maps:to_list(Trailers)}). send_headers(State) -> send_headers([], State). send_headers(Ctx, Headers) when is_map(Headers) -> State = from_ctx(Ctx), send_headers(maps:to_list(maybe_encode_headers(Headers)), State); send_headers(_Metadata, State=#state{headers_sent=true}) -> State; send_headers(Metadata, State=#state{connection=Conn, stream_id=StreamId, resp_headers=Headers, headers_sent=false}) -> MdHeaders = grpcbox_utils:encode_headers(Metadata), h2_connection:send_headers(Conn, StreamId, Headers ++ MdHeaders, [{send_end_stream, false}]), State#state{headers_sent=true}. code_to_status(0) -> ?GRPC_STATUS_OK; code_to_status(1) -> ?GRPC_STATUS_CANCELLED; code_to_status(2) -> ?GRPC_STATUS_UNKNOWN; code_to_status(3) -> ?GRPC_STATUS_INVALID_ARGUMENT; code_to_status(4) -> ?GRPC_STATUS_DEADLINE_EXCEEDED; code_to_status(5) -> ?GRPC_STATUS_NOT_FOUND; code_to_status(6) -> ?GRPC_STATUS_ALREADY_EXISTS; code_to_status(7) -> ?GRPC_STATUS_PERMISSION_DENIED; code_to_status(8) -> ?GRPC_STATUS_RESOURCE_EXHAUSTED; code_to_status(9) -> ?GRPC_STATUS_FAILED_PRECONDITION; code_to_status(10) -> ?GRPC_STATUS_ABORTED; code_to_status(11) -> ?GRPC_STATUS_OUT_OF_RANGE; code_to_status(12) -> ?GRPC_STATUS_UNIMPLEMENTED; code_to_status(13) -> ?GRPC_STATUS_INTERNAL; code_to_status(14) -> ?GRPC_STATUS_UNAVAILABLE; code_to_status(15) -> ?GRPC_STATUS_DATA_LOSS; code_to_status(16) -> ?GRPC_STATUS_UNAUTHENTICATED. error(Status, Message) -> exit(?GRPC_ERROR(Status, Message)). ctx(#state{handler=Pid}) -> h2_stream:call(Pid, ctx). ctx(#state{handler=Pid}, Ctx) -> h2_stream:call(Pid, {ctx, Ctx}). handle_call(ctx, State=#state{ctx=Ctx}) -> {ok, Ctx, State}; handle_call({ctx, Ctx}, State) -> {ok, ok, State#state{ctx=Ctx}}. handle_info({add_headers, Headers}, State) -> update_headers(Headers, State); handle_info({add_trailers, Trailers}, State) -> update_trailers(Trailers, State); handle_info({send_proto, Message}, State) -> send(false, Message, State); handle_info({'EXIT', _, normal}, State) -> end_stream(State), State; handle_info({'EXIT', _, {grpc_error, {Status, Message}}}, State) -> end_stream(Status, Message, State), State; handle_info({'EXIT', _, {grpc_extended_error, #{status := Status, message := Message} = ErrorData}}, State) -> State1 = add_trailers_from_error_data(ErrorData, State), end_stream(Status, Message, State1), State1; handle_info({'EXIT', _, _Other}, State) -> end_stream(?GRPC_STATUS_UNKNOWN, <<"process exited without reason">>, State), State; handle_info({timeout,_Ref,<<"grpc-timeout">>}, State) -> end_stream(?GRPC_STATUS_DEADLINE_EXCEEDED, <<"Deadline expired">>, State), State; handle_info(_, State) -> State. add_headers(Headers, #state{handler=Pid}) -> Pid ! {add_headers, Headers}. add_trailers(Ctx, Trailers=#{}) -> State=#state{resp_trailers=RespTrailers} = from_ctx(Ctx), ctx_with_stream(Ctx, State#state{resp_trailers=maps:to_list(Trailers) ++ RespTrailers}); add_trailers(Headers, #state{handler=Pid}) -> Pid ! {add_trailers, Headers}. update_headers(Headers, State=#state{resp_headers=RespHeaders}) -> State#state{resp_headers=RespHeaders ++ Headers}. update_trailers(Trailers, State=#state{resp_trailers=RespTrailers}) -> State#state{resp_trailers=RespTrailers ++ Trailers}. send(Message, #state{handler=Pid}) -> Pid ! {send_proto, Message}. send(End, Message, State=#state{headers_sent=false}) -> State1 = send_headers(State), send(End, Message, State1); send(End, Message, State=#state{ctx=Ctx, connection=Conn, stream_id=StreamId, response_encoding=Encoding, method=#method{proto=Proto, input={_Input, _}, output={Output, _}}}) -> BodyToSend = Proto:encode_msg(Message, Output), OutFrame = grpcbox_frame:encode(Encoding, BodyToSend), ok = h2_connection:send_body(Conn, StreamId, OutFrame, [{send_end_stream, End}]), stats_handler(Ctx, out_payload, #{uncompressed_size => erlang:external_size(Message), compressed_size => size(BodyToSend)}, State). response_encoding(gzip) -> [{<<"grpc-encoding">>, <<"gzip">>}]; response_encoding(snappy) -> [{<<"grpc-encoding">>, <<"snappy">>}]; response_encoding(deflate) -> [{<<"grpc-encoding">>, <<"deflate">>}]; response_encoding(identity) -> [{<<"grpc-encoding">>, <<"identity">>}]. content_type(json) -> <<"application/grpc+json">>; content_type(_) -> <<"application/grpc+proto">>. timeout_to_duration(T, <<"H">>) -> erlang:convert_time_unit(timer:hours(T), millisecond, nanosecond); timeout_to_duration(T, <<"M">>) -> erlang:convert_time_unit(timer:minutes(T), millisecond, nanosecond); timeout_to_duration(T, <<"S">>) -> erlang:convert_time_unit(T, second, nanosecond); timeout_to_duration(T, <<"m">>) -> erlang:convert_time_unit(T, millisecond, nanosecond); timeout_to_duration(T, <<"u">>) -> erlang:convert_time_unit(T, microsecond, nanosecond); timeout_to_duration(T, <<"n">>) -> T. parse_options(<<"grpc-timeout">>, Headers) -> case proplists:get_value(<<"grpc-timeout">>, Headers, infinity) of infinity -> infinity; T -> {I, U} = string:to_integer(T), timeout_to_duration(I, U) end; parse_options(<<"content-type">>, Headers) -> case proplists:get_value(<<"content-type">>, Headers, undefined) of undefined -> proto; <<"application/grpc">> -> proto; <<"application/grpc+proto">> -> proto; <<"application/grpc+json">> -> json; <<"application/grpc+", _>> -> ?THROW(?GRPC_STATUS_UNIMPLEMENTED, <<"unknown content-type">>) end; parse_options(<<"grpc-encoding">>, Headers) -> parse_encoding(<<"grpc-encoding">>, Headers); parse_options(<<"grpc-accept-encoding">>, Headers) -> parse_encoding(<<"grpc-accept-encoding">>, Headers). parse_encoding(EncodingType, Headers) -> case proplists:get_value(EncodingType, Headers, undefined) of undefined -> identity; <<"gzip", _/binary>> -> gzip; <<"snappy", _/binary>> -> snappy; <<"deflate", _/binary>> -> deflate; <<"identity", _/binary>> -> identity; _ -> ?THROW(?GRPC_STATUS_UNIMPLEMENTED, <<"unknown encoding">>) end. maybe_encode_headers(Headers) -> maps:map(fun(K, V) -> maybe_encode_header_value(K, V) end, Headers). maybe_encode_header_value(K, V) -> case binary:longest_common_suffix([K, <<"-bin">>]) == 4 of true -> base64:encode(V); false -> V end. add_trailers_from_error_data(ErrorData, State) -> Trailers = maps:get(trailers, ErrorData, #{}), update_trailers(maps:to_list(Trailers), State). ================================================ FILE: src/grpcbox_subchannel.erl ================================================ -module(grpcbox_subchannel). -behaviour(gen_statem). -export([start_link/5, conn/1, conn/2, stop/2]). -export([init/1, callback_mode/0, terminate/3, %% states ready/3, disconnected/3]). -record(data, {endpoint :: grpcbox_channel:endpoint(), channel :: grpcbox_channel:t(), info :: #{authority := binary(), scheme := binary(), encoding := grpcbox:encoding(), stats_handler := module() | undefined }, conn :: h2_stream_set:stream_set() | undefined, conn_pid :: pid() | undefined, idle_interval :: timer:time()}). start_link(Name, Channel, Endpoint, Encoding, StatsHandler) -> gen_statem:start_link(?MODULE, [Name, Channel, Endpoint, Encoding, StatsHandler], []). conn(Pid) -> conn(Pid, infinity). conn(Pid, Timeout) -> try gen_statem:call(Pid, conn, Timeout) catch exit:{timeout, _} -> {error, timeout} end. stop(Pid, Reason) -> gen_statem:stop(Pid, Reason, infinity). init([Name, Channel, Endpoint, Encoding, StatsHandler]) -> process_flag(trap_exit, true), gproc_pool:connect_worker(Channel, Name), {ok, disconnected, #data{conn=undefined, info=info_map(Endpoint, Encoding, StatsHandler), endpoint=Endpoint, channel=Channel}}. %% In case of unix socket transport %% (defined as tuple {local, _UnixPath} in gen_tcp), %% there is no standard on what the authority field value %% should be, as HTTP/2 over UDS is not formally specified. %% To follow other gRPC implementations' behavior, %% the "localhost" value is used. info_map({Scheme, {local, _UnixPath} = Host, Port, _, _}, Encoding, StatsHandler) -> case {Scheme, Port} of %% The ssl layer is not functional over unix sockets currently, %% and the port is strictly required to be 0 by gen_tcp. {http, 0} -> #{authority => <<"localhost">>, scheme => <<"http">>, encoding => Encoding, stats_handler => StatsHandler}; _ -> error({badarg, [Scheme, Host, Port]}) end; info_map({http, Host, 80, _, _}, Encoding, StatsHandler) -> #{authority => list_to_binary(Host), scheme => <<"http">>, encoding => Encoding, stats_handler => StatsHandler}; info_map({https, Host, 443, _, _}, Encoding, StatsHandler) -> #{authority => list_to_binary(Host), scheme => <<"https">>, encoding => Encoding, stats_handler => StatsHandler}; info_map({Scheme, Host, Port, _, _}, Encoding, StatsHandler) -> #{authority => list_to_binary(Host ++ ":" ++ integer_to_list(Port)), scheme => atom_to_binary(Scheme, utf8), encoding => Encoding, stats_handler => StatsHandler}. callback_mode() -> state_functions. ready({call, From}, conn, #data{conn=Conn, info=Info}) -> {keep_state_and_data, [{reply, From, {ok, Conn, Info}}]}; ready(EventType, EventContent, Data) -> handle_event(EventType, EventContent, Data). disconnected({call, From}, conn, Data) -> connect(Data, From, [postpone]); disconnected(EventType, EventContent, Data) -> handle_event(EventType, EventContent, Data). handle_event({call, From}, info, #data{info=Info}) -> {keep_state_and_data, [{reply, From, Info}]}; handle_event(info, {'EXIT', Pid, _}, Data=#data{conn_pid=Pid}) -> {next_state, disconnected, Data#data{conn=undefined, conn_pid=undefined}}; handle_event(info, {'EXIT', _, econnrefused}, #data{conn=undefined, conn_pid=undefined}) -> keep_state_and_data; handle_event({call, From}, shutdown, _) -> {stop_and_reply, normal, {reply, From, ok}}; handle_event(_, _, _) -> keep_state_and_data. terminate(_Reason, _State, #data{conn=undefined, endpoint=Endpoint, channel=Channel}) -> gproc_pool:disconnect_worker(Channel, Endpoint), gproc_pool:remove_worker(Channel, Endpoint), ok; terminate(normal, _State, #data{conn=Pid, endpoint=Endpoint, channel=Channel}) -> h2_connection:stop(Pid), gproc_pool:disconnect_worker(Channel, Endpoint), gproc_pool:remove_worker(Channel, Endpoint), ok; terminate(Reason, _State, #data{conn_pid=Pid, endpoint=Endpoint, channel=Channel}) -> exit(Pid, Reason), gproc_pool:disconnect_worker(Channel, Endpoint), gproc_pool:remove_worker(Channel, Endpoint), ok. connect(Data=#data{conn=undefined, endpoint={Transport, Host, Port, SSLOptions, ConnectionSettings}}, From, Actions) -> case h2_client:start_link(Transport, Host, Port, options(Transport, SSLOptions), ConnectionSettings#{garbage_on_end => true, stream_callback_mod => grpcbox_client_stream}) of {ok, Conn} -> Pid = h2_stream_set:connection(Conn), {next_state, ready, Data#data{conn=Conn, conn_pid=Pid}, Actions}; {error, _}=Error -> {next_state, disconnected, Data#data{conn=undefined}, [{reply, From, Error}]} end; connect(Data=#data{conn=Conn, conn_pid=Pid}, From, Actions) when is_pid(Pid) -> h2_connection:stop(Conn), connect(Data#data{conn=undefined, conn_pid=undefined}, From, Actions). options(https, Options) -> [{client_preferred_next_protocols, {client, [<<"h2">>]}} | Options]; options(http, Options) -> Options. ================================================ FILE: src/grpcbox_sup.erl ================================================ %%%------------------------------------------------------------------- %% @doc grpcbox top level supervisor. %% @end %%%------------------------------------------------------------------- -module(grpcbox_sup). -behaviour(supervisor). -export([start_link/0]). -export([init/1]). -include("grpcbox.hrl"). -define(SERVER, ?MODULE). start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). init(_Args) -> SupFlags = #{strategy => one_for_one, intensity => 5, period => 10}, ChildSpecs = [#{id => grpcbox_services_simple_sup, start => {grpcbox_services_simple_sup, start_link, []}, type => supervisor, restart => permanent, shutdown => 5000}, #{id => grpcbox_channel_sup, start => {grpcbox_channel_sup, start_link, []}, type => supervisor, restart => permanent, shutdown => 5000}], {ok, {SupFlags, ChildSpecs}}. ================================================ FILE: src/grpcbox_trace.erl ================================================ %% interceptors for opencensus tracing and stats -module(grpcbox_trace). -export([%% server side unary/4, stream/4, %% unary client interceptor unary_client/7, %% client streaminig interceptors new_stream/6, send_msg/3, recv_msg/3]). unary_client(Ctx, _Channel, Handler, FullMethod, Input, _Def, _Options) -> Ctx1 = oc_trace:with_child_span(Ctx, FullMethod, #{}), try Handler(Ctx1, Input) after oc_trace:finish_span(oc_trace:from_ctx(Ctx1)) end. new_stream(Ctx, Channel, Path, Def, Streamer, Options) -> {ok, S} = Streamer(Ctx, Channel, Path, Def, Options), {ok, #{client_stream => S}}. send_msg(#{client_stream := ClientStream}, Streamer, Input) -> Streamer(ClientStream, Input). recv_msg(#{client_stream := ClientStream}, Streamer, Input) -> Streamer(ClientStream, Input). unary(Ctx, Message, _ServerInfo=#{full_method := FullMethod}, Handler) -> Ctx1 = trace_context_from_ctx(Ctx), Ctx2 = oc_trace:with_child_span(Ctx1, FullMethod, #{remote_parent => true}), try Handler(Ctx2, Message) after oc_trace:finish_span(oc_trace:from_ctx(Ctx2)) end. stream(Ref, Stream, _ServerInfo=#{full_method := FullMethod}, Handler) -> Ctx = grpcbox_stream:ctx(Stream), Ctx1 = trace_context_from_ctx(Ctx), Ctx2 = oc_trace:with_child_span(Ctx1, FullMethod, #{remote_parent => true}), try grpcbox_stream:ctx(Stream, Ctx2), Handler(Ref, Stream) after oc_trace:finish_span(oc_trace:from_ctx(Ctx2)) end. %% trace_context_from_ctx(Ctx) -> Metadata = grpcbox_metadata:from_incoming_ctx(Ctx), case maps:get(<<"grpc-trace-bin">>, Metadata, undefined) of undefined -> Ctx; Bin -> try oc_trace:with_span_ctx(Ctx, oc_propagation_binary:decode(Bin)) catch _:_ -> Ctx end end. ================================================ FILE: src/grpcbox_utils.erl ================================================ -module(grpcbox_utils). -export([headers_to_metadata/1, maybe_decode_header/2, decode_header/1, encode_headers/1, is_reserved_header/1, status_to_string/1, get_timeout_from_ctx/2]). -include("grpcbox.hrl"). headers_to_metadata(H) -> lists:foldl(fun({K, V}, Acc) -> case is_reserved_header(K) of true -> Acc; false -> maps:put(K, maybe_decode_header(K, V), Acc) end end, #{}, H). %% TODO: consolidate with grpc_lib. But have to update their header map to support %% a list of values for a key. maybe_decode_header(Key, Value) -> case binary:longest_common_suffix([Key, <<"-bin">>]) == 4 of true -> decode_header(Value); false -> Value end. %% golang gRPC implementation does not add the padding that the Erlang %% decoder needs... decode_header(Base64) when byte_size(Base64) rem 4 == 3 -> base64:decode(<>]) == 4 of true -> [{Key, base64:encode(Value)} | encode_headers(Rest)]; false -> [{Key, Value} | encode_headers(Rest)] end. is_reserved_header(<<"content-type">>) -> true; is_reserved_header(<<"grpc-message-type">>) -> true; is_reserved_header(<<"grpc-encoding">>) -> true; is_reserved_header(<<"grpc-message">>) -> true; is_reserved_header(<<"grpc-status">>) -> true; is_reserved_header(<<"grpc-timeout">>) -> true; is_reserved_header(<<"grpc-status-details-bin">>) -> true; is_reserved_header(<<"te">>) -> true; is_reserved_header(_) -> false. -spec status_to_string(binary()) -> binary(). status_to_string(?GRPC_STATUS_OK) -> <<"OK">>; status_to_string(?GRPC_STATUS_CANCELLED) -> <<"CANCELLED">>; status_to_string(?GRPC_STATUS_UNKNOWN) -> <<"UNKNOWN">>; status_to_string(?GRPC_STATUS_INVALID_ARGUMENT) -> <<"INVALID_ARGUMENT">>; status_to_string(?GRPC_STATUS_DEADLINE_EXCEEDED) -> <<"DEADLINE_EXCEEDED">>; status_to_string(?GRPC_STATUS_NOT_FOUND) -> <<"NOT_FOUND">>; status_to_string(?GRPC_STATUS_ALREADY_EXISTS) -> <<"ALREADY_EXISTS">>; status_to_string(?GRPC_STATUS_PERMISSION_DENIED) -> <<"PERMISSION_DENIED">>; status_to_string(?GRPC_STATUS_RESOURCE_EXHAUSTED) -> <<"RESOURCE_EXHAUSTED">>; status_to_string(?GRPC_STATUS_FAILED_PRECONDITION) -> <<"FAILED_PRECONDITION">>; status_to_string(?GRPC_STATUS_ABORTED) -> <<"ABORTED">>; status_to_string(?GRPC_STATUS_OUT_OF_RANGE) -> <<"OUT_OF_RANGE">>; status_to_string(?GRPC_STATUS_UNIMPLEMENTED) -> <<"UNIMPLEMENTED">>; status_to_string(?GRPC_STATUS_INTERNAL) -> <<"INTERNAL">>; status_to_string(?GRPC_STATUS_UNAVAILABLE) -> <<"UNAVAILABLE">>; status_to_string(?GRPC_STATUS_DATA_LOSS) -> <<"DATA_LOSS">>; status_to_string(?GRPC_STATUS_UNAUTHENTICATED) -> <<"UNAUTHENTICATED">>; status_to_string(Code) -> <<"CODE_", Code/binary>>. get_timeout_from_ctx(Ctx, DefaultTimeout) -> case ctx:deadline(Ctx) of undefined -> DefaultTimeout; infinity -> infinity; {Deadline, _} -> Timeout = erlang:convert_time_unit(Deadline - erlang:monotonic_time(), native, millisecond), case Timeout < 0 of true -> 0; false -> Timeout end end. ================================================ FILE: test/grpcbox_SUITE.erl ================================================ -module(grpcbox_SUITE). -compile(export_all). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). -include_lib("opencensus/include/opencensus.hrl"). -include("grpcbox.hrl"). groups() -> [{ssl, [], [unary_authenticated]}, {tcp, [], [unary_no_auth, multiple_servers, unary_garbage_collect_streams]}, {socket_options, [], [fd_socket_option]}, {concurrent, [{repeat_until_any_fail, 5}], [unary_concurrent]}, {negative_tests, [], [unimplemented, closed_stream, generate_error, streaming_generate_error]}, {negative_ssl, [], [unauthorized]}, {context, [], [%% deadline ]}]. all() -> [{group, ssl}, {group, tcp}, {group, socket_options}, {group, concurrent}, {group, negative_tests}, {group, negative_ssl}, initially_down_service, unary_interceptor, unary_client_interceptor, chain_interceptor, stream_interceptor, bidirectional, client_stream, client_stream_garbage_collect_streams, compression, stats_handler, server_latency_stats, health_service, reflection_service %% TODO: rst stream error handling %% %% trace_interceptor ]. init_per_suite(Config) -> application:load(grpcbox), Config. end_per_suite(_Config) -> ok. init_per_group(ssl, Config) -> ClientCerts = cert_dir(Config), Options = [{certfile, cert(Config, "server1.pem")}, {keyfile, cert(Config, "server1.key")}, {cacertfile, cert(Config, "ca.pem")} ], application:set_env(grpcbox, client, #{channels => [{default_channel, [{https, "localhost", 8080, Options}], #{}}]}), Servers = [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, client_cert_dir => ClientCerts}, transport_opts => #{ssl => true, keyfile => cert(Config, "server1.key"), certfile => cert(Config, "server1.pem"), cacertfile => cert(Config, "ca.pem")}}], application:set_env(grpcbox, servers, Servers), application:ensure_all_started(grpcbox), Config; init_per_group(tcp, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_group(socket_options, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}, transport_opts => #{}}]), Config; init_per_group(concurrent, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_group(negative_tests, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_group(negative_ssl, Config) -> ClientCerts = cert_dir(Config), Options = [{certfile, cert(Config, "server1.pem")}, {keyfile, cert(Config, "server1.key")}, {cacertfile, cert(Config, "ca.pem")}], application:set_env(grpcbox, client, #{channels => [{default_channel, [{https, "localhost", 8080, Options}], #{}}]}), Servers = [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, client_cert_dir => ClientCerts, auth_fun => fun(_) -> false end }, transport_opts => #{ssl => true, keyfile => cert(Config, "server1.key"), certfile => cert(Config, "server1.pem"), cacertfile => cert(Config, "ca.pem")}}], application:set_env(grpcbox, servers, Servers), application:ensure_all_started(grpcbox), Config. end_per_group(_, _Config) -> ?assertMatch(ok, grpcbox_services_simple_sup:terminate_child(#{ip => {0, 0, 0, 0}, port => 8080})), application:stop(grpcbox), ok. init_per_testcase(initially_down_service, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, []), application:ensure_all_started(grpcbox), Config; init_per_testcase(unary_client_interceptor, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{unary_interceptor => fun(Ctx, _Channel, Handler, _Path, _Input, _Def, _Options) -> Handler(Ctx, #{latitude => 30, longitude => 90}) end}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(unary_interceptor, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, unary_interceptor => fun(Ctx, _Req, _, Method) -> Method(Ctx, #{latitude => 30, longitude => 90}) end}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(chain_interceptor, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, unary_interceptor => grpcbox_chain_interceptor:unary([fun ?MODULE:one/4, fun ?MODULE:two/4, fun ?MODULE:three/4])}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(trace_interceptor, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:ensure_all_started(opencensus), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, unary_interceptor => grpcbox_chain_interceptor:unary([fun grpcbox_trace:unary/4, fun ?MODULE:trace_to_trailer/4])}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(stream_interceptor, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, stream_interceptor => fun(Ref, Stream, _ServerInfo, Handler) -> grpcbox_stream:add_trailers([{<<"x-grpc-stream-interceptor">>, <<"true">>}], Stream), Handler(Ref, Stream) end}, transport_opts => #{}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(bidirectional, Config) -> application:load(grpcbox), application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(client_stream, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(client_stream_garbage_collect_streams, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(compression, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(stats_handler, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, stats_handler => test_stats_handler}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(server_latency_stats, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}, stats_handler => grpcbox_oc_stats_handler}}]), {ok, _} = application:ensure_all_started(opencensus), application:ensure_all_started(grpcbox), Config; init_per_testcase(health_service, Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [grpcbox_health_pb], services => #{'grpc.health.v1.Health' => grpcbox_health_service}}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(reflection_service, Config) -> application:load(grpcbox), application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb, grpcbox_reflection_pb, grpcbox_health_pb], services => #{'grpc.reflection.v1alpha.ServerReflection' => grpcbox_reflection_service, 'routeguide.RouteGuide' => routeguide_route_guide, 'grpc.health.v1.Health' => grpcbox_health_service}}}]), application:ensure_all_started(grpcbox), Config; init_per_testcase(_, Config) -> Config. end_per_testcase(unary_interceptor, _Config) -> ?assertMatch(ok, grpcbox_services_simple_sup:terminate_child(#{ip => {0, 0, 0, 0}, port => 8080})), application:stop(grpcbox), ok; end_per_testcase(unary_client_interceptor, _Config) -> ?assertMatch(ok, grpcbox_services_simple_sup:terminate_child(#{ip => {0, 0, 0, 0}, port => 8080})), application:stop(grpcbox), ok; end_per_testcase(chain_interceptor, _Config) -> ?assertMatch(ok, grpcbox_services_simple_sup:terminate_child(#{ip => {0, 0, 0, 0}, port => 8080})), application:stop(grpcbox), ok; end_per_testcase(trace_interceptor, _Config) -> application:stop(opencensus), ?assertMatch(ok, grpcbox_services_simple_sup:terminate_child(#{ip => {0, 0, 0, 0}, port => 8080})), application:stop(grpcbox), ok; end_per_testcase(server_latency_stats, _Config) -> application:stop(opencensus), ?assertMatch(ok, grpcbox_services_simple_sup:terminate_child(#{ip => {0, 0, 0, 0}, port => 8080})), application:stop(grpcbox), ok; end_per_testcase(health_service, _Config) -> ?assertMatch(ok, grpcbox_services_simple_sup:terminate_child(#{ip => {0, 0, 0, 0}, port => 8080})), application:stop(grpcbox), ok; end_per_testcase(unary_authenticated, _Config) -> ok; end_per_testcase(unary_no_auth, _Config) -> ok; end_per_testcase(multiple_servers, _Config) -> ok; end_per_testcase(unary_garbage_collect_streams, _Config) -> ok; end_per_testcase(fd_socket_option, _Config) -> ok; end_per_testcase(unary_concurrent, _Config) -> ok; end_per_testcase(unimplemented, _Config) -> ok; end_per_testcase(unauthorized, _Config) -> ok; end_per_testcase(generate_error, _Config) -> ok; end_per_testcase(streaming_generate_error, _Config) -> ok; end_per_testcase(closed_stream, _Config) -> ok; end_per_testcase(_, _Config) -> application:stop(grpcbox), ok. initially_down_service(_Config) -> Point = #{latitude => 409146138, longitude => -746188906}, Ctx = ctx:with_deadline_after(ctx:new(), 5, second), ?assertMatch({error, econnrefused}, routeguide_route_guide_client:get_feature(Ctx, Point)), grpcbox:start_server(#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}}), {ok, _Feature, _} = routeguide_route_guide_client:get_feature(Ctx, Point). unimplemented(_Config) -> Def = #grpcbox_def{service = 'routeguide.RouteGuide', marshal_fun = fun(I) -> route_guide_pb:encode_msg(I, point) end, unmarshal_fun = fun(I) -> route_guide_pb:encode_msg(I, feature) end}, ?assertMatch({error, {?GRPC_STATUS_UNIMPLEMENTED, _}, #{headers := #{}, trailers := #{}}}, grpcbox_client:unary(ctx:new(), <<"/routeguide.RouteGuide/NotReal">>, #{}, Def, #{})), {ok, S} = grpcbox_client:stream(ctx:new(), <<"/routeguide.RouteGuide/NotReal">>, #{}, Def, #{}), ?assertMatch({error, {?GRPC_STATUS_UNIMPLEMENTED, _}, #{trailers := #{}}}, grpcbox_client:recv_data(S)). unauthorized(_Config) -> Point = #{latitude => 409146138, longitude => -746188906}, Ctx = ctx:new(), {error, {?GRPC_STATUS_UNAUTHENTICATED, _}, #{headers := #{}, trailers := #{}}} = routeguide_route_guide_client:get_feature(Ctx, Point). generate_error(_Config) -> Response = routeguide_route_guide_client:generate_error(#{}), ?assertMatch({error, {?GRPC_STATUS_INTERNAL, <<"error_message">>}, _}, Response), {error, _, #{trailers := Trailers}} = Response, ?assertEqual(<<"error_trailer">>, maps:get(<<"generate_error_trailer">>, Trailers, undefined)). streaming_generate_error(_Config) -> {ok, Stream} = routeguide_route_guide_client:streaming_generate_error(#{}), ?assertMatch({ok, #{<<":status">> := <<"200">>}}, grpcbox_client:recv_headers(Stream)), Response = grpcbox_client:recv_data(Stream), ?assertMatch({error, {?GRPC_STATUS_INTERNAL, <<"error_message">>}, _}, Response), {error, _, #{trailers := Trailers}} = Response, ?assertEqual(<<"error_trailer">>, maps:get(<<"generate_error_trailer">>, Trailers, undefined)). closed_stream(_Config) -> {ok, S} = routeguide_route_guide_client:record_route(ctx:new()), ok = grpcbox_client:send(S, #{latitude => 409146138, longitude => -746188906}), ok = grpcbox_client:send(S, #{latitude => 234818903, longitude => -823423910}), ?assertMatch(ok, grpcbox_client:close_send(S)), %% TODO: should this error? does send need to be a call? %% ?assertMatch(ok, grpcbox_client:send(S, #{latitude => 234818903, longitude => -823423910})), ?assertMatch({ok, #{point_count := 2}}, grpcbox_client:recv_data(S)), ?assertMatch({ok, _}, grpcbox_client:recv_trailers(S)), ?assertMatch(stream_finished, grpcbox_client:recv_data(S)), %% verify you get stream finished also when not having received the trailers {ok, S1} = routeguide_route_guide_client:record_route(ctx:new()), ok = grpcbox_client:send(S1, #{latitude => 409146138, longitude => -746188906}), ok = grpcbox_client:send(S1, #{latitude => 234818903, longitude => -823423910}), ?assertMatch(ok, grpcbox_client:close_send(S1)), ?assertMatch({ok, #{point_count := 2}}, grpcbox_client:recv_data(S1)), ?assertMatch(stream_finished, grpcbox_client:recv_data(S1)). compression(_Config) -> Point = #{latitude => 409146138, longitude => -746188906}, Ctx = ctx:new(), ?assertMatch({error, {unknown_encoding, something}}, routeguide_route_guide_client:get_feature(Ctx, Point, #{encoding => something})), {ok, Feature, _} = routeguide_route_guide_client:get_feature(Point, #{encoding => gzip}), ?assertEqual(#{location => #{latitude => 409146138, longitude => -746188906}, name => <<"Berkshire Valley Management Area Trail, Jefferson, NJ, USA">>}, Feature). health_service(_Config) -> Ctx = ctx:new(), ?assertMatch({ok, #{status := 'SERVING'}, _}, grpcbox_health_client:check(Ctx, #{})), ?assertMatch({ok, #{status := 'UNKNOWN'}, _}, grpcbox_health_client:check(Ctx, #{service => <<"grpc.health.v1.Health">>})), ?assertMatch({ok, #{status := 'UNKNOWN'}, _}, grpcbox_health_client:check(Ctx, #{service => <<"something else">>})). reflection_service(_Config) -> {ok, S} = grpcbox_reflection_client:server_reflection_info(), ok = grpcbox_client:send(S, #{message_request => {list_services, <<>>}}), ?assertMatch({ok, #{message_response := {list_services_response, #{service := [#{name := <<"grpc.health.v1.Health">>}, #{name := <<"grpc.reflection.v1alpha.ServerReflection">>}, #{name := <<"routeguide.RouteGuide">>}]}}}}, grpcbox_client:recv_data(S)), ok = grpcbox_client:send(S, #{message_request => {all_extension_numbers_of_type, <<>>}}), ?assertMatch({ok, #{message_response := {error_response,#{error_code := 12, error_message := <<"unimplemented method since extensions removed in proto3">>}}}}, grpcbox_client:recv_data(S)), ok = grpcbox_client:send(S, #{message_request => {file_containing_extension, #{}}}), ?assertMatch({ok, #{message_response := {error_response,#{error_code := 12, error_message := <<"unimplemented method since extensions removed in proto3">>}}}}, grpcbox_client:recv_data(S)), ok = grpcbox_client:send(S, #{message_request => {file_by_filename, <<"health">>}}), ?assertMatch({ok, #{message_response := {file_descriptor_response, #{file_descriptor_proto := [_]}}}}, grpcbox_client:recv_data(S)), ok = grpcbox_client:send(S, #{message_request => {file_containing_symbol, <<"routeguide.RouteGuide">>}}), ?assertMatch({ok, #{message_response := {file_descriptor_response, #{file_descriptor_proto := [_]}}}}, grpcbox_client:recv_data(S)), ok = grpcbox_client:send(S, #{message_request => {file_containing_symbol, <<"grpc.health.v1.HealthCheckResponse.ServingStatus">>}}), ?assertMatch({ok, #{message_response := {file_descriptor_response, #{file_descriptor_proto := [_]}}}}, grpcbox_client:recv_data(S)), check_stream_state(S), %% closes the stream, waits for an 'end of stream' message and then returns the received data ?assertMatch(ok, grpcbox_client:close_send(S)). stats_handler(_Config) -> register(stats_pid, self()), Point = #{latitude => 409146138, longitude => -746188906}, Ctx = ctx:new(), {ok, Feature, _} = routeguide_route_guide_client:get_feature(Ctx, Point, #{encoding => gzip}), ?assertEqual(#{location => #{latitude => 409146138, longitude => -746188906}, name => <<"Berkshire Valley Management Area Trail, Jefferson, NJ, USA">>}, Feature), F = fun L(Stats) -> receive {rpc_begin, T} -> L(Stats#{rpc_begin => T}); {out_payload, USize, CSize} -> L(Stats#{out_payload => {USize, CSize}}); {in_payload, USize, CSize} -> L(Stats#{in_payload => {USize, CSize}}); {rpc_end, T} -> Stats#{rpc_end => T} after 2000 -> exit(1) end end, Stats = F(#{}), {OutUSize, OutCSize} = maps:get(out_payload, Stats), ?assert(is_integer(OutUSize) andalso is_integer(OutCSize)), {InUSize, InCSize} = maps:get(in_payload, Stats), ?assert(is_integer(InUSize) andalso is_integer(InCSize)), ?assert(maps:get(rpc_end, Stats) > maps:get(rpc_begin, Stats)). -define(server_latency_view(View), {ok, {view, "grpc.io/server/server_latency", _Measure, _, _B, _Help, _M, _Methods, oc_stat_aggregation_distribution, _Buckets} = View}). server_latency_stats(_Config) -> Registered = grpcbox_oc_stats_handler:init(), Subscribed = grpcbox_oc_stats:subscribe_views(), ?assertEqual(ok, Registered), ?assertEqual([], lists:filter(fun ({Ok, _}) -> ok =/= Ok end, Subscribed)), [SrvLatencyView] = [View || ?server_latency_view(View) <- Subscribed], Args = [ctx:new(), #{latitude => 409146138, longitude => -746188906}, #{encoding => gzip}], {MeasuredTime, {ok, Feature, _}} = timer:tc(routeguide_route_guide_client, get_feature, Args), ?assertEqual(#{location => #{latitude => 409146138, longitude => -746188906}, name => <<"Berkshire Valley Management Area Trail, Jefferson, NJ, USA">>}, Feature), #{data := #{rows := [#{value := #{buckets := Bs, count := Count, mean := Mean, sum := Sum}}]}} = oc_stat_view:export(SrvLatencyView), {H, T} = lists:splitwith(fun ({_, C}) -> C =:= 0 end, Bs), ?assert(element(1, lists:last(H)) =< MeasuredTime), %% Bucket size > Reported time ?assertEqual(element(2, hd(T)), Count), %% Count = 1 = In bucket ?assert(element(1, lists:last(H)) =< Sum), %% Lower bucket < Reported time ?assert(Sum =< MeasuredTime), %% Reported time < Measured time ?assert(element(1, hd(T)) > Sum), %% Higher bucket > Reported time ?assertEqual(Mean*Count, Sum), ok. unary_no_auth(_Config) -> unary(_Config). unary_authenticated(Config) -> unary(Config). %% checks that no closed streams are left around after unary requests unary_garbage_collect_streams(Config) -> unary(Config), ConnectionStreamSet = connection_stream_set(), ?assertEqual([], h2_stream_set:my_active_streams(ConnectionStreamSet)). client_stream_garbage_collect_streams(Config) -> client_stream(Config), timer:sleep(100), ConnectionStreamSet = connection_stream_set(), ?assertEqual([], h2_stream_set:my_active_streams(ConnectionStreamSet)). multiple_servers(_Config) -> application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", 8080, []}, {http, "localhost", 8081, []}]}, #{balancer => round_robin}]}), ?assertMatch({ok, _}, grpcbox:start_server(#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}, listen_opts => #{port => 8081}})), unary(_Config), unary(_Config). fd_socket_option(_Config) -> %% Use the fd option to dynamically select a free port {ok, Ip} = inet:getaddr("localhost", inet), {ok, Sock} = gen_tcp:listen(0, [{ip, Ip}, inet]), {ok, Fd} = inet:getfd(Sock), {ok, {_ListenIp, ListenPort}} = inet:sockname(Sock), application:set_env(grpcbox, client, #{channels => [{default_channel, [{http, "localhost", ListenPort, []}], #{}}]}), application:set_env(grpcbox, servers, [#{grpc_opts => #{service_protos => [route_guide_pb], services => #{'routeguide.RouteGuide' => routeguide_route_guide}}, listen_opts => #{socket_options => [{fd, Fd}]}}]), {ok, _} = application:ensure_all_started(grpcbox), unary(_Config), application:stop(grpcbox), gen_tcp:close(Sock). unary_concurrent(Config) -> Nrs = lists:seq(1,100), ParentPid = self(), Pids = [spawn_link(fun() -> unary(Config), ParentPid ! self() end) || _ <- Nrs], unary_concurrent_wait_for_processes(Pids). unary_concurrent_wait_for_processes([]) -> ok; unary_concurrent_wait_for_processes(Pids) -> receive Pid -> NewPids = lists:delete(Pid, Pids), unary_concurrent_wait_for_processes(NewPids) after 5000 -> ?assertMatch([], Pids, "Unary concurrency test timed out without receiving all responses") end. bidirectional(_Config) -> {ok, S} = routeguide_route_guide_client:route_chat(ctx:new()), %% send 2 before receiving since the server only sends what it already had in its list of messages for the %% location of your last send. ok = grpcbox_client:send(S, #{location => #{latitude => 1, longitude => 1}, message => <<"hello there">>}), ok = grpcbox_client:send(S, #{location => #{latitude => 1, longitude => 1}, message => <<"hello there">>}), ?assertMatch({ok, #{message := <<"hello there">>}}, grpcbox_client:recv_data(S)), ok = grpcbox_client:send(S, #{location => #{latitude => 1, longitude => 1}, message => <<"hello there">>}), check_stream_state(S), %% closes the stream, waits for an 'end of stream' message and then returns the received data ?assertMatch(ok, grpcbox_client:close_send(S)). %% TODO: add tests to ensure stream pids are gone and that accidental recvs and such after a close don't hang client_stream(_Config) -> {ok, S} = routeguide_route_guide_client:record_route(ctx:new()), ok = grpcbox_client:send(S, #{latitude => 409146138, longitude => -746188906}), ok = grpcbox_client:send(S, #{latitude => 234818903, longitude => -823423910}), ?assertMatch(ok, grpcbox_client:close_send(S)), ?assertMatch({ok, #{point_count := 2}}, grpcbox_client:recv_data(S)). %% TODO: add tests to ensure stream pids are gone and that accidental recvs and such after a close don't hang unary(_Channel) -> Point = #{latitude => 409146138, longitude => -746188906}, {ok, Feature, _} = routeguide_route_guide_client:get_feature(Point), ?assertEqual(#{location => #{latitude => 409146138, longitude => -746188906}, name => <<"Berkshire Valley Management Area Trail, Jefferson, NJ, USA">>}, Feature). unary_client_interceptor(_Config) -> %% client side interceptor replaces the point with lat 30 and long 90 Point = #{latitude => 409146138, longitude => -746188906}, {ok, Feature, _} = routeguide_route_guide_client:get_feature(Point), ?assertEqual(#{location => #{latitude => 30, longitude => 90}, name => <<"">>}, Feature). unary_interceptor(_Config) -> %% our test interceptor replaces the point with lat 30 and long 90 Point = #{latitude => 409146138, longitude => -746188906}, {ok, Feature, _} = routeguide_route_guide_client:get_feature(Point), ?assertEqual(#{location => #{latitude => 30, longitude => 90}, name => <<"">>}, Feature). chain_interceptor(_Config) -> Point = #{latitude => 409146138, longitude => -746188906}, {ok, _Feature, #{trailers := Trailers}} = routeguide_route_guide_client:get_feature(ctx:background(), Point), ?assertMatch(#{<<"x-grpc-interceptor-one">> := <<"one">>, <<"x-grpc-interceptor-three">> := <<"three">>, <<"x-grpc-interceptor-two">> := <<"two">>}, Trailers). %% include a trace context and test that it works by having a second interceptor add %% the trace id from the context as a response trailer. trace_interceptor(_Config) -> Point = #{latitude => 409146138, longitude => -746188906}, Ctx = oc_trace:with_child_span(ctx:background(), <<"grpc-client-call">>), Context = oc_propagation_binary:encode(oc_trace:from_ctx(Ctx)), Metadata = #{<<"grpc-trace-bin">> => Context}, Ctx1 = grpcbox_metadata:append_to_outgoing_ctx(Ctx, Metadata), {_, _Feature, #{trailers := Trailers}} = routeguide_route_guide_client:get_feature(Ctx1, Point), BinTraceId = integer_to_binary((oc_trace:from_ctx(Ctx))#span_ctx.trace_id), ?assertMatch(BinTraceId, maps:get(<<"x-grpc-trace-id">>, Trailers)). stream_interceptor(_Config) -> {ok, Stream} = routeguide_route_guide_client:list_features(ctx:background(), #{hi => #{latitude => 1, longitude => 2}, lo => #{latitude => 3, longitude => 5}}), ?assertMatch({ok, #{<<":status">> := <<"200">>}}, grpcbox_client:recv_headers(Stream)), ?assertMatch({ok, #{name := <<"Tour Eiffel">>}}, grpcbox_client:recv_data(Stream)), ?assertMatch({ok, #{name := <<"Louvre">>}}, grpcbox_client:recv_data(Stream)), ?assertMatch({ok, {_, _, #{<<"x-grpc-stream-interceptor">> := <<"true">>}}}, grpcbox_client:recv_trailers(Stream)). %% %% verify that the chatterbox stream isn't storing frame data check_stream_state(S) -> {_, StreamState} = sys:get_state(maps:get(stream_pid, S)), FrameQueue = element(7, StreamState), ?assert(queue:is_empty(FrameQueue)). %% return the stream_set of a connection in the channel connection_stream_set() -> {ok, {Channel, _}} = grpcbox_channel:pick(default_channel, unary), {ok, Conn, _} = grpcbox_subchannel:conn(Channel), Conn. cert_dir(Config) -> DataDir = ?config(data_dir, Config), filename:join(DataDir, "certificates"). cert(Config, FileName) -> R = filename:join([cert_dir(Config), FileName]), true = filelib:is_file(R), R. one(Ctx, Message, _ServerInfo, Handler) -> Trailer = grpcbox_metadata:pairs([{<<"x-grpc-interceptor-one">>, <<"one">>}]), Ctx1 = grpcbox_stream:add_trailers(Ctx, Trailer), Handler(Ctx1, Message). two(Ctx, Message, _ServerInfo, Handler) -> Trailer = grpcbox_metadata:pairs([{<<"x-grpc-interceptor-two">>, <<"two">>}]), Ctx1 = grpcbox_stream:add_trailers(Ctx, Trailer), Handler(Ctx1, Message). three(Ctx, Message, _ServerInfo, Handler) -> Trailer = grpcbox_metadata:pairs([{<<"x-grpc-interceptor-three">>, <<"three">>}]), Ctx1 = grpcbox_stream:add_trailers(Ctx, Trailer), Handler(Ctx1, Message). trace_to_trailer(Ctx, Message, _ServerInfo, Handler) -> SpanCtx = oc_trace:from_ctx(Ctx), BinTraceId = integer_to_binary(SpanCtx#span_ctx.trace_id), Trailer = grpcbox_metadata:pairs([{<<"x-grpc-trace-id">>, BinTraceId}]), Ctx1 = grpcbox_stream:add_trailers(Ctx, Trailer), Handler(Ctx1, Message). ================================================ FILE: test/grpcbox_SUITE_data/certificates/ca.pem ================================================ -----BEGIN CERTIFICATE----- MIIDwDCCAqigAwIBAgIUXMlP8/6iUkU3Rem9PhcISuywVVQwDQYJKoZIhvcNAQEL BQAwOzESMBAGA1UEAwwJbG9jYWxob3N0MSUwIwYDVQQuExxSdTFrMUdmbEtyakJ5 cVBMdlNIWlZCaW1ERnc9MB4XDTIzMTEwOTE0MjU1NVoXDTMzMTEwNjE0MjU1NVow OzESMBAGA1UEAwwJbG9jYWxob3N0MSUwIwYDVQQuExxSdTFrMUdmbEtyakJ5cVBM dlNIWlZCaW1ERnc9MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu7UP lnxd9Zz7BtAY/l4JJAOIsbv0dQjepp3GQAzilUDTlVStl8jPLbP69VVFhH/oELyE 3pWA030Hd+xJvJ8P/yMlH+OU48j9dtGLFCkt7DQmr9zedkT8iZjF67yxEC0H9uf6 eIM162U5OdPWANiYn6XLcyKAwHE8D5op1CQo5zJj+UFdqxXi0zGgpAgOKgavqzf6 VSUCB+0VxVAUXrZGyojasYJTHOVFrT3whMv4GrIy2YAxnixZoDrC/rECKVoUNTjX 543VWA78rq/EEmpzHXFjZ/JiDMw6Ijf3QxzsXWCyLR5J/AwbyD6E459Ld4X05o/F TboWA1GCQkbzJnC6dwIDAQABo4G7MIG4MA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O BBYEFEbtZNRn5Sq4wcqjy70h2VQYpgxcMA4GA1UdDwEB/wQEAwIBhjB2BgNVHSME bzBtgBRG7WTUZ+UquMHKo8u9IdlUGKYMXKE/pD0wOzESMBAGA1UEAwwJbG9jYWxo b3N0MSUwIwYDVQQuExxSdTFrMUdmbEtyakJ5cVBMdlNIWlZCaW1ERnc9ghRcyU/z /qJSRTdF6b0+FwhK7LBVVDANBgkqhkiG9w0BAQsFAAOCAQEAro4qY76Pst+Ffmy+ 2jQ3iBPAOVmR6Yb6Ybyxkr5f4aYQ2b2Kf17qe2bKsu1eqqHXMUF1ALfAfgL8tCM3 C4ievxKv8PcekMqp54XF+6ad70sWg4i+MmjbhpCPBNq/7g1W/lG9v3cpCxTEoeC0 +kQIlGyxDOZfaGd+OB/Q9fV1sMcH2pV+4YJE6uvOxkvDIpX5HJa9dTTu8Ozm2k7w wD84j3zlg9TNyW0r62ONbwK+vym1QdjuXos7glxoX7raRkdW/RsIfYqa25m756Sc v+pzjnN8NmzyKK+kkPRQ7ScUFC2lKXryyXX7Als5YFw0nxNZ4Ye1vuUJujJhGMfe qBXAeg== -----END CERTIFICATE----- ================================================ FILE: test/grpcbox_SUITE_data/certificates/server1.key ================================================ -----BEGIN PRIVATE KEY----- MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDLxtcJStNPpCB9 Iv+QwXMTLaErCnjPzC+2K2wgU7EC1sif76q22ZdSHzMaI92h2eusrOnAuWXQNTOo ffIfIMZZvt25aYAZKj+Xad6nrWJ7FSvo5fEChIIcPj8Iq72R0zcnbYhQNzMTedE1 SlBbadmlw1RbN6cDnFgmWvGUrU1ZyEbq2yjONZLE3yyEKLfyhsQAaVqq3cdjhXAM ComPFg+vRoOiXLUidiJtC+8leCkI9V0QnxuLsPA3A/4MMfKxdGMk7vPLremAndXN xuCoDMgNScxUlhQec+W6GXMVZ9WlvZjsTM/AWQq2DkWrNJ+gZJj+Srwvea/LFHB1 QwlWD00hAgMBAAECggEAY/vgLrMEE6OYPU4az0/bwqE03wV4WZz6HAwaNZJa2+W+ 8pqJzMXetXCRhlXqvStLs6Hz35gYGJzCB/4j+pn+OLKp3/uf2rkcEpLjqKouE+5D aTbJlk6l+G2iSALcNNzJxxK7O4CaEwhGWjtoSjIZlHfOwCMCU4c2yTr+JdESjuYR Z6ynCCa6sGEPXVwtFHFUto1S+aWkdd8+1KY5a2Tgpx7xPxcKhLPaPhIPQQ8gHXz0 s+WAPSFpboi/0XKgeqXmyRcpbcKZlPqUh1vtD3/c+wkR5G8xy5G7oMlgE5aS8etk czixy9kBLQEXWQrC4/jk27nniDIKZPn/fiUZkpFMMQKBgQDvDcIrZ9pckydSMqWG VDtJO80H1ynyFly9QZZfK0sqvK2w/P7qn3BLfG4eJEbq6uaiFHbEbzN959quD7Mg G6B7EaSnmBc5YY+K6I9Q1A/TGEo25/npDbkJ5HUsAbEMJl0edYmICvIcFjFhRGc4 qOyIftxqePQKHLB8SCaVFph8owKBgQDaOOPBditLaPBhGRZUOomx7I9BSefBVq7S qxQKqNh1tsOOOiy0msq+f+pcVR2+itzP7psjuYkEgklkqvw2P8vOeu3thQwa1iFK uIDdeF0HVxiCwFI9IZRdZAshHEJXrjOvj2bLelbwGuy/giPkotv0cAcl6ONQWFfA 569TCVZHawKBgBu6qtVCHLA0WZFNUqn8R0w9ZZENQk5UjbleTEUJzpRMgpFPJ3qr t+jprBRO/PLvAIW4ffZXN8/Y/yLFq2+EBN+BsmnGWJtNV8szIryrfJJt9N3dlr2T 2+zr1TOflpvkL1UDKUrgiij74gp4VsjZv2Yt4P9wvE4X+djQvbj5gAKlAoGACvOZ 8oaUq6crkSPqK/X4HRbLJbKoz9oi0e3GBrbsjhPLAqNGxRWToTXYNCQNZxee90x5 OrS//JrxRf0SxUI0XztqH2Zy8hHW/+H8jaDRwmGLmFxAhFLgGEPCDzpU1gOnEmN2 /DU6kbg4M3A7jujhcwYARdXHOqwEU2kNMnSggNsCgYBx6UYAj9z2m2PNtsHOmE4p tdFUzS2ELEkHaEGwLhG359MVVPl3+Sdh1cSmDSeh6DHUWWXPt04lWIrU7BN7Qasj 4kXG1vOy6LM5qpCwrJuVH3Z7LneB4pue0VT+x3Q5QVoSLHYiJJdHAqLoPbqcKfV1 q2png2Z97Dnrt6jMUwRhNA== -----END PRIVATE KEY----- ================================================ FILE: test/grpcbox_SUITE_data/certificates/server1.pem ================================================ -----BEGIN CERTIFICATE----- MIIEIDCCAwigAwIBAgIUE+a3wRyVr9Ou3L5yhlagUfs+eRwwDQYJKoZIhvcNAQEL BQAwOzESMBAGA1UEAwwJbG9jYWxob3N0MSUwIwYDVQQuExxSdTFrMUdmbEtyakJ5 cVBMdlNIWlZCaW1ERnc9MB4XDTIzMTEwOTE0MjYzN1oXDTI2MDIxMTE0MjYzN1ow aTELMAkGA1UEBhMCREUxDzANBgNVBAgMBkJlcmxpbjEPMA0GA1UEBwwGQmVybGlu MREwDwYDVQQKDAhEZXZpbGJveDERMA8GA1UECwwIRGV2aWxib3gxEjAQBgNVBAMM CWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMvG1wlK 00+kIH0i/5DBcxMtoSsKeM/ML7YrbCBTsQLWyJ/vqrbZl1IfMxoj3aHZ66ys6cC5 ZdA1M6h98h8gxlm+3blpgBkqP5dp3qetYnsVK+jl8QKEghw+PwirvZHTNydtiFA3 MxN50TVKUFtp2aXDVFs3pwOcWCZa8ZStTVnIRurbKM41ksTfLIQot/KGxABpWqrd x2OFcAwKiY8WD69Gg6JctSJ2Im0L7yV4KQj1XRCfG4uw8DcD/gwx8rF0YyTu88ut 6YCd1c3G4KgMyA1JzFSWFB5z5boZcxVn1aW9mOxMz8BZCrYORas0n6BkmP5KvC95 r8sUcHVDCVYPTSECAwEAAaOB7TCB6jAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBRp HwRXxTec9ZDHMDmwIarvck470DAOBgNVHQ8BAf8EBAMCBaAwdgYDVR0jBG8wbYAU Ru1k1GflKrjByqPLvSHZVBimDFyhP6Q9MDsxEjAQBgNVBAMMCWxvY2FsaG9zdDEl MCMGA1UELhMcUnUxazFHZmxLcmpCeXFQTHZTSFpWQmltREZ3PYIUXMlP8/6iUkU3 Rem9PhcISuywVVQwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMBQGA1Ud EQQNMAuCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQsFAAOCAQEAro8WsxoPlr5WNNtQ orr7POP01m640UwO2ZFe/QDYug1Eo4foHiqa66OLrAETMtr+2ChAC+7qN763z3E8 t9Lu/Ij4pRnyxeOur6eoyfvMZoIrhY3zWQSTg7aRrY73w/BN3+hXNCpj3TGPvEEV rpwOptOWlZ8LxPHkbjunGQD0+MXlkPHf4faehpDAtFWrcPGt1fbKgVXivBv2woZu uEFTYoPHc+YXZKI2S53pqLCnev2RKhe846gBSiBsGIOSrlVEjVYtMciCdYeME3sH nchs4pH8deqlgHMmQA3H08eaUn0peNDiM7ZVPF4QTgm+egUCyN/NhhmAbzBCBXbN mSww1w== -----END CERTIFICATE----- ================================================ FILE: test/grpcbox_SUITE_data/route_guide.proto ================================================ // Copyright 2015 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. syntax = "proto3"; option java_multiple_files = true; option java_package = "io.grpc.examples.routeguide"; option java_outer_classname = "RouteGuideProto"; package routeguide; // Interface exported by the server. service RouteGuide { // A simple RPC. // // Obtains the feature at a given position. // // A feature with an empty name is returned if there's no feature at the given // position. rpc GetFeature(Point) returns (Feature) {} // A server-to-client streaming RPC. // // Obtains the Features available within the given Rectangle. Results are // streamed rather than returned at once (e.g. in a response message with a // repeated field), as the rectangle may cover a large area and contain a // huge number of features. rpc ListFeatures(Rectangle) returns (stream Feature) {} // A client-to-server streaming RPC. // // Accepts a stream of Points on a route being traversed, returning a // RouteSummary when traversal is completed. rpc RecordRoute(stream Point) returns (RouteSummary) {} // A Bidirectional streaming RPC. // // Accepts a stream of RouteNotes sent while a route is being traversed, // while receiving other RouteNotes (e.g. from other users). rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} // A simple RPC, which always generates error response. rpc GenerateError(Empty) returns (Empty) {} // A simple RPC, which always generates error response. rpc StreamingGenerateError(Empty) returns (stream Empty) {} } // Empty message - use for RPCs without input or output. message Empty { } // Points are represented as latitude-longitude pairs in the E7 representation // (degrees multiplied by 10**7 and rounded to the nearest integer). // Latitudes should be in the range +/- 90 degrees and longitude should be in // the range +/- 180 degrees (inclusive). message Point { int32 latitude = 1; int32 longitude = 2; } // A latitude-longitude rectangle, represented as two diagonally opposite // points "lo" and "hi". message Rectangle { // One corner of the rectangle. Point lo = 1; // The other corner of the rectangle. Point hi = 2; } // A feature names something at a given point. // // If a feature could not be named, the name is empty. message Feature { // The name of the feature. string name = 1; // The point where the feature is detected. Point location = 2; } // A RouteNote is a message sent while at a given point. message RouteNote { // The location from which the message is sent. Point location = 1; // The message to be sent. string message = 2; } // A RouteSummary is received in response to a RecordRoute rpc. // // It contains the number of individual points received, the number of // detected features, and the total distance covered as the cumulative sum of // the distance between each point. message RouteSummary { // The number of points received. int32 point_count = 1; // The number of known features passed while traversing the route. int32 feature_count = 2; // The distance covered in metres. int32 distance = 3; // The duration of the traversal in seconds. int32 elapsed_time = 4; } ================================================ FILE: test/grpcbox_SUITE_data/route_guide_db.json ================================================ [{ "location": { "latitude": 407838351, "longitude": -746143763 }, "name": "Patriots Path, Mendham, NJ 07945, USA" }, { "location": { "latitude": 408122808, "longitude": -743999179 }, "name": "101 New Jersey 10, Whippany, NJ 07981, USA" }, { "location": { "latitude": 413628156, "longitude": -749015468 }, "name": "U.S. 6, Shohola, PA 18458, USA" }, { "location": { "latitude": 419999544, "longitude": -740371136 }, "name": "5 Conners Road, Kingston, NY 12401, USA" }, { "location": { "latitude": 414008389, "longitude": -743951297 }, "name": "Mid Hudson Psychiatric Center, New Hampton, NY 10958, USA" }, { "location": { "latitude": 419611318, "longitude": -746524769 }, "name": "287 Flugertown Road, Livingston Manor, NY 12758, USA" }, { "location": { "latitude": 406109563, "longitude": -742186778 }, "name": "4001 Tremley Point Road, Linden, NJ 07036, USA" }, { "location": { "latitude": 416802456, "longitude": -742370183 }, "name": "352 South Mountain Road, Wallkill, NY 12589, USA" }, { "location": { "latitude": 412950425, "longitude": -741077389 }, "name": "Bailey Turn Road, Harriman, NY 10926, USA" }, { "location": { "latitude": 412144655, "longitude": -743949739 }, "name": "193-199 Wawayanda Road, Hewitt, NJ 07421, USA" }, { "location": { "latitude": 415736605, "longitude": -742847522 }, "name": "406-496 Ward Avenue, Pine Bush, NY 12566, USA" }, { "location": { "latitude": 413843930, "longitude": -740501726 }, "name": "162 Merrill Road, Highland Mills, NY 10930, USA" }, { "location": { "latitude": 410873075, "longitude": -744459023 }, "name": "Clinton Road, West Milford, NJ 07480, USA" }, { "location": { "latitude": 412346009, "longitude": -744026814 }, "name": "16 Old Brook Lane, Warwick, NY 10990, USA" }, { "location": { "latitude": 402948455, "longitude": -747903913 }, "name": "3 Drake Lane, Pennington, NJ 08534, USA" }, { "location": { "latitude": 406337092, "longitude": -740122226 }, "name": "6324 8th Avenue, Brooklyn, NY 11220, USA" }, { "location": { "latitude": 406421967, "longitude": -747727624 }, "name": "1 Merck Access Road, Whitehouse Station, NJ 08889, USA" }, { "location": { "latitude": 416318082, "longitude": -749677716 }, "name": "78-98 Schalck Road, Narrowsburg, NY 12764, USA" }, { "location": { "latitude": 415301720, "longitude": -748416257 }, "name": "282 Lakeview Drive Road, Highland Lake, NY 12743, USA" }, { "location": { "latitude": 402647019, "longitude": -747071791 }, "name": "330 Evelyn Avenue, Hamilton Township, NJ 08619, USA" }, { "location": { "latitude": 412567807, "longitude": -741058078 }, "name": "New York State Reference Route 987E, Southfields, NY 10975, USA" }, { "location": { "latitude": 416855156, "longitude": -744420597 }, "name": "103-271 Tempaloni Road, Ellenville, NY 12428, USA" }, { "location": { "latitude": 404663628, "longitude": -744820157 }, "name": "1300 Airport Road, North Brunswick Township, NJ 08902, USA" }, { "location": { "latitude": 407113723, "longitude": -749746483 }, "name": "" }, { "location": { "latitude": 402133926, "longitude": -743613249 }, "name": "" }, { "location": { "latitude": 400273442, "longitude": -741220915 }, "name": "" }, { "location": { "latitude": 411236786, "longitude": -744070769 }, "name": "" }, { "location": { "latitude": 411633782, "longitude": -746784970 }, "name": "211-225 Plains Road, Augusta, NJ 07822, USA" }, { "location": { "latitude": 415830701, "longitude": -742952812 }, "name": "" }, { "location": { "latitude": 413447164, "longitude": -748712898 }, "name": "165 Pedersen Ridge Road, Milford, PA 18337, USA" }, { "location": { "latitude": 405047245, "longitude": -749800722 }, "name": "100-122 Locktown Road, Frenchtown, NJ 08825, USA" }, { "location": { "latitude": 418858923, "longitude": -746156790 }, "name": "" }, { "location": { "latitude": 417951888, "longitude": -748484944 }, "name": "650-652 Willi Hill Road, Swan Lake, NY 12783, USA" }, { "location": { "latitude": 407033786, "longitude": -743977337 }, "name": "26 East 3rd Street, New Providence, NJ 07974, USA" }, { "location": { "latitude": 417548014, "longitude": -740075041 }, "name": "" }, { "location": { "latitude": 410395868, "longitude": -744972325 }, "name": "" }, { "location": { "latitude": 404615353, "longitude": -745129803 }, "name": "" }, { "location": { "latitude": 406589790, "longitude": -743560121 }, "name": "611 Lawrence Avenue, Westfield, NJ 07090, USA" }, { "location": { "latitude": 414653148, "longitude": -740477477 }, "name": "18 Lannis Avenue, New Windsor, NY 12553, USA" }, { "location": { "latitude": 405957808, "longitude": -743255336 }, "name": "82-104 Amherst Avenue, Colonia, NJ 07067, USA" }, { "location": { "latitude": 411733589, "longitude": -741648093 }, "name": "170 Seven Lakes Drive, Sloatsburg, NY 10974, USA" }, { "location": { "latitude": 412676291, "longitude": -742606606 }, "name": "1270 Lakes Road, Monroe, NY 10950, USA" }, { "location": { "latitude": 409224445, "longitude": -748286738 }, "name": "509-535 Alphano Road, Great Meadows, NJ 07838, USA" }, { "location": { "latitude": 406523420, "longitude": -742135517 }, "name": "652 Garden Street, Elizabeth, NJ 07202, USA" }, { "location": { "latitude": 401827388, "longitude": -740294537 }, "name": "349 Sea Spray Court, Neptune City, NJ 07753, USA" }, { "location": { "latitude": 410564152, "longitude": -743685054 }, "name": "13-17 Stanley Street, West Milford, NJ 07480, USA" }, { "location": { "latitude": 408472324, "longitude": -740726046 }, "name": "47 Industrial Avenue, Teterboro, NJ 07608, USA" }, { "location": { "latitude": 412452168, "longitude": -740214052 }, "name": "5 White Oak Lane, Stony Point, NY 10980, USA" }, { "location": { "latitude": 409146138, "longitude": -746188906 }, "name": "Berkshire Valley Management Area Trail, Jefferson, NJ, USA" }, { "location": { "latitude": 404701380, "longitude": -744781745 }, "name": "1007 Jersey Avenue, New Brunswick, NJ 08901, USA" }, { "location": { "latitude": 409642566, "longitude": -746017679 }, "name": "6 East Emerald Isle Drive, Lake Hopatcong, NJ 07849, USA" }, { "location": { "latitude": 408031728, "longitude": -748645385 }, "name": "1358-1474 New Jersey 57, Port Murray, NJ 07865, USA" }, { "location": { "latitude": 413700272, "longitude": -742135189 }, "name": "367 Prospect Road, Chester, NY 10918, USA" }, { "location": { "latitude": 404310607, "longitude": -740282632 }, "name": "10 Simon Lake Drive, Atlantic Highlands, NJ 07716, USA" }, { "location": { "latitude": 409319800, "longitude": -746201391 }, "name": "11 Ward Street, Mount Arlington, NJ 07856, USA" }, { "location": { "latitude": 406685311, "longitude": -742108603 }, "name": "300-398 Jefferson Avenue, Elizabeth, NJ 07201, USA" }, { "location": { "latitude": 419018117, "longitude": -749142781 }, "name": "43 Dreher Road, Roscoe, NY 12776, USA" }, { "location": { "latitude": 412856162, "longitude": -745148837 }, "name": "Swan Street, Pine Island, NY 10969, USA" }, { "location": { "latitude": 416560744, "longitude": -746721964 }, "name": "66 Pleasantview Avenue, Monticello, NY 12701, USA" }, { "location": { "latitude": 405314270, "longitude": -749836354 }, "name": "" }, { "location": { "latitude": 414219548, "longitude": -743327440 }, "name": "" }, { "location": { "latitude": 415534177, "longitude": -742900616 }, "name": "565 Winding Hills Road, Montgomery, NY 12549, USA" }, { "location": { "latitude": 406898530, "longitude": -749127080 }, "name": "231 Rocky Run Road, Glen Gardner, NJ 08826, USA" }, { "location": { "latitude": 407586880, "longitude": -741670168 }, "name": "100 Mount Pleasant Avenue, Newark, NJ 07104, USA" }, { "location": { "latitude": 400106455, "longitude": -742870190 }, "name": "517-521 Huntington Drive, Manchester Township, NJ 08759, USA" }, { "location": { "latitude": 400066188, "longitude": -746793294 }, "name": "" }, { "location": { "latitude": 418803880, "longitude": -744102673 }, "name": "40 Mountain Road, Napanoch, NY 12458, USA" }, { "location": { "latitude": 414204288, "longitude": -747895140 }, "name": "" }, { "location": { "latitude": 414777405, "longitude": -740615601 }, "name": "" }, { "location": { "latitude": 415464475, "longitude": -747175374 }, "name": "48 North Road, Forestburgh, NY 12777, USA" }, { "location": { "latitude": 404062378, "longitude": -746376177 }, "name": "" }, { "location": { "latitude": 405688272, "longitude": -749285130 }, "name": "" }, { "location": { "latitude": 400342070, "longitude": -748788996 }, "name": "" }, { "location": { "latitude": 401809022, "longitude": -744157964 }, "name": "" }, { "location": { "latitude": 404226644, "longitude": -740517141 }, "name": "9 Thompson Avenue, Leonardo, NJ 07737, USA" }, { "location": { "latitude": 410322033, "longitude": -747871659 }, "name": "" }, { "location": { "latitude": 407100674, "longitude": -747742727 }, "name": "" }, { "location": { "latitude": 418811433, "longitude": -741718005 }, "name": "213 Bush Road, Stone Ridge, NY 12484, USA" }, { "location": { "latitude": 415034302, "longitude": -743850945 }, "name": "" }, { "location": { "latitude": 411349992, "longitude": -743694161 }, "name": "" }, { "location": { "latitude": 404839914, "longitude": -744759616 }, "name": "1-17 Bergen Court, New Brunswick, NJ 08901, USA" }, { "location": { "latitude": 414638017, "longitude": -745957854 }, "name": "35 Oakland Valley Road, Cuddebackville, NY 12729, USA" }, { "location": { "latitude": 412127800, "longitude": -740173578 }, "name": "" }, { "location": { "latitude": 401263460, "longitude": -747964303 }, "name": "" }, { "location": { "latitude": 412843391, "longitude": -749086026 }, "name": "" }, { "location": { "latitude": 418512773, "longitude": -743067823 }, "name": "" }, { "location": { "latitude": 404318328, "longitude": -740835638 }, "name": "42-102 Main Street, Belford, NJ 07718, USA" }, { "location": { "latitude": 419020746, "longitude": -741172328 }, "name": "" }, { "location": { "latitude": 404080723, "longitude": -746119569 }, "name": "" }, { "location": { "latitude": 401012643, "longitude": -744035134 }, "name": "" }, { "location": { "latitude": 404306372, "longitude": -741079661 }, "name": "" }, { "location": { "latitude": 403966326, "longitude": -748519297 }, "name": "" }, { "location": { "latitude": 405002031, "longitude": -748407866 }, "name": "" }, { "location": { "latitude": 409532885, "longitude": -742200683 }, "name": "" }, { "location": { "latitude": 416851321, "longitude": -742674555 }, "name": "" }, { "location": { "latitude": 406411633, "longitude": -741722051 }, "name": "3387 Richmond Terrace, Staten Island, NY 10303, USA" }, { "location": { "latitude": 413069058, "longitude": -744597778 }, "name": "261 Van Sickle Road, Goshen, NY 10924, USA" }, { "location": { "latitude": 418465462, "longitude": -746859398 }, "name": "" }, { "location": { "latitude": 411733222, "longitude": -744228360 }, "name": "" }, { "location": { "latitude": 410248224, "longitude": -747127767 }, "name": "3 Hasta Way, Newton, NJ 07860, USA" }] ================================================ FILE: test/route_guide_pb.erl ================================================ %% -*- coding: utf-8 -*- %% @private %% Automatically generated, do not edit %% Generated by gpb_compile version 4.7.3 -module(route_guide_pb). -export([encode_msg/2, encode_msg/3]). -export([decode_msg/2, decode_msg/3]). -export([merge_msgs/3, merge_msgs/4]). -export([verify_msg/2, verify_msg/3]). -export([get_msg_defs/0]). -export([get_msg_names/0]). -export([get_group_names/0]). -export([get_msg_or_group_names/0]). -export([get_enum_names/0]). -export([find_msg_def/1, fetch_msg_def/1]). -export([find_enum_def/1, fetch_enum_def/1]). -export([enum_symbol_by_value/2, enum_value_by_symbol/2]). -export([get_service_names/0]). -export([get_service_def/1]). -export([get_rpc_names/1]). -export([find_rpc_def/2, fetch_rpc_def/2]). -export([fqbin_to_service_name/1]). -export([service_name_to_fqbin/1]). -export([fqbins_to_service_and_rpc_name/2]). -export([service_and_rpc_name_to_fqbins/2]). -export([fqbin_to_msg_name/1]). -export([msg_name_to_fqbin/1]). -export([fqbin_to_enum_name/1]). -export([enum_name_to_fqbin/1]). -export([get_package_name/0]). -export([uses_packages/0]). -export([source_basename/0]). -export([get_all_source_basenames/0]). -export([get_all_proto_names/0]). -export([get_msg_containment/1]). -export([get_pkg_containment/1]). -export([get_service_containment/1]). -export([get_rpc_containment/1]). -export([get_enum_containment/1]). -export([get_proto_by_msg_name_as_fqbin/1]). -export([get_proto_by_service_name_as_fqbin/1]). -export([get_proto_by_enum_name_as_fqbin/1]). -export([get_protos_by_pkg_name_as_fqbin/1]). -export([descriptor/0, descriptor/1]). -export([gpb_version_as_string/0, gpb_version_as_list/0]). %% enumerated types -export_type([]). %% message types -type empty() :: #{ }. -type point() :: #{latitude => integer(), % = 1, 32 bits longitude => integer() % = 2, 32 bits }. -type rectangle() :: #{lo => point(), % = 1 hi => point() % = 2 }. -type feature() :: #{name => iodata(), % = 1 location => point() % = 2 }. -type route_note() :: #{location => point(), % = 1 message => iodata() % = 2 }. -type route_summary() :: #{point_count => integer(), % = 1, 32 bits feature_count => integer(), % = 2, 32 bits distance => integer(), % = 3, 32 bits elapsed_time => integer() % = 4, 32 bits }. -export_type(['empty'/0, 'point'/0, 'rectangle'/0, 'feature'/0, 'route_note'/0, 'route_summary'/0]). -spec encode_msg(empty() | point() | rectangle() | feature() | route_note() | route_summary(), atom()) -> binary(). encode_msg(Msg, MsgName) when is_atom(MsgName) -> encode_msg(Msg, MsgName, []). -spec encode_msg(empty() | point() | rectangle() | feature() | route_note() | route_summary(), atom(), list()) -> binary(). encode_msg(Msg, MsgName, Opts) -> case proplists:get_bool(verify, Opts) of true -> verify_msg(Msg, MsgName, Opts); false -> ok end, TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> encode_msg_empty(id(Msg, TrUserData), TrUserData); point -> encode_msg_point(id(Msg, TrUserData), TrUserData); rectangle -> encode_msg_rectangle(id(Msg, TrUserData), TrUserData); feature -> encode_msg_feature(id(Msg, TrUserData), TrUserData); route_note -> encode_msg_route_note(id(Msg, TrUserData), TrUserData); route_summary -> encode_msg_route_summary(id(Msg, TrUserData), TrUserData) end. encode_msg_empty(_Msg, _TrUserData) -> <<>>. encode_msg_point(Msg, TrUserData) -> encode_msg_point(Msg, <<>>, TrUserData). encode_msg_point(#{} = M, Bin, TrUserData) -> B1 = case M of #{latitude := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{longitude := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_rectangle(Msg, TrUserData) -> encode_msg_rectangle(Msg, <<>>, TrUserData). encode_msg_rectangle(#{} = M, Bin, TrUserData) -> B1 = case M of #{lo := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_rectangle_lo(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{hi := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= undefined -> B1; true -> e_mfield_rectangle_hi(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_feature(Msg, TrUserData) -> encode_msg_feature(Msg, <<>>, TrUserData). encode_msg_feature(#{} = M, Bin, TrUserData) -> B1 = case M of #{name := F1} -> begin TrF1 = id(F1, TrUserData), case is_empty_string(TrF1) of true -> Bin; false -> e_type_string(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{location := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= undefined -> B1; true -> e_mfield_feature_location(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_route_note(Msg, TrUserData) -> encode_msg_route_note(Msg, <<>>, TrUserData). encode_msg_route_note(#{} = M, Bin, TrUserData) -> B1 = case M of #{location := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= undefined -> Bin; true -> e_mfield_route_note_location(TrF1, <>, TrUserData) end end; _ -> Bin end, case M of #{message := F2} -> begin TrF2 = id(F2, TrUserData), case is_empty_string(TrF2) of true -> B1; false -> e_type_string(TrF2, <>, TrUserData) end end; _ -> B1 end. encode_msg_route_summary(Msg, TrUserData) -> encode_msg_route_summary(Msg, <<>>, TrUserData). encode_msg_route_summary(#{} = M, Bin, TrUserData) -> B1 = case M of #{point_count := F1} -> begin TrF1 = id(F1, TrUserData), if TrF1 =:= 0 -> Bin; true -> e_type_int32(TrF1, <>, TrUserData) end end; _ -> Bin end, B2 = case M of #{feature_count := F2} -> begin TrF2 = id(F2, TrUserData), if TrF2 =:= 0 -> B1; true -> e_type_int32(TrF2, <>, TrUserData) end end; _ -> B1 end, B3 = case M of #{distance := F3} -> begin TrF3 = id(F3, TrUserData), if TrF3 =:= 0 -> B2; true -> e_type_int32(TrF3, <>, TrUserData) end end; _ -> B2 end, case M of #{elapsed_time := F4} -> begin TrF4 = id(F4, TrUserData), if TrF4 =:= 0 -> B3; true -> e_type_int32(TrF4, <>, TrUserData) end end; _ -> B3 end. e_mfield_rectangle_lo(Msg, Bin, TrUserData) -> SubBin = encode_msg_point(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_rectangle_hi(Msg, Bin, TrUserData) -> SubBin = encode_msg_point(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_feature_location(Msg, Bin, TrUserData) -> SubBin = encode_msg_point(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. e_mfield_route_note_location(Msg, Bin, TrUserData) -> SubBin = encode_msg_point(Msg, <<>>, TrUserData), Bin2 = e_varint(byte_size(SubBin), Bin), <>. -compile({nowarn_unused_function,e_type_sint/3}). e_type_sint(Value, Bin, _TrUserData) when Value >= 0 -> e_varint(Value * 2, Bin); e_type_sint(Value, Bin, _TrUserData) -> e_varint(Value * -2 - 1, Bin). -compile({nowarn_unused_function,e_type_int32/3}). e_type_int32(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int32(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_int64/3}). e_type_int64(Value, Bin, _TrUserData) when 0 =< Value, Value =< 127 -> <>; e_type_int64(Value, Bin, _TrUserData) -> <> = <>, e_varint(N, Bin). -compile({nowarn_unused_function,e_type_bool/3}). e_type_bool(true, Bin, _TrUserData) -> <>; e_type_bool(false, Bin, _TrUserData) -> <>; e_type_bool(1, Bin, _TrUserData) -> <>; e_type_bool(0, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_string/3}). e_type_string(S, Bin, _TrUserData) -> Utf8 = unicode:characters_to_binary(S), Bin2 = e_varint(byte_size(Utf8), Bin), <>. -compile({nowarn_unused_function,e_type_bytes/3}). e_type_bytes(Bytes, Bin, _TrUserData) when is_binary(Bytes) -> Bin2 = e_varint(byte_size(Bytes), Bin), <>; e_type_bytes(Bytes, Bin, _TrUserData) when is_list(Bytes) -> BytesBin = iolist_to_binary(Bytes), Bin2 = e_varint(byte_size(BytesBin), Bin), <>. -compile({nowarn_unused_function,e_type_fixed32/3}). e_type_fixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed32/3}). e_type_sfixed32(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_fixed64/3}). e_type_fixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_sfixed64/3}). e_type_sfixed64(Value, Bin, _TrUserData) -> <>. -compile({nowarn_unused_function,e_type_float/3}). e_type_float(V, Bin, _) when is_number(V) -> <>; e_type_float(infinity, Bin, _) -> <>; e_type_float('-infinity', Bin, _) -> <>; e_type_float(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_type_double/3}). e_type_double(V, Bin, _) when is_number(V) -> <>; e_type_double(infinity, Bin, _) -> <>; e_type_double('-infinity', Bin, _) -> <>; e_type_double(nan, Bin, _) -> <>. -compile({nowarn_unused_function,e_varint/3}). e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin). -compile({nowarn_unused_function,e_varint/2}). e_varint(N, Bin) when N =< 127 -> <>; e_varint(N, Bin) -> Bin2 = <>, e_varint(N bsr 7, Bin2). is_empty_string("") -> true; is_empty_string(<<>>) -> true; is_empty_string(L) when is_list(L) -> not string_has_chars(L); is_empty_string(B) when is_binary(B) -> false. string_has_chars([C | _]) when is_integer(C) -> true; string_has_chars([H | T]) -> case string_has_chars(H) of true -> true; false -> string_has_chars(T) end; string_has_chars(B) when is_binary(B), byte_size(B) =/= 0 -> true; string_has_chars(C) when is_integer(C) -> true; string_has_chars(<<>>) -> false; string_has_chars([]) -> false. decode_msg(Bin, MsgName) when is_binary(Bin) -> decode_msg(Bin, MsgName, []). decode_msg(Bin, MsgName, Opts) when is_binary(Bin) -> TrUserData = proplists:get_value(user_data, Opts), decode_msg_1_catch(Bin, MsgName, TrUserData). -ifdef('OTP_RELEASE'). decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -else. decode_msg_1_catch(Bin, MsgName, TrUserData) -> try decode_msg_2_doit(MsgName, Bin, TrUserData) catch Class:Reason -> StackTrace = erlang:get_stacktrace(), error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}}) end. -endif. decode_msg_2_doit(empty, Bin, TrUserData) -> id(decode_msg_empty(Bin, TrUserData), TrUserData); decode_msg_2_doit(point, Bin, TrUserData) -> id(decode_msg_point(Bin, TrUserData), TrUserData); decode_msg_2_doit(rectangle, Bin, TrUserData) -> id(decode_msg_rectangle(Bin, TrUserData), TrUserData); decode_msg_2_doit(feature, Bin, TrUserData) -> id(decode_msg_feature(Bin, TrUserData), TrUserData); decode_msg_2_doit(route_note, Bin, TrUserData) -> id(decode_msg_route_note(Bin, TrUserData), TrUserData); decode_msg_2_doit(route_summary, Bin, TrUserData) -> id(decode_msg_route_summary(Bin, TrUserData), TrUserData). decode_msg_empty(Bin, TrUserData) -> dfp_read_field_def_empty(Bin, 0, 0, TrUserData). dfp_read_field_def_empty(<<>>, 0, 0, _) -> #{}; dfp_read_field_def_empty(Other, Z1, Z2, TrUserData) -> dg_read_field_def_empty(Other, Z1, Z2, TrUserData). dg_read_field_def_empty(<<1:1, X:7, Rest/binary>>, N, Acc, TrUserData) when N < 32 - 7 -> dg_read_field_def_empty(Rest, N + 7, X bsl N + Acc, TrUserData); dg_read_field_def_empty(<<0:1, X:7, Rest/binary>>, N, Acc, TrUserData) -> Key = X bsl N + Acc, case Key band 7 of 0 -> skip_varint_empty(Rest, 0, 0, TrUserData); 1 -> skip_64_empty(Rest, 0, 0, TrUserData); 2 -> skip_length_delimited_empty(Rest, 0, 0, TrUserData); 3 -> skip_group_empty(Rest, Key bsr 3, 0, TrUserData); 5 -> skip_32_empty(Rest, 0, 0, TrUserData) end; dg_read_field_def_empty(<<>>, 0, 0, _) -> #{}. skip_varint_empty(<<1:1, _:7, Rest/binary>>, Z1, Z2, TrUserData) -> skip_varint_empty(Rest, Z1, Z2, TrUserData); skip_varint_empty(<<0:1, _:7, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). skip_length_delimited_empty(<<1:1, X:7, Rest/binary>>, N, Acc, TrUserData) when N < 57 -> skip_length_delimited_empty(Rest, N + 7, X bsl N + Acc, TrUserData); skip_length_delimited_empty(<<0:1, X:7, Rest/binary>>, N, Acc, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_empty(Rest2, 0, 0, TrUserData). skip_group_empty(Bin, FNum, Z2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_empty(Rest, 0, Z2, TrUserData). skip_32_empty(<<_:32, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). skip_64_empty(<<_:64, Rest/binary>>, Z1, Z2, TrUserData) -> dfp_read_field_def_empty(Rest, Z1, Z2, TrUserData). decode_msg_point(Bin, TrUserData) -> dfp_read_field_def_point(Bin, 0, 0, id(0, TrUserData), id(0, TrUserData), TrUserData). dfp_read_field_def_point(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_point_latitude(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_point(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_point_longitude(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_point(<<>>, 0, 0, F@_1, F@_2, _) -> #{latitude => F@_1, longitude => F@_2}; dfp_read_field_def_point(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_point(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_point(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_point(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_point(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_point_latitude(Rest, 0, 0, F@_1, F@_2, TrUserData); 16 -> d_field_point_longitude(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_point(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_point(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_point(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_point(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_point(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_point(<<>>, 0, 0, F@_1, F@_2, _) -> #{latitude => F@_1, longitude => F@_2}. d_field_point_latitude(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_point_latitude(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_point_latitude(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_point(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_point_longitude(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_point_longitude(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_point_longitude(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_point(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_point(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_point(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_point(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_point(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_point(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_point(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_point(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_point(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_point(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_point(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_point(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_point(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_point(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_point(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_rectangle(Bin, TrUserData) -> dfp_read_field_def_rectangle(Bin, 0, 0, id('$undef', TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_rectangle(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_rectangle_lo(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_rectangle(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_rectangle_hi(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_rectangle(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{lo => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{hi => F@_2} end; dfp_read_field_def_rectangle(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_rectangle(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_rectangle(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_rectangle(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_rectangle(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_rectangle_lo(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_rectangle_hi(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_rectangle(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_rectangle(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_rectangle(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_rectangle(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_rectangle(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_rectangle(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{}, S2 = if F@_1 == '$undef' -> S1; true -> S1#{lo => F@_1} end, if F@_2 == '$undef' -> S2; true -> S2#{hi => F@_2} end. d_field_rectangle_lo(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_rectangle_lo(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_rectangle_lo(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_point(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_rectangle(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_point(Prev, NewFValue, TrUserData) end, F@_2, TrUserData). d_field_rectangle_hi(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_rectangle_hi(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_rectangle_hi(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_point(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_rectangle(RestF, 0, 0, F@_1, if Prev == '$undef' -> NewFValue; true -> merge_msg_point(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_rectangle(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_rectangle(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_rectangle(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_rectangle(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_rectangle(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_rectangle(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_rectangle(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_rectangle(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_rectangle(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_rectangle(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_rectangle(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_rectangle(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_rectangle(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_rectangle(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_feature(Bin, TrUserData) -> dfp_read_field_def_feature(Bin, 0, 0, id(<<>>, TrUserData), id('$undef', TrUserData), TrUserData). dfp_read_field_def_feature(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_feature_name(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_feature(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_feature_location(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_feature(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{name => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{location => F@_2} end; dfp_read_field_def_feature(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_feature(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_feature(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_feature(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_feature(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_feature_name(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_feature_location(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_feature(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_feature(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_feature(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_feature(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_feature(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_feature(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{name => F@_1}, if F@_2 == '$undef' -> S1; true -> S1#{location => F@_2} end. d_field_feature_name(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_feature_name(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_feature_name(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_feature(RestF, 0, 0, NewFValue, F@_2, TrUserData). d_field_feature_location(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_feature_location(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_feature_location(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, Prev, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_point(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_feature(RestF, 0, 0, F@_1, if Prev == '$undef' -> NewFValue; true -> merge_msg_point(Prev, NewFValue, TrUserData) end, TrUserData). skip_varint_feature(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_feature(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_feature(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_feature(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_feature(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_feature(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_feature(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_feature(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_feature(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_feature(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_feature(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_feature(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_feature(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_feature(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_route_note(Bin, TrUserData) -> dfp_read_field_def_route_note(Bin, 0, 0, id('$undef', TrUserData), id(<<>>, TrUserData), TrUserData). dfp_read_field_def_route_note(<<10, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_route_note_location(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_route_note(<<18, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> d_field_route_note_message(Rest, Z1, Z2, F@_1, F@_2, TrUserData); dfp_read_field_def_route_note(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{message => F@_2}, if F@_1 == '$undef' -> S1; true -> S1#{location => F@_1} end; dfp_read_field_def_route_note(Other, Z1, Z2, F@_1, F@_2, TrUserData) -> dg_read_field_def_route_note(Other, Z1, Z2, F@_1, F@_2, TrUserData). dg_read_field_def_route_note(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_note(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); dg_read_field_def_route_note(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Key = X bsl N + Acc, case Key of 10 -> d_field_route_note_location(Rest, 0, 0, F@_1, F@_2, TrUserData); 18 -> d_field_route_note_message(Rest, 0, 0, F@_1, F@_2, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_route_note(Rest, 0, 0, F@_1, F@_2, TrUserData); 1 -> skip_64_route_note(Rest, 0, 0, F@_1, F@_2, TrUserData); 2 -> skip_length_delimited_route_note(Rest, 0, 0, F@_1, F@_2, TrUserData); 3 -> skip_group_route_note(Rest, Key bsr 3, 0, F@_1, F@_2, TrUserData); 5 -> skip_32_route_note(Rest, 0, 0, F@_1, F@_2, TrUserData) end end; dg_read_field_def_route_note(<<>>, 0, 0, F@_1, F@_2, _) -> S1 = #{message => F@_2}, if F@_1 == '$undef' -> S1; true -> S1#{location => F@_1} end. d_field_route_note_location(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_note_location(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_route_note_location(<<0:1, X:7, Rest/binary>>, N, Acc, Prev, F@_2, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(decode_msg_point(Bs, TrUserData), TrUserData), Rest2} end, dfp_read_field_def_route_note(RestF, 0, 0, if Prev == '$undef' -> NewFValue; true -> merge_msg_point(Prev, NewFValue, TrUserData) end, F@_2, TrUserData). d_field_route_note_message(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> d_field_route_note_message(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); d_field_route_note_message(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, TrUserData) -> {NewFValue, RestF} = begin Len = X bsl N + Acc, <> = Rest, {id(binary:copy(Bytes), TrUserData), Rest2} end, dfp_read_field_def_route_note(RestF, 0, 0, F@_1, NewFValue, TrUserData). skip_varint_route_note(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> skip_varint_route_note(Rest, Z1, Z2, F@_1, F@_2, TrUserData); skip_varint_route_note(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_note(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_length_delimited_route_note(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) when N < 57 -> skip_length_delimited_route_note(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, TrUserData); skip_length_delimited_route_note(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_route_note(Rest2, 0, 0, F@_1, F@_2, TrUserData). skip_group_route_note(Bin, FNum, Z2, F@_1, F@_2, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_route_note(Rest, 0, Z2, F@_1, F@_2, TrUserData). skip_32_route_note(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_note(Rest, Z1, Z2, F@_1, F@_2, TrUserData). skip_64_route_note(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, TrUserData) -> dfp_read_field_def_route_note(Rest, Z1, Z2, F@_1, F@_2, TrUserData). decode_msg_route_summary(Bin, TrUserData) -> dfp_read_field_def_route_summary(Bin, 0, 0, id(0, TrUserData), id(0, TrUserData), id(0, TrUserData), id(0, TrUserData), TrUserData). dfp_read_field_def_route_summary(<<8, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_route_summary_point_count(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_route_summary(<<16, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_route_summary_feature_count(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_route_summary(<<24, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_route_summary_distance(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_route_summary(<<32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> d_field_route_summary_elapsed_time(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); dfp_read_field_def_route_summary(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, _) -> #{point_count => F@_1, feature_count => F@_2, distance => F@_3, elapsed_time => F@_4}; dfp_read_field_def_route_summary(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dg_read_field_def_route_summary(Other, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). dg_read_field_def_route_summary(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 32 - 7 -> dg_read_field_def_route_summary(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); dg_read_field_def_route_summary(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Key = X bsl N + Acc, case Key of 8 -> d_field_route_summary_point_count(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 16 -> d_field_route_summary_feature_count(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 24 -> d_field_route_summary_distance(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 32 -> d_field_route_summary_elapsed_time(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); _ -> case Key band 7 of 0 -> skip_varint_route_summary(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 1 -> skip_64_route_summary(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 2 -> skip_length_delimited_route_summary(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 3 -> skip_group_route_summary(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3, F@_4, TrUserData); 5 -> skip_32_route_summary(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData) end end; dg_read_field_def_route_summary(<<>>, 0, 0, F@_1, F@_2, F@_3, F@_4, _) -> #{point_count => F@_1, feature_count => F@_2, distance => F@_3, elapsed_time => F@_4}. d_field_route_summary_point_count(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_route_summary_point_count(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_route_summary_point_count(<<0:1, X:7, Rest/binary>>, N, Acc, _, F@_2, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_route_summary(RestF, 0, 0, NewFValue, F@_2, F@_3, F@_4, TrUserData). d_field_route_summary_feature_count(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_route_summary_feature_count(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_route_summary_feature_count(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, _, F@_3, F@_4, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_route_summary(RestF, 0, 0, F@_1, NewFValue, F@_3, F@_4, TrUserData). d_field_route_summary_distance(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_route_summary_distance(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_route_summary_distance(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, _, F@_4, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_route_summary(RestF, 0, 0, F@_1, F@_2, NewFValue, F@_4, TrUserData). d_field_route_summary_elapsed_time(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> d_field_route_summary_elapsed_time(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); d_field_route_summary_elapsed_time(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, _, TrUserData) -> {NewFValue, RestF} = {begin <> = <<(X bsl N + Acc):32/unsigned-native>>, id(Res, TrUserData) end, Rest}, dfp_read_field_def_route_summary(RestF, 0, 0, F@_1, F@_2, F@_3, NewFValue, TrUserData). skip_varint_route_summary(<<1:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> skip_varint_route_summary(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_varint_route_summary(<<0:1, _:7, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_route_summary(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_length_delimited_route_summary(<<1:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) when N < 57 -> skip_length_delimited_route_summary(Rest, N + 7, X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, TrUserData); skip_length_delimited_route_summary(<<0:1, X:7, Rest/binary>>, N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) -> Length = X bsl N + Acc, <<_:Length/binary, Rest2/binary>> = Rest, dfp_read_field_def_route_summary(Rest2, 0, 0, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_group_route_summary(Bin, FNum, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> {_, Rest} = read_group(Bin, FNum), dfp_read_field_def_route_summary(Rest, 0, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_32_route_summary(<<_:32, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_route_summary(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). skip_64_route_summary(<<_:64, Rest/binary>>, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData) -> dfp_read_field_def_route_summary(Rest, Z1, Z2, F@_1, F@_2, F@_3, F@_4, TrUserData). read_group(Bin, FieldNum) -> {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum), <> = Bin, {Group, Rest}. %% Like skipping over fields, but record the total length, %% Each field is <(FieldNum bsl 3) bor FieldType> ++ %% Record the length because varints may be non-optimally encoded. %% %% Groups can be nested, but assume the same FieldNum cannot be nested %% because group field numbers are shared with the rest of the fields %% numbers. Thus we can search just for an group-end with the same %% field number. %% %% (The only time the same group field number could occur would %% be in a nested sub message, but then it would be inside a %% length-delimited entry, which we skip-read by length.) read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) when N < (32-7) -> read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum); read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum) -> Key = X bsl N + Acc, TagLen1 = TagLen + 1, case {Key bsr 3, Key band 7} of {FieldNum, 4} -> % 4 = group_end {NumBytes, TagLen1}; {_, 0} -> % 0 = varint read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum); {_, 1} -> % 1 = bits64 <<_:64, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum); {_, 2} -> % 2 = length_delimited read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum); {_, 3} -> % 3 = group_start read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 4} -> % 4 = group_end read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum); {_, 5} -> % 5 = bits32 <<_:32, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum) end. read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum) when N < (64-7) -> read_gr_vi(Tl, N+7, NumBytes+1, FieldNum); read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) -> read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum). read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) when N < (64-7) -> read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum); read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) -> Len = X bsl N + Acc, NumBytes1 = NumBytes + 1, <<_:Len/binary, Tl2/binary>> = Tl, read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum). merge_msgs(Prev, New, MsgName) when is_atom(MsgName) -> merge_msgs(Prev, New, MsgName, []). merge_msgs(Prev, New, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> merge_msg_empty(Prev, New, TrUserData); point -> merge_msg_point(Prev, New, TrUserData); rectangle -> merge_msg_rectangle(Prev, New, TrUserData); feature -> merge_msg_feature(Prev, New, TrUserData); route_note -> merge_msg_route_note(Prev, New, TrUserData); route_summary -> merge_msg_route_summary(Prev, New, TrUserData) end. -compile({nowarn_unused_function,merge_msg_empty/3}). merge_msg_empty(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,merge_msg_point/3}). merge_msg_point(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{latitude := NFlatitude}} -> S1#{latitude => NFlatitude}; {#{latitude := PFlatitude}, _} -> S1#{latitude => PFlatitude}; _ -> S1 end, case {PMsg, NMsg} of {_, #{longitude := NFlongitude}} -> S2#{longitude => NFlongitude}; {#{longitude := PFlongitude}, _} -> S2#{longitude => PFlongitude}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_rectangle/3}). merge_msg_rectangle(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{lo := PFlo}, #{lo := NFlo}} -> S1#{lo => merge_msg_point(PFlo, NFlo, TrUserData)}; {_, #{lo := NFlo}} -> S1#{lo => NFlo}; {#{lo := PFlo}, _} -> S1#{lo => PFlo}; {_, _} -> S1 end, case {PMsg, NMsg} of {#{hi := PFhi}, #{hi := NFhi}} -> S2#{hi => merge_msg_point(PFhi, NFhi, TrUserData)}; {_, #{hi := NFhi}} -> S2#{hi => NFhi}; {#{hi := PFhi}, _} -> S2#{hi => PFhi}; {_, _} -> S2 end. -compile({nowarn_unused_function,merge_msg_feature/3}). merge_msg_feature(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{name := NFname}} -> S1#{name => NFname}; {#{name := PFname}, _} -> S1#{name => PFname}; _ -> S1 end, case {PMsg, NMsg} of {#{location := PFlocation}, #{location := NFlocation}} -> S2#{location => merge_msg_point(PFlocation, NFlocation, TrUserData)}; {_, #{location := NFlocation}} -> S2#{location => NFlocation}; {#{location := PFlocation}, _} -> S2#{location => PFlocation}; {_, _} -> S2 end. -compile({nowarn_unused_function,merge_msg_route_note/3}). merge_msg_route_note(PMsg, NMsg, TrUserData) -> S1 = #{}, S2 = case {PMsg, NMsg} of {#{location := PFlocation}, #{location := NFlocation}} -> S1#{location => merge_msg_point(PFlocation, NFlocation, TrUserData)}; {_, #{location := NFlocation}} -> S1#{location => NFlocation}; {#{location := PFlocation}, _} -> S1#{location => PFlocation}; {_, _} -> S1 end, case {PMsg, NMsg} of {_, #{message := NFmessage}} -> S2#{message => NFmessage}; {#{message := PFmessage}, _} -> S2#{message => PFmessage}; _ -> S2 end. -compile({nowarn_unused_function,merge_msg_route_summary/3}). merge_msg_route_summary(PMsg, NMsg, _) -> S1 = #{}, S2 = case {PMsg, NMsg} of {_, #{point_count := NFpoint_count}} -> S1#{point_count => NFpoint_count}; {#{point_count := PFpoint_count}, _} -> S1#{point_count => PFpoint_count}; _ -> S1 end, S3 = case {PMsg, NMsg} of {_, #{feature_count := NFfeature_count}} -> S2#{feature_count => NFfeature_count}; {#{feature_count := PFfeature_count}, _} -> S2#{feature_count => PFfeature_count}; _ -> S2 end, S4 = case {PMsg, NMsg} of {_, #{distance := NFdistance}} -> S3#{distance => NFdistance}; {#{distance := PFdistance}, _} -> S3#{distance => PFdistance}; _ -> S3 end, case {PMsg, NMsg} of {_, #{elapsed_time := NFelapsed_time}} -> S4#{elapsed_time => NFelapsed_time}; {#{elapsed_time := PFelapsed_time}, _} -> S4#{elapsed_time => PFelapsed_time}; _ -> S4 end. verify_msg(Msg, MsgName) when is_atom(MsgName) -> verify_msg(Msg, MsgName, []). verify_msg(Msg, MsgName, Opts) -> TrUserData = proplists:get_value(user_data, Opts), case MsgName of empty -> v_msg_empty(Msg, [MsgName], TrUserData); point -> v_msg_point(Msg, [MsgName], TrUserData); rectangle -> v_msg_rectangle(Msg, [MsgName], TrUserData); feature -> v_msg_feature(Msg, [MsgName], TrUserData); route_note -> v_msg_route_note(Msg, [MsgName], TrUserData); route_summary -> v_msg_route_summary(Msg, [MsgName], TrUserData); _ -> mk_type_error(not_a_known_message, Msg, []) end. -compile({nowarn_unused_function,v_msg_empty/3}). -dialyzer({nowarn_function,v_msg_empty/3}). v_msg_empty(#{} = M, Path, _) -> lists:foreach(fun (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_empty(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), empty}, M, Path); v_msg_empty(X, Path, _TrUserData) -> mk_type_error({expected_msg, empty}, X, Path). -compile({nowarn_unused_function,v_msg_point/3}). -dialyzer({nowarn_function,v_msg_point/3}). v_msg_point(#{} = M, Path, TrUserData) -> case M of #{latitude := F1} -> v_type_int32(F1, [latitude | Path], TrUserData); _ -> ok end, case M of #{longitude := F2} -> v_type_int32(F2, [longitude | Path], TrUserData); _ -> ok end, lists:foreach(fun (latitude) -> ok; (longitude) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_point(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), point}, M, Path); v_msg_point(X, Path, _TrUserData) -> mk_type_error({expected_msg, point}, X, Path). -compile({nowarn_unused_function,v_msg_rectangle/3}). -dialyzer({nowarn_function,v_msg_rectangle/3}). v_msg_rectangle(#{} = M, Path, TrUserData) -> case M of #{lo := F1} -> v_msg_point(F1, [lo | Path], TrUserData); _ -> ok end, case M of #{hi := F2} -> v_msg_point(F2, [hi | Path], TrUserData); _ -> ok end, lists:foreach(fun (lo) -> ok; (hi) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_rectangle(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), rectangle}, M, Path); v_msg_rectangle(X, Path, _TrUserData) -> mk_type_error({expected_msg, rectangle}, X, Path). -compile({nowarn_unused_function,v_msg_feature/3}). -dialyzer({nowarn_function,v_msg_feature/3}). v_msg_feature(#{} = M, Path, TrUserData) -> case M of #{name := F1} -> v_type_string(F1, [name | Path], TrUserData); _ -> ok end, case M of #{location := F2} -> v_msg_point(F2, [location | Path], TrUserData); _ -> ok end, lists:foreach(fun (name) -> ok; (location) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_feature(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), feature}, M, Path); v_msg_feature(X, Path, _TrUserData) -> mk_type_error({expected_msg, feature}, X, Path). -compile({nowarn_unused_function,v_msg_route_note/3}). -dialyzer({nowarn_function,v_msg_route_note/3}). v_msg_route_note(#{} = M, Path, TrUserData) -> case M of #{location := F1} -> v_msg_point(F1, [location | Path], TrUserData); _ -> ok end, case M of #{message := F2} -> v_type_string(F2, [message | Path], TrUserData); _ -> ok end, lists:foreach(fun (location) -> ok; (message) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_route_note(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_note}, M, Path); v_msg_route_note(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_note}, X, Path). -compile({nowarn_unused_function,v_msg_route_summary/3}). -dialyzer({nowarn_function,v_msg_route_summary/3}). v_msg_route_summary(#{} = M, Path, TrUserData) -> case M of #{point_count := F1} -> v_type_int32(F1, [point_count | Path], TrUserData); _ -> ok end, case M of #{feature_count := F2} -> v_type_int32(F2, [feature_count | Path], TrUserData); _ -> ok end, case M of #{distance := F3} -> v_type_int32(F3, [distance | Path], TrUserData); _ -> ok end, case M of #{elapsed_time := F4} -> v_type_int32(F4, [elapsed_time | Path], TrUserData); _ -> ok end, lists:foreach(fun (point_count) -> ok; (feature_count) -> ok; (distance) -> ok; (elapsed_time) -> ok; (OtherKey) -> mk_type_error({extraneous_key, OtherKey}, M, Path) end, maps:keys(M)), ok; v_msg_route_summary(M, Path, _TrUserData) when is_map(M) -> mk_type_error({missing_fields, [] -- maps:keys(M), route_summary}, M, Path); v_msg_route_summary(X, Path, _TrUserData) -> mk_type_error({expected_msg, route_summary}, X, Path). -compile({nowarn_unused_function,v_type_int32/3}). -dialyzer({nowarn_function,v_type_int32/3}). v_type_int32(N, _Path, _TrUserData) when -2147483648 =< N, N =< 2147483647 -> ok; v_type_int32(N, Path, _TrUserData) when is_integer(N) -> mk_type_error({value_out_of_range, int32, signed, 32}, N, Path); v_type_int32(X, Path, _TrUserData) -> mk_type_error({bad_integer, int32, signed, 32}, X, Path). -compile({nowarn_unused_function,v_type_string/3}). -dialyzer({nowarn_function,v_type_string/3}). v_type_string(S, Path, _TrUserData) when is_list(S); is_binary(S) -> try unicode:characters_to_binary(S) of B when is_binary(B) -> ok; {error, _, _} -> mk_type_error(bad_unicode_string, S, Path) catch error:badarg -> mk_type_error(bad_unicode_string, S, Path) end; v_type_string(X, Path, _TrUserData) -> mk_type_error(bad_unicode_string, X, Path). -compile({nowarn_unused_function,mk_type_error/3}). -spec mk_type_error(_, _, list()) -> no_return(). mk_type_error(Error, ValueSeen, Path) -> Path2 = prettify_path(Path), erlang:error({gpb_type_error, {Error, [{value, ValueSeen}, {path, Path2}]}}). -compile({nowarn_unused_function,prettify_path/1}). -dialyzer({nowarn_function,prettify_path/1}). prettify_path([]) -> top_level; prettify_path(PathR) -> list_to_atom(lists:append(lists:join(".", lists:map(fun atom_to_list/1, lists:reverse(PathR))))). -compile({nowarn_unused_function,id/2}). -compile({inline,id/2}). id(X, _TrUserData) -> X. -compile({nowarn_unused_function,v_ok/3}). -compile({inline,v_ok/3}). v_ok(_Value, _Path, _TrUserData) -> ok. -compile({nowarn_unused_function,m_overwrite/3}). -compile({inline,m_overwrite/3}). m_overwrite(_Prev, New, _TrUserData) -> New. -compile({nowarn_unused_function,cons/3}). -compile({inline,cons/3}). cons(Elem, Acc, _TrUserData) -> [Elem | Acc]. -compile({nowarn_unused_function,lists_reverse/2}). -compile({inline,lists_reverse/2}). 'lists_reverse'(L, _TrUserData) -> lists:reverse(L). -compile({nowarn_unused_function,'erlang_++'/3}). -compile({inline,'erlang_++'/3}). 'erlang_++'(A, B, _TrUserData) -> A ++ B. get_msg_defs() -> [{{msg, empty}, []}, {{msg, point}, [#{name => latitude, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => longitude, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]}, {{msg, rectangle}, [#{name => lo, fnum => 1, rnum => 2, type => {msg, point}, occurrence => optional, opts => []}, #{name => hi, fnum => 2, rnum => 3, type => {msg, point}, occurrence => optional, opts => []}]}, {{msg, feature}, [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => location, fnum => 2, rnum => 3, type => {msg, point}, occurrence => optional, opts => []}]}, {{msg, route_note}, [#{name => location, fnum => 1, rnum => 2, type => {msg, point}, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]}, {{msg, route_summary}, [#{name => point_count, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => feature_count, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => distance, fnum => 3, rnum => 4, type => int32, occurrence => optional, opts => []}, #{name => elapsed_time, fnum => 4, rnum => 5, type => int32, occurrence => optional, opts => []}]}]. get_msg_names() -> [empty, point, rectangle, feature, route_note, route_summary]. get_group_names() -> []. get_msg_or_group_names() -> [empty, point, rectangle, feature, route_note, route_summary]. get_enum_names() -> []. fetch_msg_def(MsgName) -> case find_msg_def(MsgName) of Fs when is_list(Fs) -> Fs; error -> erlang:error({no_such_msg, MsgName}) end. -spec fetch_enum_def(_) -> no_return(). fetch_enum_def(EnumName) -> erlang:error({no_such_enum, EnumName}). find_msg_def(empty) -> []; find_msg_def(point) -> [#{name => latitude, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => longitude, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}]; find_msg_def(rectangle) -> [#{name => lo, fnum => 1, rnum => 2, type => {msg, point}, occurrence => optional, opts => []}, #{name => hi, fnum => 2, rnum => 3, type => {msg, point}, occurrence => optional, opts => []}]; find_msg_def(feature) -> [#{name => name, fnum => 1, rnum => 2, type => string, occurrence => optional, opts => []}, #{name => location, fnum => 2, rnum => 3, type => {msg, point}, occurrence => optional, opts => []}]; find_msg_def(route_note) -> [#{name => location, fnum => 1, rnum => 2, type => {msg, point}, occurrence => optional, opts => []}, #{name => message, fnum => 2, rnum => 3, type => string, occurrence => optional, opts => []}]; find_msg_def(route_summary) -> [#{name => point_count, fnum => 1, rnum => 2, type => int32, occurrence => optional, opts => []}, #{name => feature_count, fnum => 2, rnum => 3, type => int32, occurrence => optional, opts => []}, #{name => distance, fnum => 3, rnum => 4, type => int32, occurrence => optional, opts => []}, #{name => elapsed_time, fnum => 4, rnum => 5, type => int32, occurrence => optional, opts => []}]; find_msg_def(_) -> error. find_enum_def(_) -> error. -spec enum_symbol_by_value(_, _) -> no_return(). enum_symbol_by_value(E, V) -> erlang:error({no_enum_defs, E, V}). -spec enum_value_by_symbol(_, _) -> no_return(). enum_value_by_symbol(E, V) -> erlang:error({no_enum_defs, E, V}). get_service_names() -> ['routeguide.RouteGuide']. get_service_def('routeguide.RouteGuide') -> {{service, 'routeguide.RouteGuide'}, [#{name => 'GetFeature', input => point, output => feature, input_stream => false, output_stream => false, opts => []}, #{name => 'ListFeatures', input => rectangle, output => feature, input_stream => false, output_stream => true, opts => []}, #{name => 'RecordRoute', input => point, output => route_summary, input_stream => true, output_stream => false, opts => []}, #{name => 'RouteChat', input => route_note, output => route_note, input_stream => true, output_stream => true, opts => []}, #{name => 'GenerateError', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}, #{name => 'StreamingGenerateError', input => empty, output => empty, input_stream => false, output_stream => true, opts => []}]}; get_service_def(_) -> error. get_rpc_names('routeguide.RouteGuide') -> ['GetFeature', 'ListFeatures', 'RecordRoute', 'RouteChat', 'GenerateError', 'StreamingGenerateError']; get_rpc_names(_) -> error. find_rpc_def('routeguide.RouteGuide', RpcName) -> 'find_rpc_def_routeguide.RouteGuide'(RpcName); find_rpc_def(_, _) -> error. 'find_rpc_def_routeguide.RouteGuide'('GetFeature') -> #{name => 'GetFeature', input => point, output => feature, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_routeguide.RouteGuide'('ListFeatures') -> #{name => 'ListFeatures', input => rectangle, output => feature, input_stream => false, output_stream => true, opts => []}; 'find_rpc_def_routeguide.RouteGuide'('RecordRoute') -> #{name => 'RecordRoute', input => point, output => route_summary, input_stream => true, output_stream => false, opts => []}; 'find_rpc_def_routeguide.RouteGuide'('RouteChat') -> #{name => 'RouteChat', input => route_note, output => route_note, input_stream => true, output_stream => true, opts => []}; 'find_rpc_def_routeguide.RouteGuide'('GenerateError') -> #{name => 'GenerateError', input => empty, output => empty, input_stream => false, output_stream => false, opts => []}; 'find_rpc_def_routeguide.RouteGuide'('StreamingGenerateError') -> #{name => 'StreamingGenerateError', input => empty, output => empty, input_stream => false, output_stream => true, opts => []}; 'find_rpc_def_routeguide.RouteGuide'(_) -> error. fetch_rpc_def(ServiceName, RpcName) -> case find_rpc_def(ServiceName, RpcName) of Def when is_map(Def) -> Def; error -> erlang:error({no_such_rpc, ServiceName, RpcName}) end. %% Convert a a fully qualified (ie with package name) service name %% as a binary to a service name as an atom. fqbin_to_service_name(<<"routeguide.RouteGuide">>) -> 'routeguide.RouteGuide'; fqbin_to_service_name(X) -> error({gpb_error, {badservice, X}}). %% Convert a service name as an atom to a fully qualified %% (ie with package name) name as a binary. service_name_to_fqbin('routeguide.RouteGuide') -> <<"routeguide.RouteGuide">>; service_name_to_fqbin(X) -> error({gpb_error, {badservice, X}}). %% Convert a a fully qualified (ie with package name) service name %% and an rpc name, both as binaries to a service name and an rpc %% name, as atoms. fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"GetFeature">>) -> {'routeguide.RouteGuide', 'GetFeature'}; fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"ListFeatures">>) -> {'routeguide.RouteGuide', 'ListFeatures'}; fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"RecordRoute">>) -> {'routeguide.RouteGuide', 'RecordRoute'}; fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"RouteChat">>) -> {'routeguide.RouteGuide', 'RouteChat'}; fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"GenerateError">>) -> {'routeguide.RouteGuide', 'GenerateError'}; fqbins_to_service_and_rpc_name(<<"routeguide.RouteGuide">>, <<"StreamingGenerateError">>) -> {'routeguide.RouteGuide', 'StreamingGenerateError'}; fqbins_to_service_and_rpc_name(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). %% Convert a service name and an rpc name, both as atoms, %% to a fully qualified (ie with package name) service name and %% an rpc name as binaries. service_and_rpc_name_to_fqbins('routeguide.RouteGuide', 'GetFeature') -> {<<"routeguide.RouteGuide">>, <<"GetFeature">>}; service_and_rpc_name_to_fqbins('routeguide.RouteGuide', 'ListFeatures') -> {<<"routeguide.RouteGuide">>, <<"ListFeatures">>}; service_and_rpc_name_to_fqbins('routeguide.RouteGuide', 'RecordRoute') -> {<<"routeguide.RouteGuide">>, <<"RecordRoute">>}; service_and_rpc_name_to_fqbins('routeguide.RouteGuide', 'RouteChat') -> {<<"routeguide.RouteGuide">>, <<"RouteChat">>}; service_and_rpc_name_to_fqbins('routeguide.RouteGuide', 'GenerateError') -> {<<"routeguide.RouteGuide">>, <<"GenerateError">>}; service_and_rpc_name_to_fqbins('routeguide.RouteGuide', 'StreamingGenerateError') -> {<<"routeguide.RouteGuide">>, <<"StreamingGenerateError">>}; service_and_rpc_name_to_fqbins(S, R) -> error({gpb_error, {badservice_or_rpc, {S, R}}}). fqbin_to_msg_name(<<"routeguide.Empty">>) -> empty; fqbin_to_msg_name(<<"routeguide.Point">>) -> point; fqbin_to_msg_name(<<"routeguide.Rectangle">>) -> rectangle; fqbin_to_msg_name(<<"routeguide.Feature">>) -> feature; fqbin_to_msg_name(<<"routeguide.RouteNote">>) -> route_note; fqbin_to_msg_name(<<"routeguide.RouteSummary">>) -> route_summary; fqbin_to_msg_name(E) -> error({gpb_error, {badmsg, E}}). msg_name_to_fqbin(empty) -> <<"routeguide.Empty">>; msg_name_to_fqbin(point) -> <<"routeguide.Point">>; msg_name_to_fqbin(rectangle) -> <<"routeguide.Rectangle">>; msg_name_to_fqbin(feature) -> <<"routeguide.Feature">>; msg_name_to_fqbin(route_note) -> <<"routeguide.RouteNote">>; msg_name_to_fqbin(route_summary) -> <<"routeguide.RouteSummary">>; msg_name_to_fqbin(E) -> error({gpb_error, {badmsg, E}}). -spec fqbin_to_enum_name(_) -> no_return(). fqbin_to_enum_name(E) -> error({gpb_error, {badenum, E}}). -spec enum_name_to_fqbin(_) -> no_return(). enum_name_to_fqbin(E) -> error({gpb_error, {badenum, E}}). get_package_name() -> routeguide. %% Whether or not the message names %% are prepended with package name or not. uses_packages() -> true. source_basename() -> "route_guide.proto". %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned with extension, %% see get_all_proto_names/0 for a version that returns %% the basenames sans extension get_all_source_basenames() -> ["route_guide.proto"]. %% Retrieve all proto file names, also imported ones. %% The order is top-down. The first element is always the main %% source file. The files are returned sans .proto extension, %% to make it easier to use them with the various get_xyz_containment %% functions. get_all_proto_names() -> ["route_guide"]. get_msg_containment("route_guide") -> [empty, feature, point, rectangle, route_note, route_summary]; get_msg_containment(P) -> error({gpb_error, {badproto, P}}). get_pkg_containment("route_guide") -> routeguide; get_pkg_containment(P) -> error({gpb_error, {badproto, P}}). get_service_containment("route_guide") -> ['routeguide.RouteGuide']; get_service_containment(P) -> error({gpb_error, {badproto, P}}). get_rpc_containment("route_guide") -> [{'routeguide.RouteGuide', 'GetFeature'}, {'routeguide.RouteGuide', 'ListFeatures'}, {'routeguide.RouteGuide', 'RecordRoute'}, {'routeguide.RouteGuide', 'RouteChat'}, {'routeguide.RouteGuide', 'GenerateError'}, {'routeguide.RouteGuide', 'StreamingGenerateError'}]; get_rpc_containment(P) -> error({gpb_error, {badproto, P}}). get_enum_containment("route_guide") -> []; get_enum_containment(P) -> error({gpb_error, {badproto, P}}). get_proto_by_msg_name_as_fqbin(<<"routeguide.Point">>) -> "route_guide"; get_proto_by_msg_name_as_fqbin(<<"routeguide.RouteNote">>) -> "route_guide"; get_proto_by_msg_name_as_fqbin(<<"routeguide.Rectangle">>) -> "route_guide"; get_proto_by_msg_name_as_fqbin(<<"routeguide.Feature">>) -> "route_guide"; get_proto_by_msg_name_as_fqbin(<<"routeguide.RouteSummary">>) -> "route_guide"; get_proto_by_msg_name_as_fqbin(<<"routeguide.Empty">>) -> "route_guide"; get_proto_by_msg_name_as_fqbin(E) -> error({gpb_error, {badmsg, E}}). get_proto_by_service_name_as_fqbin(<<"routeguide.RouteGuide">>) -> "route_guide"; get_proto_by_service_name_as_fqbin(E) -> error({gpb_error, {badservice, E}}). -spec get_proto_by_enum_name_as_fqbin(_) -> no_return(). get_proto_by_enum_name_as_fqbin(E) -> error({gpb_error, {badenum, E}}). get_protos_by_pkg_name_as_fqbin(<<"routeguide">>) -> ["route_guide"]; get_protos_by_pkg_name_as_fqbin(E) -> error({gpb_error, {badpkg, E}}). descriptor() -> <<10, 160, 6, 10, 28, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 47, 114, 111, 117, 116, 101, 95, 103, 117, 105, 100, 101, 46, 112, 114, 111, 116, 111, 18, 10, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 34, 7, 10, 5, 69, 109, 112, 116, 121, 34, 60, 10, 7, 70, 101, 97, 116, 117, 114, 101, 18, 12, 10, 4, 110, 97, 109, 101, 24, 1, 32, 1, 40, 9, 18, 35, 10, 8, 108, 111, 99, 97, 116, 105, 111, 110, 24, 2, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 34, 44, 10, 5, 80, 111, 105, 110, 116, 18, 16, 10, 8, 108, 97, 116, 105, 116, 117, 100, 101, 24, 1, 32, 1, 40, 5, 18, 17, 10, 9, 108, 111, 110, 103, 105, 116, 117, 100, 101, 24, 2, 32, 1, 40, 5, 34, 73, 10, 9, 82, 101, 99, 116, 97, 110, 103, 108, 101, 18, 29, 10, 2, 108, 111, 24, 1, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 18, 29, 10, 2, 104, 105, 24, 2, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 34, 65, 10, 9, 82, 111, 117, 116, 101, 78, 111, 116, 101, 18, 35, 10, 8, 108, 111, 99, 97, 116, 105, 111, 110, 24, 1, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 98, 10, 12, 82, 111, 117, 116, 101, 83, 117, 109, 109, 97, 114, 121, 18, 19, 10, 11, 112, 111, 105, 110, 116, 95, 99, 111, 117, 110, 116, 24, 1, 32, 1, 40, 5, 18, 21, 10, 13, 102, 101, 97, 116, 117, 114, 101, 95, 99, 111, 117, 110, 116, 24, 2, 32, 1, 40, 5, 18, 16, 10, 8, 100, 105, 115, 116, 97, 110, 99, 101, 24, 3, 32, 1, 40, 5, 18, 20, 10, 12, 101, 108, 97, 112, 115, 101, 100, 95, 116, 105, 109, 101, 24, 4, 32, 1, 40, 5, 50, 132, 3, 10, 10, 82, 111, 117, 116, 101, 71, 117, 105, 100, 101, 18, 56, 10, 10, 71, 101, 116, 70, 101, 97, 116, 117, 114, 101, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 26, 19, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 70, 101, 97, 116, 117, 114, 101, 40, 0, 48, 0, 18, 62, 10, 12, 76, 105, 115, 116, 70, 101, 97, 116, 117, 114, 101, 115, 18, 21, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 101, 99, 116, 97, 110, 103, 108, 101, 26, 19, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 70, 101, 97, 116, 117, 114, 101, 40, 0, 48, 0, 18, 62, 10, 11, 82, 101, 99, 111, 114, 100, 82, 111, 117, 116, 101, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 26, 24, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117, 116, 101, 83, 117, 109, 109, 97, 114, 121, 40, 0, 48, 0, 18, 61, 10, 9, 82, 111, 117, 116, 101, 67, 104, 97, 116, 18, 21, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117, 116, 101, 78, 111, 116, 101, 26, 21, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117, 116, 101, 78, 111, 116, 101, 40, 0, 48, 0, 18, 57, 10, 13, 71, 101, 110, 101, 114, 97, 116, 101, 69, 114, 114, 111, 114, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 26, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 66, 10, 22, 83, 116, 114, 101, 97, 109, 105, 110, 103, 71, 101, 110, 101, 114, 97, 116, 101, 69, 114, 114, 111, 114, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 26, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>. descriptor("route_guide") -> <<10, 28, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 47, 114, 111, 117, 116, 101, 95, 103, 117, 105, 100, 101, 46, 112, 114, 111, 116, 111, 18, 10, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 34, 7, 10, 5, 69, 109, 112, 116, 121, 34, 60, 10, 7, 70, 101, 97, 116, 117, 114, 101, 18, 12, 10, 4, 110, 97, 109, 101, 24, 1, 32, 1, 40, 9, 18, 35, 10, 8, 108, 111, 99, 97, 116, 105, 111, 110, 24, 2, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 34, 44, 10, 5, 80, 111, 105, 110, 116, 18, 16, 10, 8, 108, 97, 116, 105, 116, 117, 100, 101, 24, 1, 32, 1, 40, 5, 18, 17, 10, 9, 108, 111, 110, 103, 105, 116, 117, 100, 101, 24, 2, 32, 1, 40, 5, 34, 73, 10, 9, 82, 101, 99, 116, 97, 110, 103, 108, 101, 18, 29, 10, 2, 108, 111, 24, 1, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 18, 29, 10, 2, 104, 105, 24, 2, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 34, 65, 10, 9, 82, 111, 117, 116, 101, 78, 111, 116, 101, 18, 35, 10, 8, 108, 111, 99, 97, 116, 105, 111, 110, 24, 1, 32, 1, 40, 11, 50, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 18, 15, 10, 7, 109, 101, 115, 115, 97, 103, 101, 24, 2, 32, 1, 40, 9, 34, 98, 10, 12, 82, 111, 117, 116, 101, 83, 117, 109, 109, 97, 114, 121, 18, 19, 10, 11, 112, 111, 105, 110, 116, 95, 99, 111, 117, 110, 116, 24, 1, 32, 1, 40, 5, 18, 21, 10, 13, 102, 101, 97, 116, 117, 114, 101, 95, 99, 111, 117, 110, 116, 24, 2, 32, 1, 40, 5, 18, 16, 10, 8, 100, 105, 115, 116, 97, 110, 99, 101, 24, 3, 32, 1, 40, 5, 18, 20, 10, 12, 101, 108, 97, 112, 115, 101, 100, 95, 116, 105, 109, 101, 24, 4, 32, 1, 40, 5, 50, 132, 3, 10, 10, 82, 111, 117, 116, 101, 71, 117, 105, 100, 101, 18, 56, 10, 10, 71, 101, 116, 70, 101, 97, 116, 117, 114, 101, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 26, 19, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 70, 101, 97, 116, 117, 114, 101, 40, 0, 48, 0, 18, 62, 10, 12, 76, 105, 115, 116, 70, 101, 97, 116, 117, 114, 101, 115, 18, 21, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 101, 99, 116, 97, 110, 103, 108, 101, 26, 19, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 70, 101, 97, 116, 117, 114, 101, 40, 0, 48, 0, 18, 62, 10, 11, 82, 101, 99, 111, 114, 100, 82, 111, 117, 116, 101, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 80, 111, 105, 110, 116, 26, 24, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117, 116, 101, 83, 117, 109, 109, 97, 114, 121, 40, 0, 48, 0, 18, 61, 10, 9, 82, 111, 117, 116, 101, 67, 104, 97, 116, 18, 21, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117, 116, 101, 78, 111, 116, 101, 26, 21, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 82, 111, 117, 116, 101, 78, 111, 116, 101, 40, 0, 48, 0, 18, 57, 10, 13, 71, 101, 110, 101, 114, 97, 116, 101, 69, 114, 114, 111, 114, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 26, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 18, 66, 10, 22, 83, 116, 114, 101, 97, 109, 105, 110, 103, 71, 101, 110, 101, 114, 97, 116, 101, 69, 114, 114, 111, 114, 18, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 26, 17, 46, 114, 111, 117, 116, 101, 103, 117, 105, 100, 101, 46, 69, 109, 112, 116, 121, 40, 0, 48, 0, 98, 6, 112, 114, 111, 116, 111, 51>>; descriptor(X) -> error({gpb_error, {badname, X}}). gpb_version_as_string() -> "4.7.3". gpb_version_as_list() -> [4,7,3]. ================================================ FILE: test/routeguide_route_guide.erl ================================================ -module(routeguide_route_guide). -include("grpcbox.hrl"). -export([get_feature/2, list_features/2, record_route/2, route_chat/2, generate_error/2, streaming_generate_error/2]). -type route_summary() :: #{point_count => integer(), feature_count => integer(), distance => integer(), elapsed_time => integer()}. -type point() :: #{latitude => integer(), longitude => integer()}. -type rectangle() :: #{lo => point(), hi => point()}. -type route_note() :: #{location => point(), message => string()}. -type feature() :: #{name => string(), location => point()}. -spec get_feature(Ctx :: ctx:t(), Message :: point()) -> {ok, feature(), ctx:t()}. get_feature(Ctx, Message) -> Feature = #{name => find_point(Message, data()), location => Message}, {ok, Feature, Ctx}. -spec list_features(Message::rectangle(), GrpcStream :: grpcbox_stream:t()) -> ok. list_features(_Message, GrpcStream) -> grpcbox_stream:add_headers([{<<"info">>, <<"this is a test-implementation">>}], GrpcStream), grpcbox_stream:send(#{name => <<"Tour Eiffel">>, location => #{latitude => 3, longitude => 5}}, GrpcStream), grpcbox_stream:send(#{name => <<"Louvre">>, location => #{latitude => 4, longitude => 5}}, GrpcStream), grpcbox_stream:add_trailers([{<<"nr_of_points_sent">>, <<"2">>}], GrpcStream), ok. -spec record_route(reference(), GrpcStream :: grpcbox_stream:t()) -> {ok, route_summary(), grpcbox_stream:t()}. record_route(Ref, GrpcStream) -> record_route(Ref, #{t_start => erlang:system_time(1), acc => []}, GrpcStream). record_route(Ref, Data=#{t_start := T0, acc := Points}, GrpcStream) -> receive {Ref, eos} -> %% receiving 'eos' tells us that we need to return a result. {ok, #{elapsed_time => erlang:system_time(1) - T0, point_count => length(Points), feature_count => count_features(Points), distance => distance(Points)}, GrpcStream}; {Ref, Point} -> record_route(Ref, Data#{acc => [Point | Points]}, GrpcStream) end. -spec route_chat(reference(), GrpcStream :: grpcbox_stream:t()) -> ok. route_chat(Ref, GrpcStream) -> route_chat(Ref, [], GrpcStream). route_chat(Ref, Data, GrpcStream) -> receive {Ref, eos} -> ok; {Ref, #{location := Location} = P} -> Messages = proplists:get_all_values(Location, Data), [grpcbox_stream:send(Message, GrpcStream) || Message <- Messages], route_chat(Ref, [{Location, P} | Data], GrpcStream) end. -spec generate_error(Ctx :: ctx:t(), Message :: map()) -> grpcbox_stream:grpc_extended_error_response(). generate_error(_Ctx, _Message) -> { grpc_extended_error, #{ status => ?GRPC_STATUS_INTERNAL, message => <<"error_message">>, trailers => #{ <<"generate_error_trailer">> => <<"error_trailer">> } } }. -spec streaming_generate_error(Message :: map(), GrpcStream :: grpcbox_stream:t()) -> no_return(). streaming_generate_error(_Message, _GrpcStream) -> exit( { grpc_extended_error, #{ status => ?GRPC_STATUS_INTERNAL, message => <<"error_message">>, trailers => #{ <<"generate_error_trailer">> => <<"error_trailer">> } } } ). %% Supporting functions data() -> case file:read_file("test/grpcbox_SUITE_data/route_guide_db.json") of {ok, Json} -> jsx:decode(Json, [return_maps, {labels, atom}]); {error, enoent} -> {ok, Json} = file:read_file("../../../../test/grpcbox_SUITE_data/route_guide_db.json"), jsx:decode(Json, [return_maps, {labels, atom}]) end. find_point(_Location, []) -> ""; find_point(Location, [#{location := Location, name := Name} | _]) -> Name; find_point(Location, [_ | T]) -> find_point(Location, T). count_features(_) -> 42. distance(_) -> 42. ================================================ FILE: test/routeguide_route_guide_bhvr.erl ================================================ %%%------------------------------------------------------------------- %% @doc Behaviour to implement for grpc service routeguide.RouteGuide. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2020-10-19T05:10:58+00:00 and should not be modified manually -module(routeguide_route_guide_bhvr). %% @doc Unary RPC -callback get_feature(ctx:t(), route_guide_pb:point()) -> {ok, route_guide_pb:feature(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc -callback list_features(route_guide_pb:rectangle(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). %% @doc -callback record_route(reference(), grpcbox_stream:t()) -> {ok, route_guide_pb:route_summary(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc -callback route_chat(reference(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). %% @doc Unary RPC -callback generate_error(ctx:t(), route_guide_pb:empty()) -> {ok, route_guide_pb:empty(), ctx:t()} | grpcbox_stream:grpc_error_response(). %% @doc -callback streaming_generate_error(route_guide_pb:empty(), grpcbox_stream:t()) -> ok | grpcbox_stream:grpc_error_response(). ================================================ FILE: test/routeguide_route_guide_client.erl ================================================ %%%------------------------------------------------------------------- %% @doc Client module for grpc service routeguide.RouteGuide. %% @end %%%------------------------------------------------------------------- %% this module was generated on 2020-10-19T05:10:58+00:00 and should not be modified manually -module(routeguide_route_guide_client). -compile(export_all). -compile(nowarn_export_all). -include_lib("grpcbox/include/grpcbox.hrl"). -define(is_ctx(Ctx), is_tuple(Ctx) andalso element(1, Ctx) =:= ctx). -define(SERVICE, 'routeguide.RouteGuide'). -define(PROTO_MODULE, 'route_guide_pb'). -define(MARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:encode_msg(I, T) end). -define(UNMARSHAL_FUN(T), fun(I) -> ?PROTO_MODULE:decode_msg(I, T) end). -define(DEF(Input, Output, MessageType), #grpcbox_def{service=?SERVICE, message_type=MessageType, marshal_fun=?MARSHAL_FUN(Input), unmarshal_fun=?UNMARSHAL_FUN(Output)}). %% @doc Unary RPC -spec get_feature(route_guide_pb:point()) -> {ok, route_guide_pb:feature(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). get_feature(Input) -> get_feature(ctx:new(), Input, #{}). -spec get_feature(ctx:t() | route_guide_pb:point(), route_guide_pb:point() | grpcbox_client:options()) -> {ok, route_guide_pb:feature(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). get_feature(Ctx, Input) when ?is_ctx(Ctx) -> get_feature(Ctx, Input, #{}); get_feature(Input, Options) -> get_feature(ctx:new(), Input, Options). -spec get_feature(ctx:t(), route_guide_pb:point(), grpcbox_client:options()) -> {ok, route_guide_pb:feature(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). get_feature(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/routeguide.RouteGuide/GetFeature">>, Input, ?DEF(point, feature, <<"routeguide.Point">>), Options). %% @doc -spec list_features(route_guide_pb:rectangle()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). list_features(Input) -> list_features(ctx:new(), Input, #{}). -spec list_features(ctx:t() | route_guide_pb:rectangle(), route_guide_pb:rectangle() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). list_features(Ctx, Input) when ?is_ctx(Ctx) -> list_features(Ctx, Input, #{}); list_features(Input, Options) -> list_features(ctx:new(), Input, Options). -spec list_features(ctx:t(), route_guide_pb:rectangle(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). list_features(Ctx, Input, Options) -> grpcbox_client:stream(Ctx, <<"/routeguide.RouteGuide/ListFeatures">>, Input, ?DEF(rectangle, feature, <<"routeguide.Rectangle">>), Options). %% @doc -spec record_route() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). record_route() -> record_route(ctx:new(), #{}). -spec record_route(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). record_route(Ctx) when ?is_ctx(Ctx) -> record_route(Ctx, #{}); record_route(Options) -> record_route(ctx:new(), Options). -spec record_route(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). record_route(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/routeguide.RouteGuide/RecordRoute">>, ?DEF(point, route_summary, <<"routeguide.Point">>), Options). %% @doc -spec route_chat() -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). route_chat() -> route_chat(ctx:new(), #{}). -spec route_chat(ctx:t() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). route_chat(Ctx) when ?is_ctx(Ctx) -> route_chat(Ctx, #{}); route_chat(Options) -> route_chat(ctx:new(), Options). -spec route_chat(ctx:t(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). route_chat(Ctx, Options) -> grpcbox_client:stream(Ctx, <<"/routeguide.RouteGuide/RouteChat">>, ?DEF(route_note, route_note, <<"routeguide.RouteNote">>), Options). %% @doc Unary RPC -spec generate_error(route_guide_pb:empty()) -> {ok, route_guide_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). generate_error(Input) -> generate_error(ctx:new(), Input, #{}). -spec generate_error(ctx:t() | route_guide_pb:empty(), route_guide_pb:empty() | grpcbox_client:options()) -> {ok, route_guide_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). generate_error(Ctx, Input) when ?is_ctx(Ctx) -> generate_error(Ctx, Input, #{}); generate_error(Input, Options) -> generate_error(ctx:new(), Input, Options). -spec generate_error(ctx:t(), route_guide_pb:empty(), grpcbox_client:options()) -> {ok, route_guide_pb:empty(), grpcbox:metadata()} | grpcbox_stream:grpc_error_response(). generate_error(Ctx, Input, Options) -> grpcbox_client:unary(Ctx, <<"/routeguide.RouteGuide/GenerateError">>, Input, ?DEF(empty, empty, <<"routeguide.Empty">>), Options). %% @doc -spec streaming_generate_error(route_guide_pb:empty()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_generate_error(Input) -> streaming_generate_error(ctx:new(), Input, #{}). -spec streaming_generate_error(ctx:t() | route_guide_pb:empty(), route_guide_pb:empty() | grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_generate_error(Ctx, Input) when ?is_ctx(Ctx) -> streaming_generate_error(Ctx, Input, #{}); streaming_generate_error(Input, Options) -> streaming_generate_error(ctx:new(), Input, Options). -spec streaming_generate_error(ctx:t(), route_guide_pb:empty(), grpcbox_client:options()) -> {ok, grpcbox_client:stream()} | grpcbox_stream:grpc_error_response(). streaming_generate_error(Ctx, Input, Options) -> grpcbox_client:stream(Ctx, <<"/routeguide.RouteGuide/StreamingGenerateError">>, Input, ?DEF(empty, empty, <<"routeguide.Empty">>), Options). ================================================ FILE: test/test_stats_handler.erl ================================================ -module(test_stats_handler). -export([handle/5]). handle(Ctx, _, rpc_begin, _, Stats) -> stats_pid ! {rpc_begin, erlang:monotonic_time()}, {Ctx, Stats}; handle(Ctx, _, out_payload, #{uncompressed_size := USize, compressed_size := CSize}, Stats) -> stats_pid ! {out_payload, USize, CSize}, {Ctx, Stats}; handle(Ctx, _, in_payload, #{uncompressed_size := USize, compressed_size := CSize}, Stats) -> stats_pid ! {in_payload, USize, CSize}, {Ctx, Stats}; handle(Ctx, _, rpc_end, _, Stats) -> stats_pid ! {rpc_end, erlang:monotonic_time()}, {Ctx, Stats}; handle(Ctx, _, _, _, Stats) -> {Ctx, Stats}.