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()
Ejemplo n.º 2
0
 def test_on_new_data(self):
     forwarder_impl = ForwarderCarriageImpl(self.consumer_impl,
                                            self.producer_impl)
     data = MagicMock()
     forwarder_impl.on_new_data(data)
     self.consumer_impl.on_new_data.assert_called_with(data)
Ejemplo n.º 3
0
 def test_emit_document(self):
     forwarder_impl = ForwarderCarriageImpl(self.consumer_impl,
                                            self.producer_impl)
     document = MagicMock()
     forwarder_impl.emit_document(document)
     self.producer_impl.emit_document.assert_called_with(document)
Ejemplo n.º 4
0
 def test_register(self):
     forwarder_impl = ForwarderCarriageImpl(self.consumer_impl,
                                            self.producer_impl)
     forwarder_impl.register(self.node)
     self.consumer_impl.register.assert_called_with(self.node)
     self.producer_impl.register.assert_called_with(self.node)
 def test_on_new_data(self):
     forwarder_impl = ForwarderCarriageImpl(self.consumer_impl, self.producer_impl)
     data = MagicMock()
     forwarder_impl.on_new_data(data)
     self.consumer_impl.on_new_data.assert_called_with(data)
 def test_emit_document(self):
     forwarder_impl = ForwarderCarriageImpl(self.consumer_impl, self.producer_impl)
     document = MagicMock()
     forwarder_impl.emit_document(document)
     self.producer_impl.emit_document.assert_called_with(document)
 def test_register(self):
     forwarder_impl = ForwarderCarriageImpl(self.consumer_impl, self.producer_impl)
     forwarder_impl.register(self.node)
     self.consumer_impl.register.assert_called_with(self.node)
     self.producer_impl.register.assert_called_with(self.node)