temporalio.converter.ExternalStorage
class documentation

class ExternalStorage: (source)

View In Hierarchy

Configuration for external storage behavior.

Warning

This API is experimental.

def __post_init__(self): (source)

Validate drivers and build the internal name-keyed driver map.

Raises ValueError if no drivers are provided, if payload_size_threshold is less than zero, if more than one driver is registered without a driver_selector, or if any two drivers share the same name.

driver_selector: Callable[[StorageDriverSelectContext, Payload], StorageDriver | None] | None = (source)

Controls which driver stores a given payload. A callable that returns the driver instance to use, or None to leave the payload stored inline. The returned driver must be one of the instances registered in drivers.

Required when more than one driver is registered. When None and only one driver is registered, that driver is used for all store operations.

drivers: Sequence[StorageDriver] = (source)

Drivers available for storing and retrieving payloads. At least one driver must be provided. If more than one driver is registered, driver_selector must also be set.

Drivers in this list are looked up by StorageDriver.name during retrieval, so each driver must have a unique name.

payload_size_threshold: int = (source)

Minimum payload size in bytes before external storage is considered. Defaults to 256 KiB. Must be greater than or equal to zero.

def _record_metrics(count: int, size: int, start_time: float, driver_names: set[str]): (source)

Undocumented

def _decode_reference(self, payload: Payload) -> ExternalStorageReference | None: (source)

Decode an external storage reference from a payload.

def _get_driver_by_name(self, name: str) -> StorageDriver: (source)

Looks up a driver by name, raising ValueError if not found.

async def _retrieve_payload(self, payload: Payload) -> Payload: (source)

Undocumented

async def _retrieve_payload_sequence(self, payloads: Sequence[Payload]) -> list[Payload]: (source)

Undocumented

async def _retrieve_payloads(self, payloads: Payloads): (source)

Undocumented

def _select_driver(self, context: StorageDriverSelectContext, payload: Payload) -> StorageDriver | None: (source)

Returns the driver to use for this payload, or None to pass through.

async def _store_payload(self, payload: Payload) -> Payload: (source)

Undocumented

async def _store_payload_sequence(self, payloads: Sequence[Payload]) -> list[Payload]: (source)

Undocumented

async def _store_payloads(self, payloads: Payloads): (source)

Undocumented

def _validate_claim_length(self, claims: Sequence[StorageDriverClaim], expected: int, driver: StorageDriver): (source)

Undocumented

def _validate_payload_length(self, payloads: Sequence[Payload], expected: int, driver: StorageDriver): (source)

Undocumented

def _with_store_context(self, ctx: StorageDriverStoreContext) -> ExternalStorage: (source)

Return a copy of this instance with ctx bound as the store context.

_claim_converter: ClassVar[JSONProtoPayloadConverter] = (source)

Undocumented

Name-keyed index of drivers, built at construction time. Used for retrieval lookups.

_legacy_claim_converter: ClassVar[JSONPlainPayloadConverter] = (source)

Undocumented

Selector context derived from _store_context.

Store context bound to this instance via _with_store_context.