Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files
fix(service): make route_table as option for all services
  • Loading branch information
hanhxiao committed Sep 23, 2019
1 parent d7e6fb1 commit c5347a5b668148f345d732acd1f459c6d025f201
Showing with 5 additions and 5 deletions.
  1. +2 −2 gnes/cli/
  2. +2 −2 gnes/client/
  3. +1 −1 gnes/proto/
@@ -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
@@ -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,
getattr(self, 'identity', None))
'input %s:%s\t output %s:%s' %
(self.args.host_in, colored(self.args.port_in, 'yellow'),
@@ -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.routes.extend(sorted(routes.values(), key=lambda x: (x.start_time.seconds, x.start_time.nanos)))

0 comments on commit c5347a5

Please sign in to comment.