File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222from aiohttp import web
2323from google .protobuf import json_format
2424from temporalio .api .common .v1 import Payload , Payloads
25+ from temporalio .api .sdk .v1 import ExternalStorageReference
2526from temporalio .converter import ExternalStorage , PayloadCodec
2627
28+ _REFERENCE_MESSAGE_TYPE = ExternalStorageReference .DESCRIPTOR .full_name .encode ()
2729
28- def _is_storage_reference (payload : Payload ) -> bool :
29- """A payload is an external-storage reference iff it carries external_payloads metadata.
3030
31- When the SDK offloads a payload to external storage it replaces the
32- in-band bytes with a small protobuf "claim check" — the ``external_payloads``
33- repeated field is the marker the SDK uses to recognize it on the way back .
31+ def _is_storage_reference ( payload : Payload ) -> bool :
32+ """A payload is an external-storage reference iff its metadata identifies
33+ it as a serialized :class:`ExternalStorageReference` claim check .
3434 """
35- return len (payload .external_payloads ) > 0
35+ return (
36+ payload .metadata .get ("encoding" ) == b"json/protobuf"
37+ and payload .metadata .get ("messageType" ) == _REFERENCE_MESSAGE_TYPE
38+ )
3639
3740
3841def payload_routes (
You can’t perform that action at this time.
0 commit comments