def send(node,task,message = ""):
try:
channel = grpc.insecure_channel(node )
taskType,task =task / SERVICE ,task % SERVICE
if taskType == DESCOVERY:
stub = grpc_pb2_grpc.DiscoveryStub(channel)
if task ==EXCHANGENODE:
response = stub.ExchangeNode(grpc_pb2.Node(number = len(Node.__Nodes),ipport = Node.getNodesList() ))
for node in response.ipport :
Node.__Nodes.add(node)
elif taskType == SYNCHRONIZATION:
stub = grpc_pb2_grpc.SynchronizationStub(channel)
synchronization.Task(stub,task,message)
except Exception as e :
Node.delNode(node)
return
评论列表
文章目录