Ejemplo n.º 1
0
 def Configure(
         self, request: messages_pb2.ClientConfigureRequest,
         context: grpc.ServicerContext
 ) -> messages_pb2.ClientConfigureResponse:
     logger.info("Received Configure RPC: %s", request)
     method_strs = (_METHOD_ENUM_TO_STR[t] for t in request.types)
     for method in _SUPPORTED_METHODS:
         method_enum = _METHOD_STR_TO_ENUM[method]
         channel_config = self._per_method_configs[method]
         if method in method_strs:
             qps = self._qps
             metadata = ((md.key, md.value) for md in request.metadata
                         if md.type == method_enum)
             # For backward compatibility, do not change timeout when we
             # receive a default value timeout.
             if request.timeout_sec == 0:
                 timeout_sec = channel_config.rpc_timeout_sec
             else:
                 timeout_sec = request.timeout_sec
         else:
             qps = 0
             metadata = ()
             # Leave timeout unchanged for backward compatibility.
             timeout_sec = channel_config.rpc_timeout_sec
         with channel_config.condition:
             channel_config.qps = qps
             channel_config.metadata = list(metadata)
             channel_config.rpc_timeout_sec = timeout_sec
             channel_config.condition.notify_all()
     return messages_pb2.ClientConfigureResponse()
Ejemplo n.º 2
0
 def Configure(
         self, request: messages_pb2.ClientConfigureRequest,
         context: grpc.ServicerContext
 ) -> messages_pb2.ClientConfigureResponse:
     logger.info("Received Configure RPC: %s", request)
     method_strs = (_METHOD_ENUM_TO_STR[t] for t in request.types)
     for method in _SUPPORTED_METHODS:
         method_enum = _METHOD_STR_TO_ENUM[method]
         if method in method_strs:
             qps = self._qps
             metadata = ((md.key, md.value) for md in request.metadata
                         if md.type == method_enum)
         else:
             qps = 0
             metadata = ()
         channel_config = self._per_method_configs[method]
         with channel_config.condition:
             channel_config.qps = qps
             channel_config.metadata = list(metadata)
             channel_config.condition.notify_all()
     return messages_pb2.ClientConfigureResponse()