Пример #1
0
        private async Task StartSilo()
        {
            var siloBuilder = new SiloHostBuilder()
                              .UseLocalhostClustering()
                              .UseDashboard(options => { })
                              .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = "dev";
                options.ServiceId = "OrleansService";
            })
                              .ConfigureEndpoints(IPAddress.Loopback, 11111, 30000, listenOnAnyHostAddress: true)
                              .ConfigureLogging(logging => logging.AddConsole())
                              .ConfigureApplicationParts(manager =>
            {
                manager?.AddApplicationPart(typeof(CoinTrader).Assembly);
            });
            var invariant        = "System.Data.SqlClient"; // for Microsoft SQL Server
            var connectionString = Configuration["connectionString"].ToString();

            siloBuilder.UseAdoNetClustering(options =>
            {
                options.Invariant        = invariant;
                options.ConnectionString = connectionString;
            });
            //use AdoNet for reminder service
            siloBuilder.UseAdoNetReminderService(options =>
            {
                options.Invariant        = invariant;
                options.ConnectionString = connectionString;
            });
            //use AdoNet for Persistence
            siloBuilder.AddAdoNetGrainStorage("OrleansSqlStore", options =>
            {
                options.Invariant        = invariant;
                options.ConnectionString = connectionString;
                options.UseJsonFormat    = false;
            });

            _siloHost = siloBuilder.Build();
            await _siloHost.StartAsync();
        }