def test_forward_everything(self, dev, ctx): zmqmsgbus.forward('from_addr', 'to_addr') dev.assert_called_once_with(zmqmsgbus.zmq.FORWARDER, ctx.return_value.socket.return_value, ctx.return_value.socket.return_value) sock = ctx.return_value.socket.return_value sock.connect.assert_has_calls([call('from_addr'), call('to_addr')], any_order=True)
import argparse import zmqmsgbus if __name__ == '__main__': parser = argparse.ArgumentParser(description='Run ZeroMQ message Bus') parser.add_argument('--in', dest='in_addr', nargs='*', default=['ipc://ipc/sink']) parser.add_argument('--out', dest='out_addr', nargs='*', default=['ipc://ipc/source']) args = parser.parse_args() print('runnning ZeroMQ Message Bus') print('input {}'.format(', '.join(args.in_addr))) print('output {}'.format(', '.join(args.out_addr))) zmqmsgbus.forward(args.in_addr, args.out_addr, bind=True)
import argparse import zmqmsgbus if __name__ == '__main__': parser = argparse.ArgumentParser(description='Forward ZeroMQ messages') parser.add_argument('--from', dest='from_addr', nargs='*', default=['ipc://ipc/sink']) parser.add_argument('--to', dest='to_addr', nargs='*', default=['ipc://ipc/source']) parser.add_argument('--topic', default='') parser.add_argument('--rename', default=None) parser.add_argument('--bind_from', action='store_true') parser.add_argument('--bind_to', action='store_true') args = parser.parse_args() if args.rename is None: print('forwarding ' + args.topic) else: print('forwarding {} ==> {}'.format(args.topic, args.rename)) print('from {}'.format(', '.join(args.from_addr))) print('to {}'.format(', '.join(args.to_addr))) zmqmsgbus.forward(args.from_addr, args.to_addr, args.topic, args.rename, bind_sub=args.bind_from, bind_pub=args.bind_to)
import argparse import zmqmsgbus if __name__ == '__main__': parser = argparse.ArgumentParser(description='Forward ZeroMQ messages') parser.add_argument('--from', dest='from_addr', nargs='*', default=['ipc://ipc/source']) parser.add_argument('--to', dest='to_addr', nargs='*', default=['ipc://ipc/sink']) parser.add_argument('--topic', default='') parser.add_argument('--rename', default=None) args = parser.parse_args() if args.rename is None: print('forwarding ' + args.topic) else: print('forwarding {} ==> {}'.format(args.topic, args.rename)) print('from {}'.format(', '.join(args.from_addr))) print('to {}'.format(', '.join(args.to_addr))) zmqmsgbus.forward(args.from_addr, args.to_addr, args.topic, args.rename)
import argparse import zmqmsgbus if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run ZeroMQ message Bus") parser.add_argument("--in", dest="in_addr", nargs="*", default=["ipc://ipc/sink"]) parser.add_argument("--out", dest="out_addr", nargs="*", default=["ipc://ipc/source"]) args = parser.parse_args() print("runnning ZeroMQ Message Bus") print("input {}".format(", ".join(args.in_addr))) print("output {}".format(", ".join(args.out_addr))) zmqmsgbus.forward(args.in_addr, args.out_addr, bind_sub=True, bind_pub=True)