def test_load_events_plugins(monkeypatch): from bigchaindb import config_utils monkeypatch.setattr( config_utils, 'iter_entry_points', lambda *args: [type('entry_point', (object, ), {'load': lambda: object})]) plugins = config_utils.load_events_plugins(['one', 'two']) assert len(plugins) == 2
def test_load_events_plugins(monkeypatch): from bigchaindb import config_utils monkeypatch.setattr(config_utils, 'iter_entry_points', lambda *args: [type('entry_point', (object, ), {'load': lambda: object})]) plugins = config_utils.load_events_plugins(['one', 'two']) assert len(plugins) == 2
def start_events_plugins(exchange): plugins = config_utils.load_events_plugins( bigchaindb.config.get('events_plugins')) for name, plugin in plugins: logger.info('Loading events plugin %s', name) event_types = getattr(plugin, 'event_types', None) queue = exchange.get_subscriber_queue(event_types) mp.Process(name='events_plugin_{}'.format(name), target=plugin.run, args=(queue, )).start()