Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions external_storage/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@
from aiohttp import web
from google.protobuf import json_format
from temporalio.api.common.v1 import Payload, Payloads
from temporalio.api.sdk.v1 import ExternalStorageReference
from temporalio.converter import ExternalStorage, PayloadCodec

_REFERENCE_MESSAGE_TYPE = ExternalStorageReference.DESCRIPTOR.full_name.encode()

def _is_storage_reference(payload: Payload) -> bool:
"""A payload is an external-storage reference iff it carries external_payloads metadata.

When the SDK offloads a payload to external storage it replaces the
in-band bytes with a small protobuf "claim check" — the ``external_payloads``
repeated field is the marker the SDK uses to recognize it on the way back.
def _is_storage_reference(payload: Payload) -> bool:
"""A payload is an external-storage reference iff its metadata identifies
it as a serialized :class:`ExternalStorageReference` claim check.
"""
return len(payload.external_payloads) > 0
return (
payload.metadata.get("encoding") == b"json/protobuf"
and payload.metadata.get("messageType") == _REFERENCE_MESSAGE_TYPE
)
Comment thread
jmaeagle99 marked this conversation as resolved.


def payload_routes(
Expand Down
Loading