Merge pull request #1302 from aquamme/patch-2

Minor fixes for sdk-serialization.md
This commit is contained in:
Ori Zohar 2021-03-12 11:32:50 -08:00 committed by GitHub
commit 7a2f3b25fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -14,7 +14,7 @@ An SDK for Dapr should provide serialization for two use cases. First, for API o
```java
DaprClient client = (new DaprClientBuilder()).build();
client.invokeService(Verb.POST, "myappid", "saySomething", "My Message", null).block();
client.invokeService("myappid", "saySomething", "My Message", HttpExtension.POST).block();
```
In the example above, the app will receive a `POST` request for the `saySomething` method with the request payload as `"My Message"` - quoted since the serializer will serialize the input String to JSON.
@ -139,7 +139,7 @@ redis-cli MGET "ActorStateIT_StatefulActorService||StatefulActorTest||1581130928
{"value":"My data value."}
```
3. Custom serializers must serialize object to `byte[]`.
4. Custom serializers must deserilize `byte[]` to object.
4. Custom serializers must deserialize `byte[]` to object.
5. When user provides a custom serializer, it should be transferred or persisted as `byte[]`. When persisting, also encode as Base64 string. This is done natively by most JSON libraries.
```bash
redis-cli MGET "ActorStateIT_StatefulActorService||StatefulActorTest||1581130928192||message
@ -149,6 +149,5 @@ redis-cli MGET "ActorStateIT_StatefulActorService||StatefulActorTest||1581130928
redis-cli MGET "ActorStateIT_StatefulActorService||StatefulActorTest||1581130928192||mydata
"eyJ2YWx1ZSI6Ik15IGRhdGEgdmFsdWUuIn0="
```
6. When serializing a object that is a `byte[]`, the serializer should just pass it through since `byte[]` shoould be already handled internally in the SDK. The same happens when deserializing to `byte[]`.
*As of now, the [Java SDK](https://github.com/dapr/java-sdk/) is the only Dapr SDK that implements this specification. In the near future, other SDKs will also implement the same.*
*As of now, the [Java SDK](https://github.com/dapr/java-sdk/) is the only Dapr SDK that implements this specification. In the near future, other SDKs will also implement the same.*