C# 我可以用奥尔良来制作中间演员/谷物吗?

C# 我可以用奥尔良来制作中间演员/谷物吗?,c#,.net-core,orleans,C#,.net Core,Orleans,我正在使用奥尔良,但不依赖于网络和端点的配置,我更希望能够在下面的代码中使用颗粒: public interface IGreeter : IActorGrain { } public class Greeter : DispatchActorGrain, IGreeter { void On(Greet msg) => WriteLine($"Hello, {msg.Who}"); } [SerializableAttribute] public class Greet {

我正在使用奥尔良,但不依赖于网络和端点的配置,我更希望能够在下面的代码中使用颗粒:

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("\n\nPress any key to terminate ...");
        ReadKey(true);
    }
}
公共接口IGreeter:IActorGrain
{
}
公共舱迎宾员:DispatchectorGrain,IGreeter
{
void On(Greet msg)=>WriteLine($“Hello,{msg.Who}”);
}
[序列化属性]
公共课问候
{
公共字符串Who{get;set;}
}
公共静态类程序
{
公共静态异步任务Main()
{
WriteLine(“正在运行的示例。引导群集可能需要一些时间…\n”);
var host=new-SiloHostBuilder()
.Configure(选项=>
{
options.ClusterId=“localhost demo”;
options.ServiceId=“localhost演示服务”;
})
.Configure(选项=>
{
options.AllowCallChainReentrancy=false;
})
.Configure(选项=>
{
options.ResponseTimeout=TimeSpan.FromSeconds(5);
options.ResponseTimeoutWithDebugger=TimeSpan.FromSeconds(5);
})
.ConfigureLogging(日志=>
{
logging.SetMinimumLevel(LogLevel.Information);
logging.AddConsole();
})
.UseDevelopmentClustering(选项=>options.PrimarySiloEndpoint=新的IPEndPoint(IPAddress.Loopback,30000))
.ConfigureEndpoints(IPAddress.Loopback,111113000)
.ConfigureApplicationParts(x=>x
.AddApplicationPart(Assembly.getExecutionGassembly())
.WithCodeGeneration())
.UseOrleankka()
.Build();
等待host.StartAsync();
var client=new ClientBuilder()
.Configure(选项=>{
options.ClusterId=“localhost demo”;
options.ServiceId=“localhost演示服务”;
})
.UseStaticClustering(options=>options.Gateways.Add(新的IPEndPoint(IPAddress.Loopback,30000).ToGatewayUri())
.ConfigureApplicationParts(x=>x
.AddApplicationPart(Assembly.getExecutionGassembly())
.WithCodeGeneration())
.UseOrleankka()
.Build();
等待client.Connect();
var greeter=client.ActorSystem().ActorOf(“id”);
等待迎接者。告诉(新的问候{Who=“world”});
写入(“\n\n按任意键终止…”);
ReadKey(true);
}
}

有可能吗?

完全有可能将奥尔良作为一个单一流程使用,而不进行集群(我在测试和预生产阶段就是这么做的),但您将失去可用性


思洛存储器应该在集群中作为长时间运行的进程运行,因此对于云环境来说,单个节点约30秒的启动时间不应该是一个问题。如果您需要一个单主机演员系统,akka.net可能是一个更好的解决方案

是的,它可能在奥尔良2.3中开箱即用。默认情况下,它们在服务容器中有一个“托管客户端”(有时称为“直接客户端”)。不幸的是,目前还没有关于它的文档。此外,看起来您正在使用Orleankka。我还没有详细看过这个库,所以我不确定带托管客户端的思洛存储器的配置与香草奥尔良有什么不同(如果有的话)。@seniorquico谢谢,哦,很好,希望它能缩短启动时间,否则它真的会让:s变慢