Class ExternalStorageDataConverter
java.lang.Object
io.temporal.internal.payload.storage.ExternalStorageDataConverter
- All Implemented Interfaces:
DataConverter
A
DataConverter that stores/retrieves payloads to/from external storage.
This is an internal class that is not exposed to users or workflow code. The intent is to use this data converter to consolidate extstore usage within the SDK.
-
Constructor Summary
ConstructorsConstructorDescriptionExternalStorageDataConverter(DataConverter delegate, ExternalStorageRunner externalStorage) -
Method Summary
Modifier and TypeMethodDescriptionio.temporal.api.failure.v1.FailureexceptionToFailure(Throwable throwable) Serialize an existing Throwable object into a Failure object.failureToException(io.temporal.api.failure.v1.Failure failure) Instantiate an appropriate Java Exception from a serialized Failure object.<T> TfromPayload(io.temporal.api.common.v1.Payload payload, Class<T> valueClass, Type valueType) <T> TfromPayloads(int index, Optional<io.temporal.api.common.v1.Payloads> content, Class<T> parameterType, Type genericParameterType) Implements conversion of a singlePayloadfrom the serializedPayloads.Object[]fromPayloads(Optional<io.temporal.api.common.v1.Payloads> content, Class<?>[] parameterTypes, Type[] genericParameterTypes) Implements conversion of the wholecontentPayloadsinto an array of values of different types.<T> Optional<io.temporal.api.common.v1.Payload> toPayload(T value) Optional<io.temporal.api.common.v1.Payloads> toPayloads(Object... values) Implements conversion of a list of values.withContext(SerializationContext context) A correct implementation of this interface should have a fully functional "contextless" implementation.withStorageTarget(StorageDriverTargetInfo storageTarget)
-
Constructor Details
-
ExternalStorageDataConverter
public ExternalStorageDataConverter(@Nonnull DataConverter delegate, @Nullable ExternalStorageRunner externalStorage)
-
-
Method Details
-
withStorageTarget
public ExternalStorageDataConverter withStorageTarget(@Nullable StorageDriverTargetInfo storageTarget) -
toPayload
public <T> Optional<io.temporal.api.common.v1.Payload> toPayload(T value) throws DataConverterException - Specified by:
toPayloadin interfaceDataConverter- Parameters:
value- value to convert- Returns:
- a
Payloadwhich is a protobuf message containing byte-array serialized representation ofvalue. Optional here is for legacy and backward compatibility reasons. This Optional is expected to always be filled. - Throws:
DataConverterException- if conversion fails
-
toPayloads
public Optional<io.temporal.api.common.v1.Payloads> toPayloads(Object... values) throws DataConverterException Description copied from interface:DataConverterImplements conversion of a list of values.- Specified by:
toPayloadsin interfaceDataConverter- Parameters:
values- Java values to convert to String.- Returns:
- converted value. Return empty Optional if values are empty.
- Throws:
DataConverterException- if conversion of the value passed as parameter failed for any reason.
-
fromPayload
public <T> T fromPayload(io.temporal.api.common.v1.Payload payload, Class<T> valueClass, Type valueType) throws DataConverterException - Specified by:
fromPayloadin interfaceDataConverter- Throws:
DataConverterException
-
fromPayloads
public <T> T fromPayloads(int index, Optional<io.temporal.api.common.v1.Payloads> content, Class<T> parameterType, Type genericParameterType) throws DataConverterException Description copied from interface:DataConverterImplements conversion of a singlePayloadfrom the serializedPayloads.- Specified by:
fromPayloadsin interfaceDataConverter- Parameters:
index- index of the value in the payloadscontent- serialized value to convert to Java objects.parameterType- type of the value stored in thecontentgenericParameterType- generic type of the value stored in thecontent- Returns:
- converted Java object
- Throws:
DataConverterException- if conversion of the data passed as parameter failed for any reason.
-
fromPayloads
public Object[] fromPayloads(Optional<io.temporal.api.common.v1.Payloads> content, Class<?>[] parameterTypes, Type[] genericParameterTypes) throws DataConverterException Description copied from interface:DataConverterImplements conversion of the wholecontentPayloadsinto an array of values of different types.Implementation note
This method is expected to return an array of the same length asparameterTypes. Ifcontenthas not enoughPayloadelements, this method provides default instances.- Specified by:
fromPayloadsin interfaceDataConverter- Parameters:
content- serialized value to convert to Java objects.parameterTypes- types of the values stored in the @code content}genericParameterTypes- generic types of the values stored in thecontent- Returns:
- array if converted Java objects
- Throws:
DataConverterException- if conversion of the data passed as parameter failed for any reason.
-
failureToException
@Nonnull public RuntimeException failureToException(@Nonnull io.temporal.api.failure.v1.Failure failure) Description copied from interface:DataConverterInstantiate an appropriate Java Exception from a serialized Failure object. The default implementation delegates the conversion process to an instance ofFailureConverter, using this data converter for payload decoding.- Specified by:
failureToExceptionin interfaceDataConverter- Parameters:
failure- Failure protobuf object to deserialize into an exception
-
exceptionToFailure
Description copied from interface:DataConverterSerialize an existing Throwable object into a Failure object. The default implementation delegates the conversion process to an instance ofFailureConverter, using this data converter for payload encoding.- Specified by:
exceptionToFailurein interfaceDataConverter- Parameters:
throwable- a Throwable object to serialize into a Failure protobuf object
-
withContext
Description copied from interface:DataConverterA correct implementation of this interface should have a fully functional "contextless" implementation. Temporal SDK will call this method when a knowledge of the context exists, butDataConvertercan be used directly by user code and sometimes SDK itself without any context.Note: this method is expected to be cheap and fast. Temporal SDK doesn't always cache the instances and may be calling this method very often. Users are responsible to make sure that this method doesn't recreate expensive objects like Jackson's
ObjectMapperon every call.- Specified by:
withContextin interfaceDataConverter- Parameters:
context- provides information to the data converter about the abstraction the data belongs to- Returns:
- an instance of DataConverter that may use the provided
contextfor serialization - See Also:
-