service.py 683 Bytes
Newer Older
Wei Shoulin's avatar
Wei Shoulin committed
1
import os
Shoulin Wei's avatar
init  
Shoulin Wei committed
2
3
import grpc
class ServiceProxy:
Wei Shoulin's avatar
Wei Shoulin committed
4
5
    def __init__(self):
        self.gateway = os.getenv("CSST_DFS_GATEWAY",'172.31.248.218:30880')
Shoulin Wei's avatar
init  
Shoulin Wei committed
6
7

    def insecure(self, stubCls):
Wei Shoulin's avatar
Wei Shoulin committed
8
9
10
11
12
        options = [('grpc.max_send_message_length', 1000 * 1024 * 1024),
                    ('grpc.max_receive_message_length', 1000 * 1024 * 1024),
                    ('grpc.enable_retries', 1),
                    ('grpc.service_config', '{ "retryPolicy":{ "maxAttempts": 4, "initialBackoff": "0.1s", "maxBackoff": "1s", "backoffMutiplier": 2, "retryableStatusCodes": [ "UNAVAILABLE" ] } }')]        
        channel = grpc.insecure_channel(self.gateway, options=options)
Shoulin Wei's avatar
init  
Shoulin Wei committed
13
        return stubCls(channel)