-
Notifications
You must be signed in to change notification settings - Fork 23
WithDistributedData() will start DistributedDataProvider extension automatically.
#597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Aaronontheweb
merged 2 commits into
akkadotnet:dev
from
Arkatufus:#594-Start-DistributedDataProvider-automatically
Apr 28, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/Akka.Cluster.Hosting.Tests/ClusterShardingDistributedDataSpecs.cs
This file contains hidden or 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,57 @@ | ||
| using System; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Akka.Actor; | ||
| using Akka.DistributedData; | ||
| using Akka.Hosting; | ||
| using Akka.Remote.Hosting; | ||
| using FluentAssertions; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Akka.Cluster.Hosting.Tests; | ||
|
|
||
| public class ClusterShardingDistributedDataSpecs: Akka.Hosting.TestKit.TestKit | ||
| { | ||
| private const string ReplicatorName = "dDataReplicator"; | ||
|
|
||
| public ClusterShardingDistributedDataSpecs(ITestOutputHelper output): base(output: output) | ||
| { | ||
| } | ||
|
|
||
| protected override void ConfigureAkka(AkkaConfigurationBuilder builder, IServiceProvider provider) | ||
| { | ||
| builder | ||
| .WithRemoting() | ||
| .WithClustering() | ||
| .WithDistributedData(opt => | ||
| { | ||
| opt.Name = ReplicatorName; | ||
| }); | ||
| } | ||
|
|
||
| [Fact(DisplayName = "WithDistributedData should start DistributedData extension automatically")] | ||
| public async Task WithDistributedDataStartsAutomaticallyTest() | ||
| { | ||
| var cluster = Cluster.Get(Sys); | ||
| await cluster.JoinAsync(cluster.SelfAddress); | ||
| cluster.State.Members.Count(m => m.Status == MemberStatus.Up).Should().Be(1); | ||
|
|
||
| var settings = ReplicatorSettings.Create(Sys); | ||
| var coordinatorName = settings.RestartReplicatorOnFailure ? $"{ReplicatorName}Supervisor" : ReplicatorName; | ||
|
|
||
| var actorSelection = Sys.ActorSelection(new RootActorPath(cluster.SelfAddress) / "user" / coordinatorName); | ||
|
|
||
| await AwaitAssertAsync(async () => | ||
| { | ||
| actorSelection.Tell(new Identify("coordinator"), TestActor); | ||
| var identity = await ExpectMsgAsync<ActorIdentity>(TimeSpan.FromSeconds(3)); | ||
|
|
||
| // The DData replicator should be running | ||
| // * This actor is created inside DistributedData extension .ctor | ||
| // * Marks that the extension is running | ||
| // * We can't use DistributedData.Get() because that defeats the purpose. | ||
| identity.Subject.Should().NotBeNull(); | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| using Akka.Coordination; | ||
| using Akka.DependencyInjection; | ||
| using Akka.Discovery; | ||
| using Akka.DistributedData; | ||
| using Akka.Hosting; | ||
| using Akka.Hosting.Coordination; | ||
| using Akka.Persistence.Hosting; | ||
|
|
@@ -691,6 +692,7 @@ public static AkkaConfigurationBuilder WithDistributedData( | |
| { | ||
| options.Apply(builder); | ||
| builder.AddHocon(DistributedData.DistributedData.DefaultConfig(), HoconAddMode.Append); | ||
| builder.WithExtension<DistributedDataProvider>(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual fix, add the extension to the auto-start list. |
||
| return builder; | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The replicator is started under user guardian, is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It really should be under the
/systemguardian but if we're stuck with/userfor now then that's a separate bug that'll need fixing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this is an Akka core issue, not Akka.Hosting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please file a bug for that?
That might also be an ugly one to chase down if replicators are all currently hard-coded to look for
/user/paths for chatting. Might have to move that to a v1.6 issue if it ends up being a breaking behavioral change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue to track this created here: akkadotnet/akka.net#7606