經過一個ClientBuilder
和多個補充選項類,以編程方式配置一個用於鏈接Silo集羣並將請求發送至Grain的客戶端。html
客戶端配置示例:git
var client = new ClientBuilder() // 集羣信息 .Configure<ClusterOptions>(options => { options.ClusterId = "my-first-cluster"; options.ServiceId = "MyOrleansService"; }) // Clustering provider .UseAzureStorageClustering(options => options.ConnectionString = connectionString) // Application parts: just reference one of the grain interfaces that we use .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IHello).Assembly)) .Build();
注意:使用UseAzureStorageClustering
須要引用Microsoft.Orleans.Clustering.AzureStorage
github
下面讓咱們細分該示例中使用的步驟:docker
[...] // Clustering information .Configure<ClusterOptions>(options => { options.ClusterId = "orleans-docker"; options.ServiceId = "AspNetSampleApp"; }) [...]
這裏咱們使用了兩個設置:編程
設置ClusterId
爲"my-first-cluster"
:這是爲Orleans集羣的惟一ID。使用此ID的全部客戶端和Silo將可以直接相互通訊。例如,有些人會選擇ClusterId對每一個部署使用不一樣的名稱。
設置ServiceId
爲"AspNetSampleApp"
:這是你的應用程序的惟一ID,將被一些控制程序使用(例如用於持久性存儲)。該ID在整個部署中應該是穩定的(不可更改)。服務器
[...] // Clustering provider .UseAzureStorageClustering(options => options.ConnectionString = connectionString) [...]
客戶端將使用此程序配置發現羣集中全部可用的網關。Orleans有幾個支撐程序能夠選擇,在此示例中,咱們使用Azure Table提供程序。分佈式
要獲取更多詳細信息,請查看「服務器配置」頁面中的「Server Configuration」部分。ide
[...] // Application parts: just reference one of the grain interfaces that we use .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IHello).Assembly)).WithReferences()) [...];
目錄 : Orleans[NET Core 3.1] 學習筆記(一).NET環境下的分佈式應用程序學習
上一節 : Orleans[NET Core 3.1] 學習筆記(三)( 1 )本地開發配置ui
下一節 :