Skip to content

factory

Top-level functions for custom list store creation.

create_custom_list_store(parsed_uri)

Create a MLTE custom list store instance.

Parameters:

Name Type Description Default
parsed_uri StoreURI

The URI for the store instance

required

Returns:

Type Description
CustomListStore

The store instance

Source code in mlte/store/custom_list/factory.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def create_custom_list_store(parsed_uri: StoreURI) -> CustomListStore:
    """
    Create a MLTE custom list store instance.
    :param parsed_uri: The URI for the store instance
    :return: The store instance
    """
    if parsed_uri.type == StoreType.REMOTE_HTTP:
        return HttpCustomListStore(uri=parsed_uri)
    elif parsed_uri.type == StoreType.LOCAL_MEMORY:
        return InMemoryCustomListStore(parsed_uri)
    elif parsed_uri.type == StoreType.LOCAL_FILESYSTEM:
        return FileSystemCustomListStore(parsed_uri)
    elif parsed_uri.type == StoreType.RELATIONAL_DB:
        # Import is here to avoid importing SQL libraries if they have not been installed.
        from mlte.store.custom_list.underlying.rdbs.store import (
            RDBCustomListStore,
        )

        return RDBCustomListStore(parsed_uri)
    else:
        raise Exception(
            f"Custom list store can't be created, unknown or unsupported URI type received for uri {parsed_uri}"
        )