@@ -26,6 +26,11 @@ public sealed class ShardedDaemonProcessSettings
26
26
/// </summary>
27
27
public readonly ClusterShardingSettings ShardingSettings ;
28
28
29
+ /// <summary>
30
+ /// Specifies that the ShardedDaemonProcess should run on nodes with a specific role.
31
+ /// </summary>
32
+ public readonly string Role ;
33
+
29
34
/// <summary>
30
35
/// Create default settings for system
31
36
/// </summary>
@@ -43,30 +48,38 @@ public static ShardedDaemonProcessSettings FromConfig(Config config)
43
48
/// <summary>
44
49
/// Not for user constructions, use factory methods to instantiate.
45
50
/// </summary>
46
- private ShardedDaemonProcessSettings ( TimeSpan keepAliveInterval , ClusterShardingSettings shardingSettings = null )
51
+ private ShardedDaemonProcessSettings ( TimeSpan keepAliveInterval , ClusterShardingSettings shardingSettings = null , string role = null )
47
52
{
48
53
KeepAliveInterval = keepAliveInterval ;
49
54
ShardingSettings = shardingSettings ;
55
+ Role = role ;
56
+ }
57
+
58
+ private ShardedDaemonProcessSettings Copy ( TimeSpan ? keepAliveInterval = null , ClusterShardingSettings shardingSettings = null , string role = null )
59
+ {
60
+ return new ShardedDaemonProcessSettings ( keepAliveInterval ?? KeepAliveInterval , shardingSettings ?? ShardingSettings , role ?? Role ) ;
50
61
}
51
62
52
63
/// <summary>
53
64
/// NOTE: How the sharded set is kept alive may change in the future meaning this setting may go away.
54
65
/// </summary>
55
66
/// <param name="keepAliveInterval">The interval each parent of the sharded set is pinged from each node in the cluster.</param>
56
- public ShardedDaemonProcessSettings WithKeepAliveInterval ( TimeSpan keepAliveInterval )
57
- {
58
- return new ShardedDaemonProcessSettings ( keepAliveInterval , ShardingSettings ) ;
59
- }
67
+ public ShardedDaemonProcessSettings WithKeepAliveInterval ( TimeSpan keepAliveInterval ) => Copy ( keepAliveInterval : keepAliveInterval ) ;
60
68
61
69
/// <summary>
62
70
/// Specify sharding settings that should be used for the sharded daemon process instead of loading from config.
63
71
/// Some settings can not be changed (remember-entities and related settings, passivation, number-of-shards),
64
72
/// changing those settings will be ignored.
65
73
/// </summary>
66
74
/// <param name="shardingSettings">TBD</param>
67
- public ShardedDaemonProcessSettings WithShardingSettings ( ClusterShardingSettings shardingSettings )
68
- {
69
- return new ShardedDaemonProcessSettings ( KeepAliveInterval , shardingSettings ) ;
70
- }
75
+ public ShardedDaemonProcessSettings WithShardingSettings ( ClusterShardingSettings shardingSettings ) => Copy ( shardingSettings : shardingSettings ) ;
76
+
77
+ /// <summary>
78
+ /// Specifies that the ShardedDaemonProcess should run on nodes with a specific role.
79
+ /// If the role is not specified all nodes in the cluster are used. If the given role does
80
+ /// not match the role of the current node the ShardedDaemonProcess will not be started.
81
+ /// </summary>
82
+ /// <param name="role">TBD</param>
83
+ public ShardedDaemonProcessSettings WithRole ( string role ) => Copy ( role : role ) ;
71
84
}
72
85
}
0 commit comments