def main(): args = parser.parse_args() create_loggers() log.info('This is a Simple Consumer example') consumer_impl = None consumer_impl = TwistedConsumerImpl() reference_clock = LocalMachineClock() reference_clock.clock_mode = 'local' simple_consumer = SimpleConsumer( node_id='simple-consumer', carriage_impl=consumer_impl, reference_clock=reference_clock ) factory = UserInputServerFactory( url='ws://127.0.0.1:9001', consumer=TwistedConsumer( custom_consumer=consumer_impl ) ) factory.protocol = UserInputServerProtocol factory.listen() reactor.run()
def main(): args = parser.parse_args() create_loggers() do_export = False if args.folder_export: do_export = True sub_consumer_impl = TwistedConsumerImpl() sub_prod_impl = None if do_export: sub_prod_impl = FilesystemProducerImpl(args.folder_export) else: sub_prod_impl = TwistedProducerImpl() carriage_impl = ForwarderCarriageImpl(sub_consumer_impl, sub_prod_impl) reference_clock = LocalMachineClock() reference_clock.clock_mode = 'local' dist_node = DistributingNode( node_id='distributing-node', carriage_impl=carriage_impl, reference_clock=reference_clock ) # This factory listens for incoming documents from the user input producer. user_input_server_factory = UserInputServerFactory( url='ws://127.0.0.1:9001', consumer=TwistedConsumer( custom_consumer=sub_consumer_impl ) ) user_input_server_factory.protocol = UserInputServerProtocol user_input_server_factory.listen() if not do_export: # This factory listens for any consumer to forward documents to. broadcast_factory = BroadcastServerFactory("ws://127.0.0.1:9000") broadcast_factory.protocol = StreamingServerProtocol broadcast_factory.listen() TwistedPullProducer( consumer=broadcast_factory, custom_producer=sub_prod_impl ) reactor.run()
def main(): args = parser.parse_args() create_loggers() do_export = False if args.folder_export: do_export = True sub_consumer_impl = WebsocketConsumerCarriage() sub_prod_impl = None if do_export: sub_prod_impl = FilesystemProducerImpl(args.folder_export) else: sub_prod_impl = WebsocketProducerCarriage() reference_clock = LocalMachineClock() reference_clock.clock_mode = 'local' dist_node = DistributingNode( node_id='distributing-node', producer_carriage=sub_prod_impl, consumer_carriage=sub_consumer_impl, reference_clock=reference_clock ) # This factory listens for incoming documents from the user input producer. user_input_server_factory = UserInputServerFactory( url=args.websocket_url, consumer=TwistedConsumer( custom_consumer=sub_consumer_impl ) ) user_input_server_factory.protocol = UserInputServerProtocol user_input_server_factory.listen() if not do_export: # This factory listens for any consumer to forward documents to. broadcast_factory = BroadcastServerFactory("ws://127.0.0.1:9000") broadcast_factory.protocol = BroadcastServerProtocol broadcast_factory.listen() TwistedPushProducer( consumer=broadcast_factory, custom_producer=sub_prod_impl ) reactor.run()