是否可以将新奥尔良用于进程中的参与者/粒度



我正在使用奥尔良,但不依赖网络,因此不依赖端点的配置,我宁愿能够在下面的代码中处理颗粒:

public interface IGreeter : IActorGrain
{
}
public class Greeter : DispatchActorGrain, IGreeter
{
    void On(Greet msg) => WriteLine($"Hello, {msg.Who}");
}
[SerializableAttribute]
public class Greet
{
    public string Who { get; set; }
}
public static class Program
{
    public static async Task Main()
    {
        WriteLine("Running example. Booting cluster might take some time ...n");
        var host = new SiloHostBuilder()
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "localhost-demo";
                options.ServiceId = "localhost-demo-service";
            })
            .Configure<SchedulingOptions>(options =>
            {
                options.AllowCallChainReentrancy = false;
            })
            .Configure<SiloMessagingOptions>(options =>
            {
                options.ResponseTimeout = TimeSpan.FromSeconds(5);
                options.ResponseTimeoutWithDebugger = TimeSpan.FromSeconds(5);
            })
            .ConfigureLogging(logging =>
            {
                logging.SetMinimumLevel(LogLevel.Information);
                logging.AddConsole();
            })
            .UseDevelopmentClustering(options => options.PrimarySiloEndpoint = new IPEndPoint(IPAddress.Loopback, 30000))
            .ConfigureEndpoints(IPAddress.Loopback, 11111, 30000)
            .ConfigureApplicationParts(x => x
                .AddApplicationPart(Assembly.GetExecutingAssembly())
                .WithCodeGeneration())
            .UseOrleankka()
            .Build();
        await host.StartAsync();
        var client = new ClientBuilder()
            .Configure<ClusterOptions>(options => {
                options.ClusterId = "localhost-demo";
                options.ServiceId = "localhost-demo-service";
            })
            .UseStaticClustering(options => options.Gateways.Add(new IPEndPoint(IPAddress.Loopback, 30000).ToGatewayUri()))
            .ConfigureApplicationParts(x => x
                .AddApplicationPart(Assembly.GetExecutingAssembly())
                .WithCodeGeneration())
            .UseOrleankka()
            .Build();
        await client.Connect();
        var greeter = client.ActorSystem().ActorOf<IGreeter>("id");
        await greeter.Tell(new Greet {Who = "world"});
        Write("nnPress any key to terminate ...");
        ReadKey(true);
    }
}

可能吗?

完全可以将新奥尔良用作没有群集的单个进程(我在测试和预生产阶段就是这样做的(,但你将失去可用性。

孤岛应该作为集群中长时间运行的进程运行,因此单个节点的~30秒启动时间对于云环境来说永远不是问题。如果您需要单主机Actor系统,akka.net 可能是更好的解决方案

最新更新