-
Notifications
You must be signed in to change notification settings - Fork 748
Added .NET SDK examples to serialization document #4596
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: v1.15
Are you sure you want to change the base?
Conversation
Signed-off-by: Whit Waldo <[email protected]>
Stale PR, paging all reviewers |
Stale PR, paging all reviewers |
Stale PR, paging all reviewers |
@alicejgibbons Any chance you could review this? |
Updated formatting and grammar Signed-off-by: Mark Fussell <[email protected]>
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.
LGTM but will also let @alicejgibbons comment
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.
Thanks Whit, big improvement but just a couple small things.
@@ -8,16 +8,40 @@ aliases: | |||
- '/developing-applications/sdks/serialization/' | |||
--- | |||
|
|||
An SDK for Dapr should provide serialization for two use cases. First, for API objects sent through request and response payloads. Second, for objects to be persisted. For both these use cases, a default serialization is provided. In the Java SDK, it is the [DefaultObjectSerializer](https://dapr.github.io/java-sdk/io/dapr/serializer/DefaultObjectSerializer.html) class, providing JSON serialization. | |||
An SDK for Dapr should provide serialization for two use cases. First, for API objects sent through request and response payloads. Second, for objects to be persisted. For both these use cases, a default serialization is provided. |
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.
An SDK for Dapr should provide serialization for two use cases. First, for API objects sent through request and response payloads. Second, for objects to be persisted. For both these use cases, a default serialization is provided. | |
Dapr SDKs provide serialization for two use cases. First, for API objects sent through request and response payloads. Second, for objects to be persisted. For both of these cases, a default serialization method is provided in each language SDK. |
|
||
| Language SDK | Default Serializer | | ||
|------------------------------|------------------------------------------------------------------------------------------------------------| | ||
| [.NET]({{< ref dotnet >}}) | DataContracts for remoted actors, System.Text.Json otherwise | | |
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.
| [.NET]({{< ref dotnet >}}) | DataContracts for remoted actors, System.Text.Json otherwise | | | |
| [.NET]({{< ref dotnet >}}) | [System.Text.Json](https://www.nuget.org/packages/system.text.json/) and [DataContracts ](https://www.nuget.org/packages/LogicBuilder.DataContracts) for remoted actors, | | |
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.
@WhitWaldo would it make sense to link the remoted actors text to this page? https://docs.dapr.io/developing-applications/sdks/dotnet/dotnet-actors/dotnet-actors-serialization/#strongly-typed-dapr-actor-client
Also lmk if i linked the wrong nuget to data contracts
|------------------------------|------------------------------------------------------------------------------------------------------------| | ||
| [.NET]({{< ref dotnet >}}) | DataContracts for remoted actors, System.Text.Json otherwise | | | ||
| [Java]({{< ref java >}}) | [DefaultObjectSerializer](https://dapr.github.io/java-sdk/io/dapr/serializer/DefaultObjectSerializer.html) for JSON serialization| | ||
| [JavaScript]({{< ref js >}}) | JSON | |
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.
| [JavaScript]({{< ref js >}}) | JSON | | |
| [JavaScript]({{< ref js >}}) | [JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) | |
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. | ||
{{% /codetab %}} | ||
|
||
In the example above, the app receives a `POST` request for the `saySomething` method with the request payload as |
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.
In the example above, the app receives a `POST` request for the `saySomething` method with the request payload as | |
In the example above, the app `myappid` receives a `POST` request for the `saySomething` method with the request payload as |
|
||
<!-- Java --> | ||
{{% codetab %}} | ||
|
||
```java | ||
DaprClient client = (new DaprClientBuilder()).build(); | ||
client.invokeService("myappid", "saySomething", "My Message", HttpExtension.POST).block(); |
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.
client.invokeService("myappid", "saySomething", "My Message", HttpExtension.POST).block(); | |
client.invokeMethod("myappid", "saySomething", "My Message", HttpExtension.POST).block(); |
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.
Looking at the newer java examples we are using invokeMethod
not invokeService
.
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.
@cicoyle can you confirm that this is the correct example we should be giving in the docs.
```csharp | ||
using var client = (new DaprClientBuilder()).Build(); | ||
await client.InvokeBindingAsync("sample", "My Message"); | ||
``` |
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.
Input binding example? @WhitWaldo
It should print: | ||
``` | ||
My Message | ||
``` | ||
|
||
## Actor Method invocation | ||
Object serialization and deserialization for invocation of Actor's methods are same as for the service method invocation, the only difference is that the application does not need to deserialize the request or serialize the response since it is all done transparently by the SDK. | ||
Object serialization and deserialization for invocation of Actor's methods are same as for the service method invocation, |
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.
Object serialization and deserialization for invocation of Actor's methods are same as for the service method invocation, | |
Object serialization and deserialization for Actor method invocation are same as for the service method invocation, |
the only difference is that the application does not need to deserialize the request or serialize the response since it | ||
is all done transparently by the SDK. | ||
|
||
For an Actor's methods, the SDK only supports methods with zero or one parameter. |
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.
For an Actor's methods, the SDK only supports methods with zero or one parameter. | |
For Actor methods, the SDK only supports methods with zero or one parameter. |
|
||
{{< tabs ".NET" "Java" >}} | ||
|
||
The .NET SDK supports two different serialization types based on whether you're using the strongly-typed (DataContracts) |
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.
The .NET SDK supports two different serialization types based on whether you're using the strongly-typed (DataContracts) | |
The .NET SDK supports two different serialization types based on whether you're using strongly-typed (DataContracts) |
{{% /codetab %}} | ||
|
||
<!-- Java --> | ||
{{% codetab %}} |
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.
I also don't think that this invokeActorMethod is correct anymore (unless you're using springboot?). @cicoyle can you take a peek at this actors example?
Thank you for helping make the Dapr documentation better!
Please follow this checklist before submitting:
In addition, please fill out the following to help reviewers understand this pull request:
Description
The SDK serialization page claimed that only Java uses JSON serialization. To my knowledge, that's not accurate at all - all of the languages use JSON, though there have been recent requests for other serialization approaches. Regardless... while supposedly addressing serialization requirements across the solution, it only provided Java-specific examples. This PR adds .NET examples that are current (for now) to the 1.16 release.
Issue reference
Please reference the issue this PR will close: #4595