コード例 #1
0
def test_event_handler_raises_when_called_after_start():
    from bigchaindb.events import Exchange, POISON_PILL

    exchange = Exchange()
    publisher_queue = exchange.get_publisher_queue()
    publisher_queue.put(POISON_PILL)
    exchange.run()

    with pytest.raises(RuntimeError):
        exchange.get_subscriber_queue()
コード例 #2
0
ファイル: test_events.py プロジェクト: roderik/bigchaindb
def test_event_handler_raises_when_called_after_start():
    from bigchaindb.events import Exchange, POISON_PILL

    exchange = Exchange()
    publisher_queue = exchange.get_publisher_queue()
    publisher_queue.put(POISON_PILL)
    exchange.run()

    with pytest.raises(RuntimeError):
        exchange.get_subscriber_queue()
コード例 #3
0
def test_exchange_stops_with_poison_pill():
    from bigchaindb.events import EventTypes, Event, Exchange, POISON_PILL

    # create and event
    event_data = {'msg': 'some data'}
    event = Event(EventTypes.BLOCK_VALID, event_data)

    # create the events pub sub
    exchange = Exchange()

    publisher_queue = exchange.get_publisher_queue()

    # push and event to the queue
    publisher_queue.put(event)
    publisher_queue.put(POISON_PILL)
    exchange.run()

    assert publisher_queue.qsize() == 0
コード例 #4
0
ファイル: test_events.py プロジェクト: roderik/bigchaindb
def test_exchange_stops_with_poison_pill():
    from bigchaindb.events import EventTypes, Event, Exchange, POISON_PILL

    # create and event
    event_data = {'msg': 'some data'}
    event = Event(EventTypes.BLOCK_VALID, event_data)

    # create the events pub sub
    exchange = Exchange()

    publisher_queue = exchange.get_publisher_queue()

    # push and event to the queue
    publisher_queue.put(event)
    publisher_queue.put(POISON_PILL)
    exchange.run()

    assert publisher_queue.qsize() == 0
コード例 #5
0
def start():
    logger.info('Initializing BigchainDB...')

    # Create a Exchange object.
    # The events queue needs to be initialized once and shared between
    # processes. This seems the best way to do it
    # At this point only the election processs and the event consumer require
    # this queue.
    exchange = Exchange()

    # start the processes
    logger.info('Starting block')
    block.start()

    logger.info('Starting voter')
    vote.start()

    logger.info('Starting stale transaction monitor')
    stale.start()

    logger.info('Starting election')
    election.start(events_queue=exchange.get_publisher_queue())

    # start the web api
    app_server = server.create_server(settings=bigchaindb.config['server'],
                                      log_config=bigchaindb.config['log'])
    p_webapi = mp.Process(name='webapi', target=app_server.run)
    p_webapi.start()

    logger.info('WebSocket server started')
    p_websocket_server = mp.Process(name='ws',
                                    target=websocket_server.start,
                                    args=(exchange.get_subscriber_queue(
                                        EventTypes.BLOCK_VALID), ))
    p_websocket_server.start()

    # start message
    logger.info(BANNER.format(bigchaindb.config['server']['bind']))

    start_events_plugins(exchange)

    exchange.run()
コード例 #6
0
ファイル: processes.py プロジェクト: cgwyx/bigchaindb
def start():
    logger.info('Initializing BigchainDB...')

    # Create a Exchange object.
    # The events queue needs to be initialized once and shared between
    # processes. This seems the best way to do it
    # At this point only the election processs and the event consumer require
    # this queue.
    exchange = Exchange()

    # start the processes
    logger.info('Starting block')
    block.start()

    logger.info('Starting voter')
    vote.start()

    logger.info('Starting stale transaction monitor')
    stale.start()

    logger.info('Starting election')
    election.start(events_queue=exchange.get_publisher_queue())

    # start the web api
    app_server = server.create_server(settings=bigchaindb.config['server'],
                                      log_config=bigchaindb.config['log'])
    p_webapi = mp.Process(name='webapi', target=app_server.run)
    p_webapi.start()

    logger.info('WebSocket server started')
    p_websocket_server = mp.Process(name='ws',
                                    target=websocket_server.start,
                                    args=(exchange.get_subscriber_queue(EventTypes.BLOCK_VALID),))
    p_websocket_server.start()

    # start message
    logger.info(BANNER.format(bigchaindb.config['server']['bind']))

    start_events_plugins(exchange)

    exchange.run()