💥 Use ExternalStorageReference protobuf message for payload references#2311
💥 Use ExternalStorageReference protobuf message for payload references#2311jmaeagle99 wants to merge 1 commit intotemporalio:mainfrom
Conversation
0d127c6 to
f9977e3
Compare
f9977e3 to
bb13a69
Compare
|
For reference, this is the API PR: temporalio/api#772 |
| type storageReference struct { | ||
| // legacyStorageReference is the old wire format retained for backward compatibility | ||
| // with payloads written by earlier prerelease SDK versions. | ||
| type legacyStorageReference struct { |
There was a problem hiding this comment.
Why do we want/need to maintain the earlier prerelease SDK version? Since it's still in prerelease, should we just make the breaking change here, so we only need to support one format?
There was a problem hiding this comment.
I guess we maybe don't want to completely break previous workflows, but do we plan on deprecating this legacy stuff before we hit public preview/GA?
There was a problem hiding this comment.
We don't want to immediately break anyone who used the prerelease bits. We'll remove before GA.
| // payloads that are storage references rather than actual data. | ||
| const metadataEncodingStorageRef = "json/external-storage-reference" | ||
| // metadataMessageType is the key used in payload metadata to identify the proto | ||
| // message type. Mirrors converter.MetadataMessageType without importing converter package. |
There was a problem hiding this comment.
nit: Do we want to add a mirroring comment to converter.MetadataMessageType that it matches this new value? Same question for metadataEncodingProtoJSON
| ] | ||
| }` | ||
|
|
||
| externalStorageReferenceMessageType = string((*sdkpb.ExternalStorageReference)(nil).ProtoReflect().Descriptor().FullName()) |
There was a problem hiding this comment.
Is this line needed? Don't we already set this value in internal_extstore.go?
| // IsStorageReference reports whether p is an external-storage reference payload | ||
| // (i.e. its encoding metadata equals the internal storage-reference marker). | ||
| // IsStorageReference reports whether p is an external-storage reference payload. | ||
| // It recognises both the current protojson format (encoding=json/protobuf, |
There was a problem hiding this comment.
nit: recognises is the british form of recognizes? Not sure we use British spelling elsewhere in the SDK. I know we use Canadian forms of words (i.e. Behaviour), but not aware of any british spelling, haha
| // It recognises both the current protojson format (encoding=json/protobuf, | |
| // It recognizes both the current protojson format (encoding=json/protobuf, |
| @@ -0,0 +1,39 @@ | |||
| # internal/temporalapi | |||
There was a problem hiding this comment.
Any reason we need this over waiting for an API release to ingest the changes from there?
|
|
||
| // metadataEncodingProtoJSON is the standard protojson encoding value, shared with | ||
| // ProtoJSONPayloadConverter. Mirrors converter.MetadataEncodingProtoJSON. | ||
| const metadataEncodingProtoJSON = "json/protobuf" |
There was a problem hiding this comment.
technically this is breaking if we use an old SDK to read the new deployment format for a rolling deployment. A safer pattern would be to introduce the new format but continue to use the old, then a version later switch to the new format by default. But I assume we don't have time for this multi-release rollout. I'm fine without it, but not sure if we want to add a 💥 . It's a bit of an edge case
There was a problem hiding this comment.
Added boom to title
| externalStorageReferenceMessageType = string((*sdkpb.ExternalStorageReference)(nil).ProtoReflect().Descriptor().FullName()) | ||
|
|
||
| protoMarshalOptions = protojson.MarshalOptions{} | ||
| protoUnmarshalOptions = protojson.UnmarshalOptions{} |
There was a problem hiding this comment.
Do we want to have DiscardUnknown: true? For if an older SDK version tries to read a payload from a new SDK that added a new field to ExternalStorageReference
https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson#UnmarshalOptions
There was a problem hiding this comment.
Wouldn't we have had to add that option to the plain JSON converter in the old SDK though to work with the scenario that you outlined?
| // TestClaimDeserialization_OtherSdk_ProtoJson verifies that a full proto-JSON | ||
| // payload produced by another language SDK (e.g. Python) is correctly parsed by | ||
| // the Go SDK's payloadToStorageReference function. | ||
| func TestClaimDeserialization_OtherSdk_ProtoJson(t *testing.T) { |
There was a problem hiding this comment.
JSON in ProtoJson should be all caps, same with PlainJson
What was changed
Why?
Checklist