Пример #1
0
def get_db():
    """Get or initialize the request-scoped datastore instance

    Returns:
        DataStore: a request-scoped datastore instance
    """
    if "db" not in g:
        g.db = DataStore(current_app.config.get("database_uri"))  # pylint: disable=assigning-non-slot
    return g.db
Пример #2
0
def get_db():
    """Get or initialize the request-scoped datastore instance

    Returns:
        DataStore: a request-scoped datastore instance
    """
    if 'db' not in g:
        g.db = DataStore(current_app.config.get('database_uri'))
    return g.db
Пример #3
0
def test_db():
    """Setup a test database fixture

    Yields:
        DataStore: a sqlite backed datastore with all test data
    """
    from comet_core.data_store import DataStore
    from tests.utils import get_all_test_messages

    data_store = DataStore("sqlite://")
    for event in get_all_test_messages(parsed=True):
        data_store.add_record(event.get_record())
    yield data_store
Пример #4
0
    def __init__(self, database_uri='sqlite://'):
        self.running = False
        self.data_store = DataStore(database_uri)

        self.inputs = list()
        self.instantiated_inputs = list()
        self.hydrators = dict()
        self.parsers = dict()
        self.routers = SourceTypeFunction()
        self.escalators = SourceTypeFunction()

        self.database_uri = database_uri
        self.batch_config = {
            'wait_for_more': timedelta(seconds=3),
            'max_wait': timedelta(seconds=4),
            'new_threshold': timedelta(days=7),
            'owner_reminder_cadence': timedelta(days=7),
            'escalation_time': timedelta(seconds=10),
            'escalation_reminder_cadence': timedelta(days=7)
        }
        self.specific_configs = {}
Пример #5
0
    def __init__(self, database_uri="sqlite://"):
        self.running = False
        self.data_store = DataStore(database_uri)

        self.inputs = list()
        self.instantiated_inputs = list()
        self.hydrators = dict()
        self.filters = dict()
        self.parsers = dict()
        self.routers = SourceTypeFunction()
        self.escalators = SourceTypeFunction()
        self.real_time_sources = list()
        self.real_time_config_providers = dict()

        self.database_uri = database_uri
        self.batch_config = {
            "communication_digest_mode": True,
            # By default (communication_digest_mode=True), all batch events will be grouped by an owner and source_type.
            # And email will look like:
            #  here are your X new issues, and by the way, you have these Y old ones.
            # In case of the non-digest mode,
            # the router will receive only these events that are new or need a reminder.
            "escalation_reminder_cadence": timedelta(days=7),
            # `escalation_reminder_cadence` defines how often to send escalation reminders
            "escalation_time": timedelta(seconds=10),
            # `escalation_time` defines how soon event should be escalated (it takes ignore_fingerprints into account)
            "max_wait": timedelta(seconds=4),
            # `max_wait` defines the amount of time to wait since the earliest event in an attempt to catch whole batch
            "new_threshold": timedelta(days=7),
            # `new_threshold` defines amount of time to wait since the latest report of the given fingerprint to assume
            # it as a regression of the detected issue
            "owner_reminder_cadence": timedelta(days=7),
            # `owner_reminder_cadence` defines how often to send reminders
            "wait_for_more": timedelta(seconds=3),
            # `wait_for_more` defines the amount of time to wait since the latest event
        }
        self.specific_configs = {}
Пример #6
0
    def __init__(self, database_uri="sqlite://"):
        self.running = False
        self.data_store = DataStore(database_uri)

        self.inputs = list()
        self.instantiated_inputs = list()
        self.hydrators = dict()
        self.filters = dict()
        self.parsers = dict()
        self.routers = SourceTypeFunction()
        self.escalators = SourceTypeFunction()
        self.real_time_sources = list()
        self.real_time_config_providers = dict()

        self.database_uri = database_uri
        self.batch_config = {
            "wait_for_more": timedelta(seconds=3),
            "max_wait": timedelta(seconds=4),
            "new_threshold": timedelta(days=7),
            "owner_reminder_cadence": timedelta(days=7),
            "escalation_time": timedelta(seconds=10),
            "escalation_reminder_cadence": timedelta(days=7),
        }
        self.specific_configs = {}
Пример #7
0
def data_store() -> DataStore:
    """Creates a SQLite backed datastore."""
    return DataStore("sqlite://")