Interceptors

The grpc_proxy.interceptors contains classes and functions:

class grpc_proxy.interceptors.GrpcProxyNoRuleError(*args: Any, **kwargs: Any)[source]
class grpc_proxy.interceptors.ProxyInterceptor(*args: Any, **kwargs: Any)[source]

gRPC interceptor for initialise proxy.

intercept_service(continuation, handler_call_details)[source]

Interceptor method for generate handler.

Parameters
  • continuation (function) – Function for get net handler.

  • handler_call_details (grpc._server._HandlerCallDetails) – Channel metainformation.

grpc_proxy.interceptors.proxy_method(request, context, service, method, config, options)[source]

Prototype for gRPC proxy method.

Parameters
  • request (binary) – Binary request without deserialisation.

  • context (grpc._server._Context) – A gRPC service contex. For more details read https://grpc.github.io/grpc/python/grpc.html#service-side-context.

  • service (str) – A name of discovery service.

  • method (str) – A name of method in discovered service.

  • config (dict) – A config dictionary with all information. Must contain field ‘hosts’ and ‘loadBalancer’. If None raise GrpcProxyNoRuleError.

  • options (list) – A list of parameters for gRPC channel.

Returns

Responce from the target services.

Return type

binary