Skip to content

Commit 478dc63

Browse files
committed
adapted the design docs
1 parent 7daa34b commit 478dc63

1 file changed

Lines changed: 23 additions & 26 deletions

File tree

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,6 @@ context.step("name", Type.class, supplier,
8585
.build());
8686
```
8787

88-
**Custom SerDes Interface:**
89-
```java
90-
public interface SerDes {
91-
String serialize(Object value);
92-
<T> T deserialize(String data, Class<T> type);
93-
<T> T deserialize(String data, TypeToken<T> typeToken);
94-
}
95-
```
96-
97-
**TypeToken and Type Erasure:**
98-
99-
Java's type erasure removes generic type parameters at runtime (`List<User>` becomes `List`). This is problematic for deserialization—Jackson needs the full type to reconstruct objects correctly.
100-
101-
`TypeToken<T>` solves this by capturing generic types at compile time. Creating `new TypeToken<List<User>>() {}` produces an anonymous subclass whose superclass type parameter is preserved in bytecode and accessible via reflection (`getGenericSuperclass()`).
102-
103-
The `SerDes` interface provides both `Class<T>` and `TypeToken<T>` overloads:
104-
- Use `Class<T>` for simple types: `String.class`, `User.class`
105-
- Use `TypeToken<T>` for parameterized types: `new TypeToken<List<User>>() {}`
106-
107-
**Custom RetryStrategy Interface:**
108-
```java
109-
@FunctionalInterface
110-
public interface RetryStrategy {
111-
RetryDecision makeRetryDecision(Throwable error, int attemptNumber);
112-
}
113-
```
11488
---
11589

11690
## Architecture
@@ -414,6 +388,29 @@ For testing, use `DurableConfig.builder().withDurableExecutionClient(localMemory
414388

415389
---
416390

391+
## Custom SerDes and TypeToken
392+
393+
**Custom SerDes Interface:**
394+
```java
395+
public interface SerDes {
396+
String serialize(Object value);
397+
<T> T deserialize(String data, Class<T> type);
398+
<T> T deserialize(String data, TypeToken<T> typeToken);
399+
}
400+
```
401+
402+
**TypeToken and Type Erasure:**
403+
404+
Java's type erasure removes generic type parameters at runtime (`List<User>` becomes `List`). This is problematic for deserialization—Jackson needs the full type to reconstruct objects correctly.
405+
406+
`TypeToken<T>` solves this by capturing generic types at compile time. Creating `new TypeToken<List<User>>() {}` produces an anonymous subclass whose superclass type parameter is preserved in bytecode and accessible via reflection (`getGenericSuperclass()`).
407+
408+
The `SerDes` interface provides both `Class<T>` and `TypeToken<T>` overloads:
409+
- Use `Class<T>` for simple types: `String.class`, `User.class`
410+
- Use `TypeToken<T>` for parameterized types: `new TypeToken<List<User>>() {}`
411+
412+
---
413+
417414
## Thread Coordination and Suspension Mechanism (Advanced)
418415

419416
The SDK uses a threaded execution model where the handler runs in a background thread, racing against a suspension future. This enables immediate suspension when operations need to pause execution (waits, retries), without waiting for the handler to complete naturally.

0 commit comments

Comments
 (0)