File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Akka.Hosting.API.Tests/verify Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -278,12 +278,21 @@ public sealed class ShardOptions
278
278
/// <see cref="Akka.Cluster.Sharding.StateStoreMode.DData"/>
279
279
/// </summary>
280
280
public ShardingDDataOptions DistributedData { get ; } = new ( ) ;
281
+
282
+ /// <summary>
283
+ /// Set this to a time duration to have sharding passivate entities when they have not
284
+ /// received any message in this length of time. Set to <c>null</c> to disable.
285
+ /// It is always disabled if <see cref="RememberEntities"/> is enabled.
286
+ /// </summary>
287
+ // Had to do it this way because this property is a tri-state
288
+ public TimeSpan ? PassivateIdleEntityAfter { get ; set ; } = TimeSpan . FromMinutes ( 2 ) ;
281
289
282
290
internal void Apply ( AkkaConfigurationBuilder builder )
283
291
{
284
292
DistributedData . Apply ( builder ) ;
285
293
286
294
var sb = new StringBuilder ( ) ;
295
+ sb . AppendLine ( "akka.cluster.sharding {" ) ;
287
296
288
297
if ( Role is { } )
289
298
sb . AppendLine ( $ "role = { Role . ToHocon ( ) } ") ;
@@ -315,10 +324,10 @@ internal void Apply(AkkaConfigurationBuilder builder)
315
324
sb . AppendLine (
316
325
$ "fail-on-invalid-entity-state-transition = { FailOnInvalidEntityStateTransition . ToHocon ( ) } ") ;
317
326
318
- if ( sb . Length == 0 )
319
- return ;
327
+ // Had to do it this way because this property is a tri-state
328
+ sb . AppendLine (
329
+ $ "passivate-idle-entity-after = { ( PassivateIdleEntityAfter is null ? "off" : PassivateIdleEntityAfter . ToHocon ( ) ) } ") ;
320
330
321
- sb . Insert ( 0 , "akka.cluster.sharding {" ) ;
322
331
sb . AppendLine ( "}" ) ;
323
332
builder . AddHocon ( sb . ToString ( ) , HoconAddMode . Prepend ) ;
324
333
}
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ namespace Akka.Cluster.Hosting
77
77
public string? JournalPluginId { get; set; }
78
78
public Akka.Hosting.Coordination.LeaseOptionBase? LeaseImplementation { get; set; }
79
79
public System.TimeSpan? LeaseRetryInterval { get; set; }
80
+ public System.TimeSpan? PassivateIdleEntityAfter { get; set; }
80
81
public bool? RememberEntities { get; set; }
81
82
public Akka.Cluster.Sharding.RememberEntitiesStore? RememberEntitiesStore { get; set; }
82
83
public string? Role { get; set; }
You can’t perform that action at this time.
0 commit comments