And back to enums again

pull/25366/head
Richard Belleville 4 years ago
parent b47279d923
commit 3cf0266843
  1. 4
      src/proto/grpc/testing/messages.proto
  2. 18
      src/python/grpcio_tests/tests_py3_only/interop/xds_interop_client.py

@ -237,8 +237,8 @@ message LoadBalancerAccumulatedStatsResponse {
map<int32, int32> result = 2;
}
// Per-method RPC statistics. The key is the full method path; i.e.
// "/proto.package.ServiceName/MethodName".
// Per-method RPC statistics. The key is the RpcType in string form; e.g.
// 'EMPTY_CALL' or 'UNARY_CALL'
map<string, MethodStats> stats_per_method = 4;
}

@ -49,9 +49,9 @@ _METHOD_STR_TO_ENUM = {
"EmptyCall": messages_pb2.ClientConfigureRequest.EMPTY_CALL,
}
_METHOD_CAMEL_TO_FULL_PATH = {
"UnaryCall": "/grpc.testing.TestService/UnaryCall",
"EmptyCall": "/grpc.testing.TestService/EmptyCall",
_METHOD_CAMEL_TO_CAPS_SNAKE = {
"UnaryCall": "UNARY_CALL",
"EmptyCall": "EMPTY_CALL",
}
_METHOD_ENUM_TO_STR = {v: k for k, v in _METHOD_STR_TO_ENUM.items()}
@ -161,17 +161,17 @@ class _LoadBalancerStatsServicer(test_pb2_grpc.LoadBalancerStatsServiceServicer
response = messages_pb2.LoadBalancerAccumulatedStatsResponse()
with _global_lock:
for method in _SUPPORTED_METHODS:
method_path = _METHOD_CAMEL_TO_FULL_PATH[method]
caps_method = _METHOD_CAMEL_TO_CAPS_SNAKE[method]
response.num_rpcs_started_by_method[
method_path] = _global_rpcs_started[method]
caps_method] = _global_rpcs_started[method]
response.num_rpcs_succeeded_by_method[
method_path] = _global_rpcs_succeeded[method]
caps_method] = _global_rpcs_succeeded[method]
response.num_rpcs_failed_by_method[
method_path] = _global_rpcs_failed[method]
caps_method] = _global_rpcs_failed[method]
response.stats_per_method[
method_path].rpcs_started = _global_rpcs_started[method]
caps_method].rpcs_started = _global_rpcs_started[method]
for code, count in _global_rpc_statuses[method].items():
response.stats_per_method[method_path].result[code] = count
response.stats_per_method[caps_method].result[code] = count
logger.info("Returning cumulative stats response.")
return response

Loading…
Cancel
Save