From 998c0a79d17c3b9d5480c24a565f81ee8e8be0bc Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Thu, 20 May 2021 09:59:43 -0700 Subject: [PATCH 1/8] Actor Runtime Configuration Docs Addresses #1470 --- .../building-blocks/actors/howto-actors.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index fe459cd013e..4a03a84e6b1 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -129,3 +129,16 @@ DELETE http://localhost:3500/v1.0/actors///reminders/ ``` Refer [api spec]({{< ref "actors_api.md#invoke-reminder" >}}) for more details. + +## Actor Runtime Configuration + +You can configure the Dapr Actors runtime configuration to modify the default runtime behavior. + +### Current defaults +- `actorIdleTimeout` The timeout before deactivating an idle actor. Checks for timeouts occur every `actorScanInterval` interval. **Default: 60 minutes** +- `actorScanInterval` The duration which specifies how often to scan for actors to deactivate idle actors. Actors that have been idle longer than actor_idle_timeout will be deactivated. **Default: 30 seconds** +- `drainOngoingCallTimeout` The duration when in the process of draining rebalanced actors. This specifies the timeout for the current active actor method to finish. If there is no current actor method call, this is ignored. **Default: 60 seconds** +- `drainRebalancedActors` If true, Dapr will wait for `drainOngoingCallTimeout` duration to allow a current actor call to complete before trying to deactivate an actor. **Default: true** +- `reentrancy (ActorReentrancyConfig)` Configure the reentrancy behavior for an actor. If not provided, reentrancy is diabled. **Default: disabled** + +Refer to the [Dapr SDKs]({{< ref "developing-applications/sdks/#sdk-languages" >}}) for more details. From 0842ddd4c8d57445323830f7e6d58ddd5f3d31b1 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 24 May 2021 09:54:45 -0700 Subject: [PATCH 2/8] Update daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md Co-authored-by: Aaron Crawfis --- .../building-blocks/actors/howto-actors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index 4a03a84e6b1..0c846a49919 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -134,7 +134,7 @@ Refer [api spec]({{< ref "actors_api.md#invoke-reminder" >}}) for more details. You can configure the Dapr Actors runtime configuration to modify the default runtime behavior. -### Current defaults +### Configuration parameters - `actorIdleTimeout` The timeout before deactivating an idle actor. Checks for timeouts occur every `actorScanInterval` interval. **Default: 60 minutes** - `actorScanInterval` The duration which specifies how often to scan for actors to deactivate idle actors. Actors that have been idle longer than actor_idle_timeout will be deactivated. **Default: 30 seconds** - `drainOngoingCallTimeout` The duration when in the process of draining rebalanced actors. This specifies the timeout for the current active actor method to finish. If there is no current actor method call, this is ignored. **Default: 60 seconds** From 98e24163e35e75cd7003c40dcfe03fe304585a00 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Mon, 24 May 2021 09:55:05 -0700 Subject: [PATCH 3/8] Update daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md Co-authored-by: Aaron Crawfis --- .../building-blocks/actors/howto-actors.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index 0c846a49919..273f639586b 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -135,10 +135,10 @@ Refer [api spec]({{< ref "actors_api.md#invoke-reminder" >}}) for more details. You can configure the Dapr Actors runtime configuration to modify the default runtime behavior. ### Configuration parameters -- `actorIdleTimeout` The timeout before deactivating an idle actor. Checks for timeouts occur every `actorScanInterval` interval. **Default: 60 minutes** -- `actorScanInterval` The duration which specifies how often to scan for actors to deactivate idle actors. Actors that have been idle longer than actor_idle_timeout will be deactivated. **Default: 30 seconds** -- `drainOngoingCallTimeout` The duration when in the process of draining rebalanced actors. This specifies the timeout for the current active actor method to finish. If there is no current actor method call, this is ignored. **Default: 60 seconds** -- `drainRebalancedActors` If true, Dapr will wait for `drainOngoingCallTimeout` duration to allow a current actor call to complete before trying to deactivate an actor. **Default: true** -- `reentrancy (ActorReentrancyConfig)` Configure the reentrancy behavior for an actor. If not provided, reentrancy is diabled. **Default: disabled** +- `actorIdleTimeout` - The timeout before deactivating an idle actor. Checks for timeouts occur every `actorScanInterval` interval. **Default: 60 minutes** +- `actorScanInterval` - The duration which specifies how often to scan for actors to deactivate idle actors. Actors that have been idle longer than actor_idle_timeout will be deactivated. **Default: 30 seconds** +- `drainOngoingCallTimeout` - The duration when in the process of draining rebalanced actors. This specifies the timeout for the current active actor method to finish. If there is no current actor method call, this is ignored. **Default: 60 seconds** +- `drainRebalancedActors` - If true, Dapr will wait for `drainOngoingCallTimeout` duration to allow a current actor call to complete before trying to deactivate an actor. **Default: true** +- `reentrancy` (ActorReentrancyConfig) - Configure the reentrancy behavior for an actor. If not provided, reentrancy is diabled. **Default: disabled** Refer to the [Dapr SDKs]({{< ref "developing-applications/sdks/#sdk-languages" >}}) for more details. From f5e776353363abd90ef5196c3f35632bd8de737a Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Thu, 3 Jun 2021 17:54:03 -0700 Subject: [PATCH 4/8] add configuration examples --- .../building-blocks/actors/howto-actors.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index 273f639586b..8ac553af8f2 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -141,4 +141,49 @@ You can configure the Dapr Actors runtime configuration to modify the default ru - `drainRebalancedActors` - If true, Dapr will wait for `drainOngoingCallTimeout` duration to allow a current actor call to complete before trying to deactivate an actor. **Default: true** - `reentrancy` (ActorReentrancyConfig) - Configure the reentrancy behavior for an actor. If not provided, reentrancy is diabled. **Default: disabled** +{{< tabs Java .Net Python>}} + +{{% codetab %}} +```java + +// import io.dapr.actors.runtime.ActorRuntime; +// import java.time.Duration; + +ActorRuntime.getInstance().getConfig().setActorIdleTimeout(Duration.ofMinutes(60)); +ActorRuntime.getInstance().getConfig().setActorScanInterval(Duration.ofSeconds(30)); +ActorRuntime.getInstance().getConfig().setDrainOngoingCallTimeout(Duration.ofSeconds(60)); +ActorRuntime.getInstance().getConfig().setDrainBalancedActors(true); +ActorRuntime.getInstance().getConfig().setActorReentrancyConfig(false, null); +``` + +See [this example](https://github.com/dapr/java-sdk/blob/master/examples/src/main/java/io/dapr/examples/actors/DemoActorService.java) +{{% /codetab %}} + +{{% codetab %}} +```dotnet + +TBD +``` +{{% /codetab %}} + +{{% codetab %}} +```python + +from datetime import timedelta +from dapr.actor.runtime.config import ActorRuntimeConfig, ActorReentrancyConfig + +ActorRuntime.set_actor_config( + ActorRuntimeConfig( + actor_idle_timeout=timedelta(hours=1), + actor_scan_interval=timedelta(seconds=30), + drain_ongoing_call_timeout=timedelta(minutes=1), + drain_rebalanced_actors=True, + reentrancy=ActorReentrancyConfig(enabled=False) + ) +) +``` +{{% /codetab %}} + +{{< /tabs >}} + Refer to the [Dapr SDKs]({{< ref "developing-applications/sdks/#sdk-languages" >}}) for more details. From 31fe88cc6c2bdf3a24397a414963efbad327b08d Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Thu, 3 Jun 2021 18:43:22 -0700 Subject: [PATCH 5/8] configuration examples --- .../building-blocks/actors/howto-actors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index 8ac553af8f2..4417c3abe43 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -186,4 +186,4 @@ ActorRuntime.set_actor_config( {{< /tabs >}} -Refer to the [Dapr SDKs]({{< ref "developing-applications/sdks/#sdk-languages" >}}) for more details. +Refer to the documentation and examples of the [Dapr SDKs]({{< ref "developing-applications/sdks/#sdk-languages" >}}) for more details. From c89ad76a60f57b75497555f72604546b61c944d8 Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Thu, 3 Jun 2021 18:46:37 -0700 Subject: [PATCH 6/8] Fix syntax --- .../building-blocks/actors/howto-actors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index 4417c3abe43..b332ad399b8 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -141,7 +141,7 @@ You can configure the Dapr Actors runtime configuration to modify the default ru - `drainRebalancedActors` - If true, Dapr will wait for `drainOngoingCallTimeout` duration to allow a current actor call to complete before trying to deactivate an actor. **Default: true** - `reentrancy` (ActorReentrancyConfig) - Configure the reentrancy behavior for an actor. If not provided, reentrancy is diabled. **Default: disabled** -{{< tabs Java .Net Python>}} +{{< tabs Java Dotnet Python >}} {{% codetab %}} ```java From 106d30db8a7d83943fd26d6fb474704accfe29eb Mon Sep 17 00:00:00 2001 From: Bernd Verst Date: Thu, 3 Jun 2021 19:17:03 -0700 Subject: [PATCH 7/8] Add dotnet sample --- .../building-blocks/actors/howto-actors.md | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index b332ad399b8..fa6aba37d44 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -145,7 +145,6 @@ You can configure the Dapr Actors runtime configuration to modify the default ru {{% codetab %}} ```java - // import io.dapr.actors.runtime.ActorRuntime; // import java.time.Duration; @@ -160,15 +159,33 @@ See [this example](https://github.com/dapr/java-sdk/blob/master/examples/src/mai {{% /codetab %}} {{% codetab %}} -```dotnet - -TBD +```csharp +// In Startup.cs +public void ConfigureServices(IServiceCollection services) +{ + // Register actor runtime with DI + services.AddActors(options => + { + // Register actor types and configure actor settings + options.Actors.RegisterActor(); + + // Configure default settings + options.ActorIdleTimeout = TimeSpan.FromMinutes(60); + options.ActorScanInterval = TimeSpan.FromSeconds(30); + options.DrainOngoingCallTimeout = TimeSpan.FromSeconds(60); + options.DrainRebalancedActors = true; + // reentrancy not implemented in the .NET SDK at this time + }); + + // Register additional services for use with actors + services.AddSingleton(); +} ``` +See the .NET SDK [documentation](https://github.com/dapr/dotnet-sdk/blob/master/daprdocs/content/en/dotnet-sdk-docs/dotnet-actors/dotnet-actors-usage.md#registering-actors). {{% /codetab %}} {{% codetab %}} ```python - from datetime import timedelta from dapr.actor.runtime.config import ActorRuntimeConfig, ActorReentrancyConfig From 5113e7ed26ebaf4e4a66485b8f77ae470addace3 Mon Sep 17 00:00:00 2001 From: Aaron Crawfis Date: Mon, 7 Jun 2021 21:46:58 -0700 Subject: [PATCH 8/8] Update daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md --- .../building-blocks/actors/howto-actors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md index fa6aba37d44..0ba0043dc70 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md +++ b/daprdocs/content/en/developing-applications/building-blocks/actors/howto-actors.md @@ -130,7 +130,7 @@ DELETE http://localhost:3500/v1.0/actors///reminders/ Refer [api spec]({{< ref "actors_api.md#invoke-reminder" >}}) for more details. -## Actor Runtime Configuration +## Actor runtime configuration You can configure the Dapr Actors runtime configuration to modify the default runtime behavior.