Orleans 接收器配置

有关快速概述,我们在以下 XML 语法中显示了所有相关配置参数(包括可选参数):

<?xml version="1.0" encoding="utf-8"?>
<OrleansConfiguration xmlns="urn:orleans">
  <Globals>
    <MultiClusterNetwork
      ClusterId="clusterid"
      DefaultMultiCluster="uswest,europewest,useast"
      BackgroundGossipInterval="30s"
      UseGlobalSingleInstanceByDefault="false"
      GlobalSingleInstanceRetryInterval="30s"
      GlobalSingleInstanceNumberRetries="3"
      MaxMultiClusterGateways="10">
         <GossipChannel Type="..." ConnectionString="..."/>
         <GossipChannel Type="..." ConnectionString="..."/>
    </MultiClusterNetwork>
    <SystemStore ServiceId="some-guid" />
  </Globals>
</OrleansConfiguration>
var silo = new HostBuilder()
    .UseOrleans(builder =>
    {
        builder.Configure<ClusterInfo>(options =>
        {
            options.ClusterId = "us3";
            options.ServiceId = "myawesomeservice";
        })
        .Configure<MultiClusterOptions>(options =>
        {
            options.HasMultiClusterNetwork = true;
            options.DefaultMultiCluster = new[] { "us1", "eu1", "us2" };
            options.BackgroundGossipInterval = TimeSpan.FromSeconds(30);
            options.UseGlobalSingleInstanceByDefault = false;
            options.GlobalSingleInstanceRetryInterval = TimeSpan.FromSeconds(30);
            options.GlobalSingleInstanceNumberRetries = 3;
            options.MaxMultiClusterGateways = 10;
            options.GossipChannels.Add(
                "AzureTable",
                "DefaultEndpointsProtocol=https;AccountName=usa;AccountKey=...");
            options.GossipChannels.Add(
                "AzureTable",
                "DefaultEndpointsProtocol=https;AccountName=europe;AccountKey=...")
        });
    });

与往常一样,还可以通过类的相应成员 GlobalConfiguration 以编程方式读取和写入所有配置设置。

GlobalConfiguration.ServiceId 是用于标识此服务的任意 ID。 所有群集和所有接收器必须采用同一个 ID。

MultiClusterNetwork 部分是可选的。 如果不存在,则会禁用此存储的所有多群集支持。

所需的参数ClusterIdGossipChannels多群集通信中进行了解释。

可选参数MaxMultiClusterGatewaysBackgroundGossipInterval多群集通信中进行了解释。

多群集配置中介绍了可选参数DefaultMultiCluster

可选参数UseGlobalSingleInstanceByDefaultGlobalSingleInstanceRetryIntervalGlobalSingleInstanceNumberRetries全局单实例模型中进行了说明。

Orleans 客户端配置

客户端不需要 Orleans 额外的配置。 同一客户端无法连接到不同群集中的孤岛(孤岛在这种情况下拒绝连接)。