/
config.go
80 lines (69 loc) · 2.66 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation and Dapr Contributors.
// Licensed under the MIT License.
// ------------------------------------------------------------
package actors
import (
"time"
app_config "github.com/dapr/dapr/pkg/config"
)
// Config is the actor runtime configuration.
type Config struct {
HostAddress string
AppID string
PlacementAddresses []string
HostedActorTypes []string
Port int
HeartbeatInterval time.Duration
ActorDeactivationScanInterval time.Duration
ActorIdleTimeout time.Duration
DrainOngoingCallTimeout time.Duration
DrainRebalancedActors bool
Namespace string
Reentrancy app_config.ReentrancyConfig
RemindersStoragePartitions int
}
const (
defaultActorIdleTimeout = time.Minute * 60
defaultHeartbeatInterval = time.Second * 1
defaultActorScanInterval = time.Second * 30
defaultOngoingCallTimeout = time.Second * 60
defaultReentrancyStackLimit = 32
)
// NewConfig returns the actor runtime configuration.
func NewConfig(hostAddress, appID string, placementAddresses []string, hostedActors []string, port int,
actorScanInterval, actorIdleTimeout, ongoingCallTimeout string, drainRebalancedActors bool, namespace string,
reentrancy app_config.ReentrancyConfig, remindersStoragePartitions int) Config {
c := Config{
HostAddress: hostAddress,
AppID: appID,
PlacementAddresses: placementAddresses,
HostedActorTypes: hostedActors,
Port: port,
HeartbeatInterval: defaultHeartbeatInterval,
ActorDeactivationScanInterval: defaultActorScanInterval,
ActorIdleTimeout: defaultActorIdleTimeout,
DrainOngoingCallTimeout: defaultOngoingCallTimeout,
DrainRebalancedActors: drainRebalancedActors,
Namespace: namespace,
Reentrancy: reentrancy,
RemindersStoragePartitions: remindersStoragePartitions,
}
scanDuration, err := time.ParseDuration(actorScanInterval)
if err == nil {
c.ActorDeactivationScanInterval = scanDuration
}
idleDuration, err := time.ParseDuration(actorIdleTimeout)
if err == nil {
c.ActorIdleTimeout = idleDuration
}
drainCallDuration, err := time.ParseDuration(ongoingCallTimeout)
if err == nil {
c.DrainOngoingCallTimeout = drainCallDuration
}
if reentrancy.MaxStackDepth == nil {
reentrancyLimit := defaultReentrancyStackLimit
c.Reentrancy.MaxStackDepth = &reentrancyLimit
}
return c
}