From c5347a5b668148f345d732acd1f459c6d025f201 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Mon, 23 Sep 2019 14:29:41 +0800 Subject: [PATCH] fix(service): make route_table as option for all services --- gnes/cli/parser.py | 4 ++-- gnes/client/base.py | 4 ++-- gnes/proto/__init__.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gnes/cli/parser.py b/gnes/cli/parser.py index 118e1f8b..2474e5ff 100644 --- a/gnes/cli/parser.py +++ b/gnes/cli/parser.py @@ -179,8 +179,8 @@ def set_service_parser(parser=None): parser.add_argument('--check_version', action=ActionNoYes, default=True, help='comparing the GNES and proto version of incoming message with local setup, ' 'mismatch raise an exception') - parser.add_argument('--identity', type=str, default=str(uuid.uuid4()).split('-')[0], - help='identity of the service, by default a random uuid string') + parser.add_argument('--identity', type=str, default='', + help='identity of the service, empty by default') parser.add_argument('--route_table', action=ActionNoYes, default=True, help='showing a route table with time cost after receiving the result') return parser diff --git a/gnes/client/base.py b/gnes/client/base.py index 278be54a..7962eec0 100644 --- a/gnes/client/base.py +++ b/gnes/client/base.py @@ -76,11 +76,11 @@ def __init__(self, args): self.ctx.setsockopt(zmq.LINGER, 0) self.receiver, recv_addr = build_socket( self.ctx, self.args.host_in, self.args.port_in, - self.args.socket_in, getattr(self, 'identity', None)) + self.args.socket_in, self.args.identity) self.sender, send_addr = build_socket(self.ctx, self.args.host_out, self.args.port_out, self.args.socket_out, - getattr(self, 'identity', None)) + self.args.identity) self.logger.info( 'input %s:%s\t output %s:%s' % (self.args.host_in, colored(self.args.port_in, 'yellow'), diff --git a/gnes/proto/__init__.py b/gnes/proto/__init__.py index b70e0321..ac79e3eb 100644 --- a/gnes/proto/__init__.py +++ b/gnes/proto/__init__.py @@ -116,7 +116,7 @@ def add_route(evlp: 'gnes_pb2.Envelope', name: str, identity: str): def merge_routes(msg: 'gnes_pb2.Message', prev_msgs: List['gnes_pb2.Message']): # take unique routes by service identity - routes = {r.service_identity: r for m in prev_msgs for r in m.envelope.routes} + routes = {(r.service + r.service_identity): r for m in prev_msgs for r in m.envelope.routes} msg.envelope.ClearField('routes') msg.envelope.routes.extend(sorted(routes.values(), key=lambda x: (x.start_time.seconds, x.start_time.nanos)))