From 6507c0fc862446ea2cc0f9c0cfe0c0d6e9628309 Mon Sep 17 00:00:00 2001 From: Peter Salin Date: Mon, 7 Feb 2022 13:19:58 +0200 Subject: [PATCH] Add benchmark utility Adds utilities for benchmarking the grpcbox client and server. The benchmark protocol is compatible with the one used by for example the Go client and server, making it possible to benchmark them also against each other. --- benchmark/README.md | 46 + benchmark/config/sys.config | 37 + benchmark/config/test.config | 23 + benchmark/proto/benchmark_service.proto | 44 + benchmark/src/benchmark_service_pb.erl | 4958 +++++++++++++++++ .../src/grpc_testing_benchmark_service.erl | 51 + .../grpc_testing_benchmark_service_bhvr.erl | 29 + .../grpc_testing_benchmark_service_client.erl | 115 + .../test/grpcbox_benchmark_client_SUITE.erl | 151 + rebar.config | 18 +- 10 files changed, 5470 insertions(+), 2 deletions(-) create mode 100644 benchmark/README.md create mode 100644 benchmark/config/sys.config create mode 100644 benchmark/config/test.config create mode 100644 benchmark/proto/benchmark_service.proto create mode 100644 benchmark/src/benchmark_service_pb.erl create mode 100644 benchmark/src/grpc_testing_benchmark_service.erl create mode 100644 benchmark/src/grpc_testing_benchmark_service_bhvr.erl create mode 100644 benchmark/src/grpc_testing_benchmark_service_client.erl create mode 100644 benchmark/test/grpcbox_benchmark_client_SUITE.erl diff --git a/benchmark/README.md b/benchmark/README.md new file mode 100644 index 0000000..fcc334c --- /dev/null +++ b/benchmark/README.md @@ -0,0 +1,46 @@ +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 +``` diff --git a/benchmark/config/sys.config b/benchmark/config/sys.config new file mode 100644 index 0000000..64b10cf --- /dev/null +++ b/benchmark/config/sys.config @@ -0,0 +1,37 @@ +[ + {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}}}}]}]} +]. diff --git a/benchmark/config/test.config b/benchmark/config/test.config new file mode 100644 index 0000000..e169856 --- /dev/null +++ b/benchmark/config/test.config @@ -0,0 +1,23 @@ +%% 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} + ] +}. diff --git a/benchmark/proto/benchmark_service.proto b/benchmark/proto/benchmark_service.proto new file mode 100644 index 0000000..72bbb84 --- /dev/null +++ b/benchmark/proto/benchmark_service.proto @@ -0,0 +1,44 @@ +// 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); +} diff --git a/benchmark/src/benchmark_service_pb.erl b/benchmark/src/benchmark_service_pb.erl new file mode 100644 index 0000000..69fae07 --- /dev/null +++ b/benchmark/src/benchmark_service_pb.erl @@ -0,0 +1,4958 @@ +%% -*- 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]. diff --git a/benchmark/src/grpc_testing_benchmark_service.erl b/benchmark/src/grpc_testing_benchmark_service.erl new file mode 100644 index 0000000..b1c130d --- /dev/null +++ b/benchmark/src/grpc_testing_benchmark_service.erl @@ -0,0 +1,51 @@ +-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. diff --git a/benchmark/src/grpc_testing_benchmark_service_bhvr.erl b/benchmark/src/grpc_testing_benchmark_service_bhvr.erl new file mode 100644 index 0000000..114c90d --- /dev/null +++ b/benchmark/src/grpc_testing_benchmark_service_bhvr.erl @@ -0,0 +1,29 @@ +%%%------------------------------------------------------------------- +%% @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(). + diff --git a/benchmark/src/grpc_testing_benchmark_service_client.erl b/benchmark/src/grpc_testing_benchmark_service_client.erl new file mode 100644 index 0000000..c903723 --- /dev/null +++ b/benchmark/src/grpc_testing_benchmark_service_client.erl @@ -0,0 +1,115 @@ +%%%------------------------------------------------------------------- +%% @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). + diff --git a/benchmark/test/grpcbox_benchmark_client_SUITE.erl b/benchmark/test/grpcbox_benchmark_client_SUITE.erl new file mode 100644 index 0000000..d6abab4 --- /dev/null +++ b/benchmark/test/grpcbox_benchmark_client_SUITE.erl @@ -0,0 +1,151 @@ +-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)]). diff --git a/rebar.config b/rebar.config index 0ab03ff..430b28c 100644 --- a/rebar.config +++ b/rebar.config @@ -39,8 +39,22 @@ {dir, "interop/test"}]}, {shell, [{apps, [grpcbox]}, - {config, "interop/config/sys.config"}]}]} - ]}. + {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]}]}.