Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.


feat(router): add a block router for benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 23, 2019
1 parent ea69135 commit 8fbb094
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion gnes/cli/
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def set_composer_flask_parser(parser=None):
def set_service_parser(parser=None):
from ..service.base import SocketType, BaseService, ParallelType
import random
import uuid
if not parser:
parser = set_base_parser()
min_port, max_port = 49152, 65536
Expand Down
15 changes: 15 additions & 0 deletions gnes/router/
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,22 @@
from ..proto import gnes_pb2

class BlockRouter(BaseMapRouter):
"""Wait for 'sleep_sec' seconds and forward messages, useful for benchmark"""

def __init__(self, sleep_sec: int = 5, *args, **kwargs):
super().__init__(*args, **kwargs)
self.sleep_sec = sleep_sec

def apply(self, msg: 'gnes_pb2.Message', *args, **kwargs):
import time

class PublishRouter(BaseMapRouter):
"""Copy a message 'num_part' time and forward it, useful for PUB-SUB sockets.
'num_part' is an indicator for downstream sync-barrier, e.g. a ReduceRouter

def __init__(self, num_part: int, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit 8fbb094

Please sign in to comment.