Share via


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 是用來識別此服務的任意識別碼。 其對於所有叢集和所有定址接收器都必須相同。

Orleans.Runtime.MultiClusterNetwork 區段是選擇性的,如果不存在,此定址接收器會停用所有多重叢集支援。

必要參數ClusterIdGossipChannels 會在多叢集通訊一節中說明。

選擇性參數MaxMultiClusterGatewaysBackgroundGossipInterval 會在多叢集通訊一節中說明。

選擇性參數DefaultMultiCluster會在多叢集設定一節中說明。

選擇性參數 UseGlobalSingleInstanceByDefaultGlobalSingleInstanceRetryIntervalGlobalSingleInstanceNumberRetries 會在全域單一執行個體粒紋一節中說明。

Orleans 用戶端組態

Orleans 用戶端不需要額外的設定。 相同的用戶端可能不會連線至不同叢集中的定址接收器 (定址接收器拒絕該情況中的連線)。