-
Notifications
You must be signed in to change notification settings - Fork 239
External Storage Integration: Lazy resolving references, general refactoring #3016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eee31a3
ca09b50
af36622
5ebc8ee
6cc2e4a
66f31c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,10 @@ | |
| import io.temporal.api.common.v1.Payloads; | ||
| import io.temporal.api.failure.v1.Failure; | ||
| import io.temporal.failure.DefaultFailureConverter; | ||
| import io.temporal.internal.payload.storage.ExternalStorageReferences; | ||
| import io.temporal.internal.payload.storage.ExternalStorageUnhandledReferenceException; | ||
| import io.temporal.payload.context.SerializationContext; | ||
| import io.temporal.payload.storage.ExternalStorage; | ||
| import java.lang.reflect.Type; | ||
| import java.util.*; | ||
| import javax.annotation.Nonnull; | ||
|
|
@@ -22,6 +25,7 @@ class PayloadAndFailureDataConverter implements DataConverter { | |
| volatile List<PayloadConverter> converters; | ||
| volatile Map<String, PayloadConverter> convertersMap; | ||
| volatile FailureConverter failureConverter; | ||
| volatile @Nullable ExternalStorage externalStorage; | ||
| private final @Nullable SerializationContext serializationContext; | ||
|
|
||
| public PayloadAndFailureDataConverter(@Nonnull List<PayloadConverter> converters) { | ||
|
|
@@ -71,6 +75,10 @@ public <T> T fromPayload(Payload payload, Class<T> valueClass, Type valueType) | |
| return (T) new RawValue(payload); | ||
| } | ||
|
|
||
| if (ExternalStorageReferences.isReference(payload)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really convinced this is necessary. If we forget to plumb through retrieval somewhere, then it should likely fail at deserialization time explaining that the ExternalStorageReference message couldn't be deserialized into the target type. I also don't think we should give customers something that they can handle and attempt to compensate for in their executions. |
||
| throw new ExternalStorageUnhandledReferenceException(); | ||
| } | ||
|
|
||
| try { | ||
| String encoding = | ||
| payload.getMetadataOrThrow(EncodingKeys.METADATA_ENCODING_KEY).toString(UTF_8); | ||
|
|
@@ -143,9 +151,18 @@ public Failure exceptionToFailure(@Nonnull Throwable throwable) { | |
| .exceptionToFailure(throwable, this); | ||
| } | ||
|
|
||
| @Override | ||
| @Nullable | ||
| public ExternalStorage getExternalStorage() { | ||
| return externalStorage; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nonnull DataConverter withContext(@Nonnull SerializationContext context) { | ||
| return new PayloadAndFailureDataConverter(converters, convertersMap, failureConverter, context); | ||
| PayloadAndFailureDataConverter copy = | ||
| new PayloadAndFailureDataConverter(converters, convertersMap, failureConverter, context); | ||
| copy.externalStorage = this.externalStorage; | ||
| return copy; | ||
| } | ||
|
|
||
| static Map<String, PayloadConverter> createConvertersMap(List<PayloadConverter> converters) { | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package io.temporal.internal.payload.storage; | ||
|
|
||
| import io.temporal.common.converter.DataConverterException; | ||
|
|
||
| /** | ||
| * Signals that a payload referenced in external storage needs to be retrieved, but external storage | ||
| * is not configured. Logs a TMPRL1105 error. | ||
| */ | ||
| public final class ExternalStorageNotConfiguredException extends DataConverterException { | ||
| public ExternalStorageNotConfiguredException() { | ||
| super( | ||
| "[TMPRL1105] Encountered a reference to a payload in external storage, but no external " | ||
| + "storage is configured to retrieve it. Configure external storage on the " | ||
| + "DataConverter with " | ||
| + "DefaultDataConverter.withExternalStorage(...) and provide a driver able to " | ||
| + "retrieve it."); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
External storage should not be on
DataConverterbut instead onWorkflowClientOptions. TheIDataConverterinstance is accessible from within the workflow context, where we do not want external storage be accessible, let alone executable.