Skip to content

Commit

Permalink
add first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
st0o0 committed Oct 27, 2023
1 parent f12f9b1 commit e7a9bcb
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Akka.Pathfinder.AcceptanceTests
build_property.ProjectDir = D:\Priv\Akka.Pathfinder\src\Akka\Akka.Pathfinder.AcceptanceTests\
build_property.ProjectDir = D:\GIT\Akka.Pathfinder\src\Akka\Akka.Pathfinder.AcceptanceTests\
10 changes: 8 additions & 2 deletions src/Akka/Akka.Pathfinder/Akka.Pathfinder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Akka" Version="1.5.13" />
<PackageReference Include="Akka" Version="1.5.*" />
<PackageReference Include="Akka.HealthCheck.Hosting" Version="1.5.*" />
<PackageReference Include="Akka.HealthCheck.Cluster" Version="1.5.*" />
<PackageReference Include="Akka.Cluster.Sharding" Version="1.5.*" />
<PackageReference Include="Akka.Cluster.Hosting" Version="1.5.*" />
<PackageReference Include="Akka.Cluster" Version="1.5.13" />
<PackageReference Include="Akka.DependencyInjection" Version="1.5.13" />
<PackageReference Include="Akka.Hosting" Version="1.5.13" />
<PackageReference Include="Akka.Logger.Extensions.Logging" Version="1.4.22" />
<PackageReference Include="Akka.Logger.Serilog" Version="1.5.12.1" />
<PackageReference Include="Akka.Persistence.MongoDb" Version="1.5.12.1" />
<PackageReference Include="Akka.Persistence.Hosting" Version="1.5.*" />
<PackageReference Include="Akka.Persistence.MongoDb.Hosting" Version="1.5.*" />
<PackageReference Include="Akka.Persistence.MongoDb" Version="1.5.*" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0-dev-00923" />
</ItemGroup>

Expand Down
18 changes: 0 additions & 18 deletions src/Akka/Akka.Pathfinder/HelloActor.cs

This file was deleted.

4 changes: 4 additions & 0 deletions src/Akka/Akka.Pathfinder/IEntityId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public interface IEntityId
{
string EntityId { get; }
}
14 changes: 14 additions & 0 deletions src/Akka/Akka.Pathfinder/MessageExtractor.cs
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");
}
}
}
14 changes: 14 additions & 0 deletions src/Akka/Akka.Pathfinder/PathfinderWorker.cs
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;
}
}
14 changes: 14 additions & 0 deletions src/Akka/Akka.Pathfinder/PointWorker.cs
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;
}
}
77 changes: 58 additions & 19 deletions src/Akka/Akka.Pathfinder/Program.cs
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();
}
}
25 changes: 0 additions & 25 deletions src/Akka/Akka.Pathfinder/TimerActor.cs

This file was deleted.

0 comments on commit e7a9bcb

Please sign in to comment.