Delen via


Typische configuraties

Hieronder vindt u voorbeelden van typische configuraties die kunnen worden gebruikt voor ontwikkelings- en productie-implementaties.

Lokale ontwikkeling

Zie De configuratie van lokale ontwikkeling voor meer informatie.

Betrouwbare productie-implementatie met Behulp van Azure

Voor een betrouwbare productie-implementatie met behulp van Azure moet u de optie Azure Table gebruiken voor clusterlidmaatschap. Deze configuratie is gebruikelijk voor implementaties voor on-premises servers, containers of exemplaren van virtuele Azure-machines.

De notatie van de DataConnection tekenreeks is een ; gescheiden lijst Key=Value met paren. De volgende opties worden ondersteund:

Sleutel Weergegeven als
DefaultEndpointsProtocol https
AccountName <Azure storage account>
AccountKey <Azure table storage account key>

Hier volgt een voorbeeld van een DataConnection tekenreeks voor Azure Table Storage:

"DefaultEndpointsProtocol=https;AccountName=<Azure storage account>;AccountKey=<Azure table storage account key>"

Siloconfiguratie:

const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var silo = new HostBuilder()
    .UseOrleans(builder =>
    {
        builder.Configure<ClusterOptions>(options =>
        {
            options.ClusterId = "Cluster42";
            options.ServiceId = "MyAwesomeService";
        })
        .UseAzureStorageClustering(
            options => options.ConfigureTableServiceClient(connectionString))
        .ConfigureEndpoints(siloPort: 11_111, gatewayPort: 30_000)
        .ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
    })
    .Build();

Clientconfiguratie:

const string connectionString = "YOUR_CONNECTION_STRING_HERE";

using var host = Host.CreateDefaultBuilder(args)
    .UseOrleansClient(clientBuilder =>
        clientBuilder.Configure<ClusterOptions>(options =>
        {
            options.ClusterId = "Cluster42";
            options.ServiceId = "MyAwesomeService";
        })
        .UseAzureStorageClustering(
            options => options.ConfigureTableServiceClient(connectionString)))
    .Build();

Betrouwbare productie-implementatie met SQL Server

Voor een betrouwbare productie-implementatie met behulp van SQL Server moet een SQL Server-verbindingsreeks worden opgegeven.

Siloconfiguratie:

const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var silo = new HostBuilder()
    .UseOrleans(builder =>
    {
        builder.Configure<ClusterOptions>(options =>
        {
            options.ClusterId = "Cluster42";
            options.ServiceId = "MyAwesomeService";
        })
        .UseAdoNetClustering(options =>
        {
          options.ConnectionString = connectionString;
          options.Invariant = "System.Data.SqlClient";
        })
        .ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000)
        .ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
    })
    .Build();

Clientconfiguratie:

const string connectionString = "YOUR_CONNECTION_STRING_HERE";

using var host = Host.CreateDefaultBuilder(args)
    .UseOrleansClient(clientBuilder =>
        clientBuilder.Configure<ClusterOptions>(options =>
        {
            options.ClusterId = "Cluster42";
            options.ServiceId = "MyAwesomeService";
        })
        .UseAdoNetClustering(options =>
        {
          options.ConnectionString = connectionString;
          options.Invariant = "System.Data.SqlClient";
        }))
    .Build();

Onbetrouwbare implementatie op een cluster van toegewezen servers

Voor het testen op een cluster van toegewezen servers wanneer betrouwbaarheid geen probleem is, kunt u gebruikmaken MembershipTableGrain van en afhankelijkheid van Azure Table voorkomen. U hoeft slechts een van de knooppunten aan te wijzen als primaire knooppunten.

Op de silo's:

var primarySiloEndpoint = new IPEndpoint(PRIMARY_SILO_IP_ADDRESS, 11_111);
var silo = new HostBuilder()
    .UseOrleans(builder =>
    {
        builder
            .UseDevelopmentClustering(primarySiloEndpoint)
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "Cluster42";
                options.ServiceId = "MyAwesomeService";
            })
            .ConfigureEndpoints(siloPort: 11_111, gatewayPort: 30_000)
            .ConfigureLogging(logging => logging.AddConsole())
    })
    .Build();

Op de clients:

var gateways = new IPEndPoint[]
{
    new IPEndPoint(PRIMARY_SILO_IP_ADDRESS, 30_000),
    new IPEndPoint(OTHER_SILO__IP_ADDRESS_1, 30_000),
    // ...
    new IPEndPoint(OTHER_SILO__IP_ADDRESS_N, 30_000),
};

using var host = Host.CreateDefaultBuilder(args)
    .UseOrleansClient(clientBuilder =>
        clientBuilder.UseStaticClustering(gateways)
            .Configure<ClusterOptions>(options =>
            {
                options.ClusterId = "Cluster42";
                options.ServiceId = "MyAwesomeService";
            }))
    .Build();