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()
Beispiel #2
0
def main():
    args = parser.parse_args()
    create_loggers()
    log.info('This is a Simple Consumer example')

    manifest_path = args.manifest_path
    websocket_url = args.websocket_url
    consumer_impl = None
    fs_reader = None

    reference_clock = LocalMachineClock()
    reference_clock.clock_mode = 'local'

    if manifest_path:
        do_tail = args.do_tail
        consumer_impl = FilesystemConsumerImpl(reference_clock)
        fs_reader = FilesystemReader(manifest_path, consumer_impl, do_tail)
    else:
        consumer_impl = WebsocketConsumerCarriage()

    simple_consumer = SimpleConsumer(node_id='simple-consumer',
                                     reference_clock=reference_clock)

    # Chaining converter
    ConsumerNodeCarriageAdapter(consumer_node=simple_consumer,
                                consumer_carriage=consumer_impl)

    if manifest_path:
        fs_reader.resume_reading()
    else:
        factory_args = {}
        if args.proxy:
            proxyHost, proxyPort = args.proxy.split(':')
            factory_args['proxy'] = {'host': proxyHost, 'port': int(proxyPort)}

        twisted_consumer = TwistedWSConsumer(custom_consumer=consumer_impl)

        factory = BroadcastClientFactory(url=websocket_url,
                                         consumer=twisted_consumer,
                                         **factory_args)

        factory.protocol = BroadcastClientProtocol

        factory.connect()

        reactor.run()
def main():
    args = parser.parse_args()
    create_loggers()
    log.info('This is a User Input Consumer example')

    consumer_impl = None

    consumer_impl = WebsocketConsumerCarriage()

    reference_clock = LocalMachineClock()
    reference_clock.clock_mode = 'local'

    simple_consumer = SimpleConsumer(node_id='user-input-consumer',
                                     consumer_carriage=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()
Beispiel #4
0
 def __init__(self, config, local_config):
     super(WebsocketInput, self).__init__(config, local_config)
     # from_string_converter does not work for lists in configman :( Doing it manually here
     self.config.connect = parse_url_list(self.config.connect)
     self.component = WebsocketConsumerCarriage()
     self.backend.register_component_start(self)
Beispiel #5
0
 def __init__(self, config, local_config):
     super(WebsocketLegacyInput, self).__init__(config, local_config)
     self.component = WebsocketConsumerCarriage()
     self.backend.register_component_start(self)