Skip to content

Commit 633d129

Browse files
committed
Documentation for data converter
1 parent 1257064 commit 633d129

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Data Converter
2+
3+
## Introduction
4+
A Data Converter in Cadence is responsible for serializing and deserializing data exchanged between workflows, activities, and the Cadence service. It ensures that data is correctly encoded and decoded during communication.
5+
6+
## Use Cases
7+
- **Custom Serialization**: Implement custom serialization logic for complex data types.
8+
- **Data Compression**: Reduce payload size for efficient data transfer.
9+
- **Encryption**: Secure sensitive data during transmission.
10+
11+
## Examples
12+
13+
### Default Data Converter
14+
Cadence provides a default data converter that uses JSON for serialization. It is suitable for most use cases.
15+
16+
```typescript
17+
import { DefaultDataConverter } from '@temporalio/common';
18+
19+
const dataConverter = new DefaultDataConverter();
20+
```
21+
22+
### Custom Data Converter
23+
You can implement a custom data converter by extending the `DataConverter` interface.
24+
25+
```typescript
26+
import { DataConverter } from '@temporalio/common';
27+
28+
class CustomDataConverter implements DataConverter {
29+
toPayload(value: any): Uint8Array {
30+
// Custom serialization logic
31+
}
32+
33+
fromPayload(payload: Uint8Array): any {
34+
// Custom deserialization logic
35+
}
36+
}
37+
```
38+
39+
### References
40+
For more examples and detailed implementations, refer to the Cadence samples repository:
41+
- [Data Converter Recipe](https://github.com/cadence-workflow/cadence-samples/tree/master/cmd/samples/recipes/dataconverter)
42+
43+
## Conclusion
44+
Data Converters are a powerful feature in Cadence that allow developers to customize how data is handled during workflow execution. By leveraging custom converters, you can optimize performance and ensure data security.

sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const sidebars: SidebarsConfig = {
6161
{ type: 'doc', id: 'concepts/cross-dc-replication' },
6262
{ type: 'doc', id: 'concepts/search-workflows' },
6363
{ type: 'doc', id: 'concepts/http-api' },
64+
{ type: 'doc', id: 'concepts/data-converter' },
6465
],
6566
},
6667
{

0 commit comments

Comments
 (0)