Skip to main content

AliasResolver

Class for handling aliases.

The purpose of this is class is to ensure that alias storages are created with correct id. This is achieved by using default kvs as a storage for global mapping of aliases to storage ids. Same mapping is also kept in memory to avoid unnecessary calls to API and also have limited support of alias storages when not running on Apify platform. When on Apify platform, the storages created with alias are accessible by the same alias even after migration or reboot.

Index

Methods

__aenter__

  • Context manager to prevent race condition in alias creation.


    Returns AliasResolver

__aexit__

  • async __aexit__(exc_type, exc_value, exc_traceback): None
  • Parameters

    • exc_type: type[BaseException] | None
    • exc_value: BaseException | None
    • exc_traceback: TracebackType | None

    Returns None

__init__

  • __init__(storage_type, alias, configuration): None
  • Parameters

    • storage_type: type[(Dataset | KeyValueStore) | RequestQueue]
    • alias: str
    • configuration: Configuration

    Returns None

resolve_id

  • async resolve_id(): str | None
  • Get id of the aliased storage.

    Either locate the id in the in-memory mapping or create the new storage.


    Returns str | None

store_mapping

  • async store_mapping(storage_id): None
  • Add alias and related storage id to the mapping in default kvs and local in-memory mapping.


    Parameters

    • storage_id: str

    Returns None