Added contents based on the review comment

Signed-off-by: Amulya Varote <amulyavarote@QTM-SWATHIKIL-1.redmond.corp.microsoft.com>
Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
This commit is contained in:
Amulya Varote 2022-03-11 11:23:17 -08:00 committed by Amulya Varote
parent 183b21b61a
commit d0b6025b63
4 changed files with 49 additions and 6 deletions

View File

@ -16,10 +16,16 @@ ActorA -> Actor B -> Actor A
With reentrancy, there can be more complex actor calls without sacrificing the single-threaded behavior of virtual actors.
The `maxStackDepth` parameter gets a value that controls how many reentrant calls be made to the same actor.
## Enable Actor Reentrancy with Actor Configuration
The actor that will be reentrant must provide the appropriate configuration to use reentrancy. This is done by the actor's endpoint for `GET /dapr/config`, similar to other actor configuration elements. Here is a snipet of an actor written in Golang providing the configuration:
{{< tabs Go Dotnet Python JavaScript >}}
{{% codetab %}}
```go
type daprConfig struct {
Entities []string `json:"entities,omitempty"`
@ -49,7 +55,7 @@ func configHandler(w http.ResponseWriter, r *http.Request) {
### Handling reentrant requests
The key to a reentrant request is the `Dapr-Reentrancy-Id` header. The value of this header is used to match requests to their call chain and allow them to bypass the actor's lock.
The header is generated by the Dapr runtime for any actor request that has a reentrant config specified. Once it is generated, it is used to lock the actor and must be passed to all future requests. Below is a snippet of code from an actor handling this is Golang:
The header is generated by the Dapr runtime for any actor request that has a reentrant config specified. Once it is generated, it is used to lock the actor and must be passed to all future requests. Below are the snippets of code from an actor handling this:
```go
func reentrantCallHandler(w http.ResponseWriter, r *http.Request) {
@ -71,4 +77,35 @@ func reentrantCallHandler(w http.ResponseWriter, r *http.Request) {
}
```
Currently, no SDK supports actor reentrancy. In the future, the method for handling the reentrancy id may be different based on the SDK that is being used.
{{% /codetab %}}
{{% codetab %}}
```csharp
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<BankService>();
services.AddActors(options =>
{
options.Actors.RegisterActor<DemoActor>();
options.ReentrancyConfig = new Dapr.Actors.ActorReentrancyConfig()
{
Enabled = true,
MaxStackDepth = 32,
};
});
}
}
```
{{% /codetab %}}
{{< /tabs >}}
Watch this [video](https://youtu.be/QADHQ5v-gww?list=PLcip_LgkYwzuF-OV6zKRADoiBvUvGhkao&t=674) on how to use actor reentrancy.
<div class="embed-responsive embed-responsive-16by9">
<iframe width="560" height="315" src="https://youtu.be/QADHQ5v-gww?list=PLcip_LgkYwzuF-OV6zKRADoiBvUvGhkao&t=674" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>

View File

@ -84,4 +84,5 @@ To rotate a key, change the `primaryEncryptionKey` to point to a secret containi
## Related links
- [Security overview]({{< ref "security-concept.md" >}})
- [State store query API implementation guide](https://github.com/dapr/components-contrib/blob/master/state/Readme.md#implementing-state-query-api)
- [State store query API implementation guide](https://github.com/dapr/components-contrib/blob/master/state/Readme.md#implementing-state-query-api)
- [State store components]({{< ref "supported-state-stores.md" >}})

View File

@ -11,8 +11,6 @@ Preview features in Dapr are considered experimental when they are first release
## Current preview features
| Feature | Description | Setting | Documentation |
| ---------- |-------------|---------|---------------|
| **Actor reentrancy** | Enables actors to be called multiple times in the same call chain allowing call backs between actors. | `Actor.Reentrancy` | [Actor reentrancy]({{<ref actor-reentrancy>}}) |
| **Partition actor reminders** | Allows actor reminders to be partitioned across multiple keys in the underlying statestore in order to improve scale and performance. | `Actor.TypeMetadata` | [How-To: Partition Actor Reminders]({{< ref "howto-actors.md#partitioning-reminders" >}}) |
| **State store encryption** | Enables automatic client side encryption for state stores | `State.Encryption` | [How-To: Encrypt application state]({{<ref howto-encrypt-state>}}) |
| **Pub/Sub routing** | Allow the use of expressions to route cloud events to different URIs/paths and event handlers in your application. | `PubSub.Routing` | [How-To: Publish a message and subscribe to a topic]({{<ref howto-route-messages>}}) |
| **ARM64 Mac Support** | Dapr CLI, sidecar, and Dashboard are now natively compiled for ARM64 Macs, along with Dapr CLI installation via Homebrew. | N/A | [Install the Dapr CLI]({{<ref install-dapr-cli>}}) |

View File

@ -461,6 +461,9 @@ actorIdleTimeout | Specifies how long to wait before deactivating an idle actor.
actorScanInterval | A duration which specifies how often to scan for actors to deactivate idle actors. Actors that have been idle longer than the actorIdleTimeout will be deactivated.
drainOngoingCallTimeout | A duration used when in the process of draining rebalanced actors. This specifies how long to wait for the current active actor method to finish. If there is no current actor method call, this is ignored.
drainRebalancedActors | A bool. If true, Dapr will wait for `drainOngoingCallTimeout` to allow a current actor call to complete before trying to deactivate an actor. If false, do not wait.
reentrancy | A configuration object that holds the options for Actor Reentrancy
enabled | A flag that is needed to enable the reentrancy.
maxStackDepth | A value that controls how many reentrant calls be made to the same actor.
```json
{
@ -468,7 +471,11 @@ drainRebalancedActors | A bool. If true, Dapr will wait for `drainOngoingCallTi
"actorIdleTimeout": "1h",
"actorScanInterval": "30s",
"drainOngoingCallTimeout": "30s",
"drainRebalancedActors": true
"drainRebalancedActors": true,
"reentrancy": {
"enabled": true,
"maxStackDepth": 32
}
}
```