예제 #1
0
    def from_config(_config, **options):
        """Instantiate an in-memory event store from config.

        Parameters:
        _config   -- the configuration file options read from file(s). Not
                      used.
        **options -- various options given to the specific event store. Shall
                     not be used with this event store. Warning will be logged
                     for every extra non-recognized option.

        returns   -- an `InMemoryEventStore` event store.

        """
        rconfig.check_config_options("InMemoryEventStore", tuple(), tuple(),
                                     options)
        return InMemoryEventStore()
예제 #2
0
    def from_config(_config, **options):
        """Instantiate an in-memory event store from config.

        Parameters:
        _config   -- the configuration file options read from file(s). Not
                      used.
        **options -- various options given to the specific event store. Shall
                     not be used with this event store. Warning will be logged
                     for every extra non-recognized option.

        returns   -- an `InMemoryEventStore` event store.

        """
        rconfig.check_config_options("InMemoryEventStore", tuple(), tuple(),
                                     options)
        return InMemoryEventStore()
예제 #3
0
    def from_config(config, **options):
        """Instantiate an `LogEventStore` from config.

        Parameters:
        _config    -- the configuration file options read from file(s).
        **options -- various options given to the specific event store. Shall
                     not be used with this event store. Warning will be logged
                     for every extra non-recognized option. The only required
                     key to this function is 'path'.

        returns   -- a newly instantiated `LogEventStore`.

        """
        expected_args = ('path',)
        rconfig.check_config_options("LogEventStore", expected_args, tuple(),
                                     options)
        return LogEventStore(options['path'])
예제 #4
0
    def from_config(config, **options):
        """Instantiate an `LogEventStore` from config.

        Parameters:
        _config    -- the configuration file options read from file(s).
        **options -- various options given to the specific event store. Shall
                     not be used with this event store. Warning will be logged
                     for every extra non-recognized option. The only required
                     key to this function is 'path'.

        returns   -- a newly instantiated `LogEventStore`.

        """
        expected_args = ('path', )
        rconfig.check_config_options("LogEventStore", expected_args, tuple(),
                                     options)
        return LogEventStore(options['path'])
예제 #5
0
    def from_config(config, **options):
        """Instantiate an `SyncedRotationEventStores` from config.

        Parameters:
        config    -- the configuration file options read from file(s).
        **options -- various options given to the specific event store. Shall
                     not be used with this event store. Warning will be logged
                     for every extra non-recognized option. The only required
                     key to this function is 'path'.

        returns   -- a newly instantiated `SyncedRotationEventStores`.

        """
        required_args = ('storage-backends', )
        optional_args = {'events_per_batch': 25000}
        rconfig.check_config_options("SyncedRotationEventStores",
                                     required_args,
                                     tuple(optional_args.keys()), options)

        if "events_per_batch" in options:
            events_per_batch = int(options["events_per_batch"])
        else:
            events_per_batch = optional_args["events_per_batch"]

        estore = SyncedRotationEventStores(events_per_batch)

        for section in options['storage-backends'].split(' '):
            try:
                substore = rconfig.construct_eventstore(config, section)
                estore.add_rotated_store(substore)
            except Exception as e:
                _logger.exception(
                    'Could not instantiate substore from'
                    ' section %s', section)
                estore.close()
                raise

        return estore
예제 #6
0
    def from_config(config, **options):
        """Instantiate an `SyncedRotationEventStores` from config.

        Parameters:
        config    -- the configuration file options read from file(s).
        **options -- various options given to the specific event store. Shall
                     not be used with this event store. Warning will be logged
                     for every extra non-recognized option. The only required
                     key to this function is 'path'.

        returns   -- a newly instantiated `SyncedRotationEventStores`.

        """
        required_args = ('storage-backends',)
        optional_args = {'events_per_batch': 25000}
        rconfig.check_config_options("SyncedRotationEventStores",
                                     required_args,
                                     tuple(optional_args.keys()), options)

        if "events_per_batch" in options:
            events_per_batch = int(options["events_per_batch"])
        else:
            events_per_batch = optional_args["events_per_batch"]

        estore = SyncedRotationEventStores(events_per_batch)

        for section in options['storage-backends'].split(' '):
            try:
                substore = rconfig.construct_eventstore(config, section)
                estore.add_rotated_store(substore)
            except Exception as e:
                _logger.exception('Could not instantiate substore from'
                                  ' section %s', section)
                estore.close()
                raise

        return estore