-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
113 additions
and
65 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
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,4 @@ | ||
public interface IEntityId | ||
{ | ||
string EntityId { get; } | ||
} |
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,14 @@ | ||
using Akka.Cluster.Sharding; | ||
|
||
namespace Akka.Pathfinder | ||
{ | ||
public class MessageExtractor : HashCodeMessageExtractor | ||
{ | ||
public MessageExtractor() : base(100) { } | ||
|
||
public override string EntityId(object message) | ||
{ | ||
return message is IEntityId ntt ? ntt.EntityId : throw new ArgumentException("DUMMKOPF"); | ||
} | ||
} | ||
} |
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,14 @@ | ||
using Akka.Persistence; | ||
|
||
namespace Akka.Pathfinder; | ||
|
||
public class PathfinderWorker : ReceivePersistentActor | ||
{ | ||
public override string PersistenceId => $"PathfinderWorker_{EntityId}"; | ||
public string EntityId; | ||
|
||
public PathfinderWorker(string entityId) | ||
{ | ||
EntityId = entityId; | ||
} | ||
} |
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,14 @@ | ||
using Akka.Persistence; | ||
|
||
namespace Akka.Pathfinder; | ||
|
||
public class PointWorker : ReceivePersistentActor | ||
{ | ||
public override string PersistenceId => $"PointWorker_{EntityId}"; | ||
public string EntityId; | ||
|
||
public PointWorker(string entityId) | ||
{ | ||
EntityId = entityId; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,29 +1,68 @@ | ||
using System.Drawing; | ||
using Akka.Actor; | ||
using Akka.Cluster.Hosting; | ||
using Akka.Cluster.Sharding; | ||
using Akka.HealthCheck.Hosting; | ||
using Akka.Hosting; | ||
using Akka.Pathfinder; | ||
using Akka.Persistence.Hosting; | ||
using Akka.Persistence.MongoDb.Hosting; | ||
using Akka.Remote.Hosting; | ||
|
||
var hostBuilder = new HostBuilder(); | ||
|
||
hostBuilder.ConfigureServices((context, services) => | ||
internal class Program | ||
{ | ||
services.AddAkka("MyActorSystem", (builder, sp) => | ||
private static async Task Main(string[] args) | ||
{ | ||
builder | ||
.WithActors((system, registry, resolver) => | ||
{ | ||
var helloActor = system.ActorOf(Props.Create(() => new HelloActor()), "hello-actor"); | ||
registry.Register<HelloActor>(helloActor); | ||
}) | ||
.WithActors((system, registry, resolver) => | ||
var hostBuilder = new HostBuilder(); | ||
|
||
hostBuilder.ConfigureServices((context, services) => | ||
{ | ||
services.AddAkka("Zeus", (builder, sp) => | ||
{ | ||
var timerActorProps = | ||
resolver.Props<TimerActor>(); // uses Msft.Ext.DI to inject reference to helloActor | ||
var timerActor = system.ActorOf(timerActorProps, "timer-actor"); | ||
registry.Register<TimerActor>(timerActor); | ||
var shardingJournalOptions = new MongoDbJournalOptions(false) | ||
{ | ||
ConnectionString = "connectionString", | ||
Collection = "EventJournal", | ||
MetadataCollection = "Metadata", | ||
AutoInitialize = true, | ||
}; | ||
var shardingSnapshotOptions = new MongoDbSnapshotOptions(true) | ||
{ | ||
ConnectionString = "connectionString", | ||
Collection = "SnapshotStore", | ||
AutoInitialize = true | ||
}; | ||
builder.WithHealthCheck(x => | ||
{ | ||
x.AddProviders(HealthCheckType.All); | ||
x.Liveness.PersistenceProbeInterval = TimeSpan.FromSeconds(5); | ||
x.Readiness.PersistenceProbeInterval = TimeSpan.FromSeconds(5); | ||
x.LogConfigOnStart = true; | ||
}) | ||
.WithRemoting("0.0.0.0", 1337, "127.0.0.1") | ||
.WithClustering(new ClusterOptions | ||
{ | ||
Roles = new[] { "KEKW" }, | ||
SeedNodes = new[] { "akka.tcp://[email protected]:4200" } | ||
}) | ||
.WithMongoDbPersistence("connectionString", PersistenceMode.Both, true) | ||
.WithJournalAndSnapshot(shardingJournalOptions, shardingSnapshotOptions) | ||
.WithShardRegion<PointWorker>("Name", x => Props.Create<PointWorker>(x), new MessageExtractor(), new ShardOptions() | ||
{ | ||
JournalOptions = shardingJournalOptions, | ||
SnapshotOptions = shardingSnapshotOptions, | ||
Role = "KEKW", | ||
PassivateIdleEntityAfter = null | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
var host = hostBuilder.Build(); | ||
var host = hostBuilder.Build(); | ||
|
||
await host.RunAsync(); | ||
await host.RunAsync(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.