Balancer¶
The grpc_proxy.service
contains classes:
grpc_proxy.service.LoadBalancer
grpc_proxy.service.RandomChoice
grpc_proxy.service.PickFirst
- class grpc_proxy.balancer.LoadBalancer(service, method, adresses=[], options=[], metadata=None)[source]¶
Base class for all load nalancer classes.
- sent(request, metadata)[source]¶
A method for process given request.
- Parameters
request (binary) – Binary request without deserialisation.
metadata (tuple) – A gRPC service metadata (included http2 headers). For more details read https://grpc.github.io/grpc/python/grpc.html.
- Returns
Return tuple of host and responce from the target services.
- Return type
(str, binary)
- class grpc_proxy.balancer.PickFirst(service, method, adresses=[], options=[], metadata=None)[source]¶
Implementation of pick first balancer with random host choosing.
- sent(request, metadata)[source]¶
A method for process given request.
- Parameters
request (binary) – Binary request without deserialisation.
metadata (tuple) – A gRPC service metadata (included http2 headers). For more details read https://grpc.github.io/grpc/python/grpc.html.
- Returns
Return tuple of host and responce from the target services.
- Return type
(str, binary)
- class grpc_proxy.balancer.RandomChoice(service, method, adresses=[], options=[], metadata=None)[source]¶
Implementation of random balancer with random host choosing.
- sent(request, metadata)[source]¶
A method for process given request.
- Parameters
request (binary) – Binary request without deserialisation.
metadata (tuple) – A gRPC service metadata (included http2 headers). For more details read https://grpc.github.io/grpc/python/grpc.html.
- Returns
Return tuple of host and responce from the target services.
- Return type
(str, binary)