Repository navigation
Add transfer type converters #3073
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
base: main
Are you sure you want to change the base?
Changes from all commits
583962b
3b2bbcf
1ff8771
f50ffdd
3cea60a
1c5fe58
452f46c
6fec25d
37411ad
14e91b5
4849ec0
8be2665
030d5eb
58bd31b
0b82638
49b483b
96eb2de
aa6daac
184a740
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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package io.temporal.common.converter; | ||
|
|
||
| import io.temporal.common.Experimental; | ||
| import java.lang.reflect.Type; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Converts a model to and from a representation handled by the configured {@link DataConverter}. | ||
| * | ||
| * <p>Conversion is applied only to top-level values. The {@code valueType} arguments contain the | ||
| * complete requested model type, including generic arguments. Implementations must be stateless and | ||
| * thread-safe because converter instances are cached. | ||
| * | ||
| * @param <T> annotated model type converted to and from its transfer representation | ||
| */ | ||
| @Experimental | ||
| public interface TransferTypeConverter<T> { | ||
| /** | ||
| * Returns the type used to serialize a model value. | ||
| * | ||
| * @param valueType complete declared model type, including generic arguments | ||
| * @return non-null transfer type | ||
| */ | ||
| Type getTransferType(Type valueType); | ||
|
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. Why do we need to take a
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. Looking more it seems like we need this for generic resolution that will be needed for worker callbacks |
||
|
|
||
| /** Converts a model value to its transfer representation, which may be null. */ | ||
| @Nullable | ||
| Object toTransferType(T value); | ||
|
|
||
| /** | ||
| * Reconstructs a model value from its transfer representation. | ||
| * | ||
| * @param value transfer representation decoded by the configured data converter, which may be | ||
| * null | ||
| * @param valueType complete requested model type, including generic arguments | ||
| */ | ||
| T fromTransferType(@Nullable Object value, Type valueType); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package io.temporal.common.converter; | ||
|
|
||
| import io.temporal.common.Experimental; | ||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Associates a model class with the converter used to produce its transfer representation. | ||
| * | ||
| * <p>The annotation is read only from the exact declared class and is not inherited. Conversion is | ||
| * applied to top-level values within a transfer-aware data converter. The configured {@link | ||
| * DataConverter} remains responsible for serialization, payload codecs, and wire encoding. | ||
| * | ||
| * <p>The converter and its enclosing classes must be public. The converter must be concrete and | ||
| * have a public no-argument constructor. Converter instances are cached, so implementations must be | ||
| * stateless and thread-safe. | ||
| */ | ||
| @Experimental | ||
| @Documented | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target(ElementType.TYPE) | ||
| public @interface TransferTypeConvertible { | ||
| /** The converter associated with the annotated model class. */ | ||
| @SuppressWarnings("rawtypes") | ||
| Class<? extends TransferTypeConverter> value(); | ||
| } |
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.
WE can move this above 108 so we have a builder already