-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add per-plugin recovery permitter actors (#7448)
* Add per-plugin recovery permitter actors * Add specs
- Loading branch information
Showing
7 changed files
with
125 additions
and
37 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/core/Akka.Persistence.Tests/MultipleRecoveryPermitterSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="MultipleRecoveryPermitterSpec.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2025 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2025 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Akka.Persistence.Tests; | ||
|
||
public class MultipleRecoveryPermitterSpec : PersistenceSpec | ||
{ | ||
private readonly IActorRef _permitter1; | ||
private readonly IActorRef _permitter2; | ||
|
||
public MultipleRecoveryPermitterSpec() : base(ConfigurationFactory.ParseString($$""" | ||
akka.persistence | ||
{ | ||
# default global max recovery value | ||
max-concurrent-recoveries = 3 | ||
journal | ||
{ | ||
plugin = "akka.persistence.journal.inmem" | ||
inmem2 { | ||
# max recovery value override | ||
max-concurrent-recoveries = 20 | ||
class = "Akka.Persistence.Journal.MemoryJournal, Akka.Persistence" | ||
plugin-dispatcher = "akka.actor.default-dispatcher" | ||
} | ||
} | ||
# snapshot store plugin is NOT defined, things should still work | ||
snapshot-store.plugin = "akka.persistence.no-snapshot-store" | ||
snapshot-store.local.dir = "target/snapshots-"{{typeof(RecoveryPermitterSpec).FullName}}"} | ||
""")) | ||
{ | ||
var extension = Persistence.Instance.Apply(Sys); | ||
_permitter1 = extension.RecoveryPermitterFor(null); | ||
_permitter2 = extension.RecoveryPermitterFor("akka.persistence.journal.inmem2"); | ||
} | ||
|
||
[Fact(DisplayName = "Plugin max-concurrent-recoveries HOCON setting should override akka.persistence setting")] | ||
public async Task HoconOverrideTest() | ||
{ | ||
_permitter1.Tell(GetMaxPermits.Instance); | ||
await ExpectMsgAsync(3); | ||
|
||
_permitter2.Tell(GetMaxPermits.Instance); | ||
await ExpectMsgAsync(20); | ||
} | ||
|
||
[Fact(DisplayName = "Each plugin should have their own recovery permitter")] | ||
public void MultiRecoveryPermitterActorTest() | ||
{ | ||
_permitter1.Equals(_permitter2).Should().BeFalse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters