mirror of https://github.com/dapr/docs.git
Add documentation for per actor configuration (#2334)
This commit includes documentation on how to set the per type actor configuration. This is currently not supported in any SDK so an example is provided using raw Go. https://github.com/dapr/docs/issues/2176 Signed-off-by: Hal Spang <halspang@microsoft.com> Co-authored-by: Mark Fussell <markfussell@gmail.com>
This commit is contained in:
parent
211ccd0d50
commit
ddbf4bf756
|
|
@ -163,6 +163,7 @@ Refer [api spec]({{< ref "actors_api.md#invoke-reminder" >}}) for more details.
|
|||
You can configure the Dapr actor runtime configuration to modify the default runtime behavior.
|
||||
|
||||
### Configuration parameters
|
||||
- `entities` - The actor types supported by this host.
|
||||
- `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**
|
||||
|
|
@ -170,8 +171,9 @@ You can configure the Dapr actor runtime configuration to modify the default run
|
|||
- `reentrancy` (ActorReentrancyConfig) - Configure the reentrancy behavior for an actor. If not provided, reentrancy is diabled. **Default: disabled**
|
||||
**Default: 0**
|
||||
- `remindersStoragePartitions` - Configure the number of partitions for actor's reminders. If not provided, all reminders are saved as a single record in actor's state store. **Default: 0**
|
||||
- `entitiesConfig` - Configure each actor type individually with an array of configurations. Any entity specified in the individual entity configurations must also be specified in the top level `entities` field. **Default: None**
|
||||
|
||||
{{< tabs Java Dotnet Python >}}
|
||||
{{< tabs Java Dotnet Python Go >}}
|
||||
|
||||
{{% codetab %}}
|
||||
```java
|
||||
|
|
@ -234,6 +236,52 @@ ActorRuntime.set_actor_config(
|
|||
```
|
||||
{{% /codetab %}}
|
||||
|
||||
{{% codetab %}}
|
||||
```go
|
||||
const (
|
||||
defaultActorType = "basicType"
|
||||
reentrantActorType = "reentrantType"
|
||||
)
|
||||
|
||||
type daprConfig struct {
|
||||
Entities []string `json:"entities,omitempty"`
|
||||
ActorIdleTimeout string `json:"actorIdleTimeout,omitempty"`
|
||||
ActorScanInterval string `json:"actorScanInterval,omitempty"`
|
||||
DrainOngoingCallTimeout string `json:"drainOngoingCallTimeout,omitempty"`
|
||||
DrainRebalancedActors bool `json:"drainRebalancedActors,omitempty"`
|
||||
Reentrancy config.ReentrancyConfig `json:"reentrancy,omitempty"`
|
||||
EntitiesConfig []config.EntityConfig `json:"entitiesConfig,omitempty"`
|
||||
}
|
||||
|
||||
var daprConfigResponse = daprConfig{
|
||||
Entities: []string{defaultActorType, reentrantActorType},
|
||||
ActorIdleTimeout: actorIdleTimeout,
|
||||
ActorScanInterval: actorScanInterval,
|
||||
DrainOngoingCallTimeout: drainOngoingCallTimeout,
|
||||
DrainRebalancedActors: drainRebalancedActors,
|
||||
Reentrancy: config.ReentrancyConfig{Enabled: false},
|
||||
EntitiesConfig: []config.EntityConfig{
|
||||
{
|
||||
// This actor type must have a matching value in the base level 'entities' field. If it does not, the configuration will be ignored.
|
||||
// If there is a matching entity, the values here will be used to overwrite any values specified in the root configuration.
|
||||
// In the case of this actor, it will have reentrancy enabled and 'defaultActorType' will not have reentrancy enabled.
|
||||
Entities: []string{reentrantActorType},
|
||||
Reentrancy: config.ReentrancyConfig{
|
||||
Enabled: true,
|
||||
MaxStackDepth: &maxStackDepth,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func configHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(daprConfigResponse)
|
||||
}
|
||||
```
|
||||
{{% /codetab %}}
|
||||
|
||||
{{< /tabs >}}
|
||||
|
||||
Refer to the documentation and examples of the [Dapr SDKs]({{< ref "developing-applications/sdks/#sdk-languages" >}}) for more details.
|
||||
|
|
|
|||
|
|
@ -464,6 +464,7 @@ drainRebalancedActors | A bool. If true, Dapr will wait for `drainOngoingCallTi
|
|||
reentrancy | A configuration object that holds the options for actor reentrancy.
|
||||
enabled | A flag in the reentrancy configuration that is needed to enable reentrancy.
|
||||
maxStackDepth | A value in the reentrancy configuration that controls how many reentrant calls be made to the same actor.
|
||||
entitiesConfig | Array of entity configurations that allow per actor type settings. Any configuration defined here must have an entity that maps back into the root level entities.
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
@ -475,7 +476,17 @@ maxStackDepth | A value in the reentrancy configuration that controls how many r
|
|||
"reentrancy": {
|
||||
"enabled": true,
|
||||
"maxStackDepth": 32
|
||||
}
|
||||
},
|
||||
"entitiesConfig": [
|
||||
{
|
||||
"entities": ["actorType1"],
|
||||
"actorIdleTimeout": "1m",
|
||||
"drainOngoingCallTimeout": "10s",
|
||||
"reentrancy": {
|
||||
"enabled": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue