Large Payloads¶
Codec for handling payloads that exceed Temporal's size limit.
LargePayloadCodec¶
LargePayloadCodec
¶
LargePayloadCodec(
store: BlobStore,
*,
size_threshold: int = DEFAULT_SIZE_THRESHOLD,
prefix: str = "langgraph-temporal",
)
Bases: PayloadCodec
Temporal PayloadCodec that offloads large payloads to a blob store.
Payloads exceeding size_threshold bytes are stored in the blob store,
and replaced with a reference payload in Temporal's event history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
BlobStore
|
A |
required |
size_threshold
|
int
|
Payloads larger than this (in bytes) are offloaded. Defaults to 2MB. |
DEFAULT_SIZE_THRESHOLD
|
prefix
|
str
|
Key prefix for stored blobs. |
'langgraph-temporal'
|
Source code in langgraph/temporal/_codec.py
encode
async
¶
Encode payloads, offloading large ones to blob store.
Source code in langgraph/temporal/_codec.py
decode
async
¶
Decode payloads, fetching offloaded ones from blob store.
Source code in langgraph/temporal/_codec.py
BlobStore¶
BlobStore
¶
Bases: ABC
Abstract blob store for large payload offloading.
put
abstractmethod
async
¶
Store data and return a reference key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Unique key for the data. |
required |
data
|
bytes
|
Raw bytes to store. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The key under which the data was stored. |
Source code in langgraph/temporal/_codec.py
get
abstractmethod
async
¶
Retrieve data by reference key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key returned by |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The raw bytes. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the key is not found. |
delete
abstractmethod
async
¶
Delete data by reference key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to delete. |
required |