private void ProcessCommand(HostBuilderContext context, ISiloBuilder builder) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { builder.UsePerfCounterEnvironmentStatistics(); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { builder.UseLinuxEnvironmentStatistics(); } var siloPort = Configuration.GetValue <int>("SiloPort"); var gatewayPort = Configuration.GetValue <int>("GatewayPort"); if (string.IsNullOrWhiteSpace(Endpoint)) { builder.ConfigureEndpoints(SiloPort ?? siloPort, GatewayPort ?? gatewayPort); } else { builder.ConfigureEndpoints(Endpoint, SiloPort ?? siloPort, GatewayPort ?? gatewayPort); } if (Dashboard) { builder.UseDashboard(options => options.HostSelf = false); } }
private static void ConfigureOrleans(HostBuilderContext hostBuilderContext, ISiloBuilder siloBuilder) { siloBuilder.ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().WithCodeGeneration()) .AddStartupTask <HostStartupTask>() .UseLocalhostClustering() .AddMemoryGrainStorageAsDefault(); }
// This method gets called from Program.cs public static void ConfigureOrleans(HostBuilderContext hostBuilderContext, ISiloBuilder siloBuilder) { var config = new AppConfig(hostBuilderContext.Configuration); siloBuilder .Configure <ClusterOptions>(options => { options.ClusterId = "DevOpsLab"; options.ServiceId = "DevOpsLab.Server"; }) .Configure <ClusterMembershipOptions>(options => { // ADO.NET cluster membership provider does not support Defunct Silo Cleanup options.DefunctSiloCleanupPeriod = TimeSpan.MaxValue; }) .UseAdoNetClustering(options => { options.Invariant = "Npgsql"; options.ConnectionString = config.ConnectionString; }) .UseAdoNetReminderService(options => { options.Invariant = "Npgsql"; options.ConnectionString = config.ConnectionString; }) .ConfigureApplicationParts(parts => { parts.AddApplicationPart(typeof(MembershipTableCleanupGrain).Assembly).WithReferences(); }) .ConfigureEndpoints(5010, 5011); }
private static void ConfigureServices(Microsoft.Extensions.Hosting.HostBuilderContext context, IServiceCollection services) { services.AddOptions(); services.Configure <PersistenceOptions>(context.Configuration.GetSection("persistenceOptions")); services.Configure <ServerOptions>(context.Configuration.GetSection("serverOptions")); services.AddTransient <IMessageRepository, MessageRepository>(); }
private static void ConfigureSiloBuilder( Microsoft.Extensions.Hosting.HostBuilderContext context, ISiloBuilder siloBuilder) => siloBuilder // Prevent the silo from automatically stopping itself when the cancel key is pressed. .Configure <ProcessExitHandlingOptions>(options => options.FastKillOnProcessExit = false) .ConfigureServices( (context, services) => { services.Configure <ApplicationOptions>(context.Configuration); services.Configure <ClusterOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Cluster))); services.Configure <StorageOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Storage))); #if ApplicationInsights services.Configure <ApplicationInsightsTelemetryConsumerOptions>( context.Configuration.GetSection(nameof(ApplicationOptions.ApplicationInsights))); #endif }) .UseSiloUnobservedExceptionsHandler() .UseAzureStorageClustering( options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) .ConfigureEndpoints( EndpointOptions.DEFAULT_SILO_PORT, EndpointOptions.DEFAULT_GATEWAY_PORT, listenOnAnyHostAddress: !context.HostingEnvironment.IsDevelopment()) .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(HelloGrain).Assembly).WithReferences()) #if ApplicationInsights .AddApplicationInsightsTelemetryConsumer() #endif .AddAzureTableGrainStorageAsDefault( options => { options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJson = true; }) .UseAzureTableReminderService( options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) .UseTransactions(withStatisticsReporter: true) .AddAzureTableTransactionalStateStorageAsDefault( options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) .AddSimpleMessageStreamProvider(StreamProviderName.Default) .AddAzureTableGrainStorage( "PubSubStore", options => { options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJson = true; }) .UseIf( RuntimeInformation.IsOSPlatform(OSPlatform.Linux), x => x.UseLinuxEnvironmentStatistics()) .UseIf( RuntimeInformation.IsOSPlatform(OSPlatform.Windows), x => x.UsePerfCounterEnvironmentStatistics()) .UseDashboard();
private static Orleans.Hosting.HostBuilderContext GetContext(Microsoft.Extensions.Hosting.HostBuilderContext ctx) { var siloContext = new Orleans.Hosting.HostBuilderContext(ctx.Properties) { Configuration = ctx.Configuration, HostingEnvironment = new HostingEnvironmentAdapter(ctx.HostingEnvironment) }; return(siloContext); }
private static void ConfigureOrleans(HostBuilderContext hostBuilderContext, ISiloBuilder siloBuilder) { siloBuilder .ConfigureServices((context, services) => { services.Configure <AdoNetGrainStorageOptions>("Default", context.Configuration.GetSection("Options:Persistence:Default")); }) .AddStartupTask <HostStartup>() .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().WithCodeGeneration()) .UseLocalhostClustering() .AddAdoNetGrainStorage("Default"); }
private static void ConfigureOrleans(HostBuilderContext hostBuilderContext, ISiloBuilder siloBuilder) { siloBuilder .ConfigureServices(services => { services.AddSingleton <IIncomingGrainCallFilter, GrainLoggingIncomingCallFilter>(); services.AddSingleton <IOutgoingGrainCallFilter, GrainLoggingOutgoingCallFilter>(); }) .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().WithCodeGeneration()) .UseLocalhostClustering() .AddStartupTask <HostStartUp>(); // or .AddIncomingGrainCallFilter<GrainLoggingCallFilter>(); }
private void BuildAppConfiguration(HostBuilderContext context, IConfigurationBuilder builder) { var environmentName = EnvironmentVariable ?? Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT", EnvironmentVariableTarget.Machine) ?? "Production"; builder.SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile($"appsettings.{environmentName}.json") .AddJsonFile($"appsettings.json") .AddEnvironmentVariables(); var settingPath = Path.Combine(Environment.CurrentDirectory, "settings"); var files = Directory.GetFiles(settingPath, "*.json", SearchOption.AllDirectories); Array.ForEach(files, p => builder.AddJsonFile(p)); Configuration = builder.Build(); }
public void Build(Microsoft.Extensions.Hosting.HostBuilderContext context, IServiceCollection serviceCollection) { foreach (var configurationDelegate in this.configureSiloDelegates) { configurationDelegate(context, this); } serviceCollection.AddHostedService <SiloHostedService>(); foreach (var configurationDelegate in this.configureServicesDelegates) { configurationDelegate(context, serviceCollection); } }
public void Build(Microsoft.Extensions.Hosting.HostBuilderContext context, IServiceCollection serviceCollection) { foreach (var configurationDelegate in this.configureClusterDelegates) { configurationDelegate(context, this); } serviceCollection.AddHostedService <ProtoActorHostedService>(); this.ConfigureDefaults(); foreach (var configurationDelegate in this.configureServicesDelegates) { configurationDelegate(context, serviceCollection); } }
private void BuildOrleans(HostBuilderContext context, ISiloBuilder builder) { var mongoConfig = Configuration.GetSection(nameof(MongoDBOptions)); var clusterConfig = Configuration.GetSection(nameof(ClusterOptions)); var membershipOptions = Configuration.GetSection(nameof(MongoDBMembershipTableOptions)); var remindableOptions = Configuration.GetSection(nameof(MongoDBRemindersOptions)); var storageOptions = mongoConfig.Get <MongoDBGrainStorageOptions>(); var adoNetOptions = Configuration.GetSection("AdoNetOptions").Get <AdoNetGrainStorageOptions>(); var mongodbConnection = Configuration.GetSection("MongoDBConnection").Get <string>(); void ConfigureStorage(MongoDBGrainStorageOptions options) { options.CollectionPrefix = storageOptions.CollectionPrefix; options.ClientName = storageOptions.ClientName; options.DatabaseName = storageOptions.DatabaseName; } builder .Configure <ClusterOptions>(clusterConfig) .Configure <MongoDBOptions>(mongoConfig) .Configure <SchedulingOptions>(options => options.PerformDeadlockDetection = true) .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().WithReferences()) .UseSiloUnobservedExceptionsHandler() //EntityFramework .AddDBContexts <ApplicationDbContext>(adoNetOptions.ConnectionString) //ConsistencyProvider .AddLogStorageBasedLogConsistencyProvider() .AddStateStorageBasedLogConsistencyProvider() .AddCustomStorageBasedLogConsistencyProvider("CustomStorage") //MongoDB .UseMongoDbAccessor() .UseMongoDBMembershipTable(membershipOptions) .UseMongoDBReminders(remindableOptions) .UseMongoDBClient(mongodbConnection) .AddMongoDBGrainStorage("Default", ConfigureStorage) .AddMongoDBGrainStorage("PubSubStore", ConfigureStorage) .AddMongoDBGrainStorage("MongoDb", ConfigureStorage) //SMS .AddSimpleMessageStreamProvider("SMS", options => options.FireAndForgetDelivery = true); ProcessCommand(context, builder); }
private static void ConfigureOrleans(HostBuilderContext hostBuilder, ISiloBuilder siloBuilder) { siloBuilder .AddStartupTask <HostStartupTask>() .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().WithCodeGeneration()) .UseLocalhostClustering() .Configure <ClusterOptions>(options => { options.ServiceId = "HelloStateless"; options.ClusterId = hostBuilder.Configuration["ClusterId"]; }) .Configure <EndpointOptions>(options => { options.AdvertisedIPAddress = IPAddress.Loopback; options.SiloPort = int.Parse(hostBuilder.Configuration["SiloPort"]); options.GatewayPort = int.Parse(hostBuilder.Configuration["GatewayPort"]); }); }
private static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder builder) { builder.AddConsole() .AddSentry(Dsn) .AddConfiguration(context.Configuration.GetSection("Logging")); if (context.HostingEnvironment.IsDevelopment()) { builder.AddFile( o => { o.BasePath = "logs"; o.EnsureBasePath = true; o.FallbackFileName = $"server-{Assembly.GetExecutingAssembly().GetName().Version}-{DateTime.Now:yyyy-dd-M-HH-mm-ss}.log"; }); } }
private static void ConfigureOrleans(HostBuilderContext hostBuilderContext, ISiloBuilder siloBuilder) { siloBuilder .AddStartupTask <HostStartupTask>() .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().WithCodeGeneration()) .Configure <MultiClusterOptions>(options => { options.HasMultiClusterNetwork = true; options.BackgroundGossipInterval = TimeSpan.FromSeconds(10); options.UseGlobalSingleInstanceByDefault = false; }) .Configure <ClusterOptions>(options => { options.ServiceId = "HelloMultiClusters"; options.ClusterId = hostBuilderContext.Configuration["ClusterId"]; }) .Configure <EndpointOptions>(options => { options.AdvertisedIPAddress = IPAddress.Loopback; options.SiloPort = int.Parse(hostBuilderContext.Configuration["SiloPort"]); options.GatewayPort = int.Parse(hostBuilderContext.Configuration["GatewayPort"]); }) .UseAdoNetClustering(options => { var config = hostBuilderContext.Configuration.GetSection("Options:Cluster:Default"); options.Invariant = config["Invariant"]; options.ConnectionString = config["ConnectionString"]; }) .Configure <GrainCollectionOptions>(options => { options.CollectionAge = TimeSpan.Parse("00:01:01"); }); if (hostBuilderContext.Configuration["DashboardPort"] != null) { siloBuilder.UseDashboard(options => { options.Host = "*"; options.HostSelf = true; options.Port = int.Parse(hostBuilderContext.Configuration["DashboardPort"]); options.CounterUpdateIntervalMs = 1000; }); } }
private static void ConfigureSiloBuilder( Microsoft.Extensions.Hosting.HostBuilderContext context, ISiloBuilder siloBuilder) => siloBuilder // Prevent the silo from automatically stopping itself when the cancel key is pressed. .Configure <ProcessExitHandlingOptions>(options => options.FastKillOnProcessExit = false) .ConfigureServices( (context, services) => { services.Configure <ApplicationOptions>(context.Configuration); services.Configure <ClusterOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Cluster))); services.Configure <StorageOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Storage))); }) .UseSiloUnobservedExceptionsHandler() .UseLocalhostClustering() .Configure <EndpointOptions>(options => options.AdvertisedIPAddress = IPAddress.Loopback) .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(HelloGrain).Assembly).WithReferences()) .AddAzureTableGrainStorageAsDefault( options => { options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJson = true; }) .UseAzureTableReminderService(options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) .AddSimpleMessageStreamProvider(StreamProviderName.Default) .AddAzureTableGrainStorage( "PubSubStore", options => { options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJson = true; }) .UseIf( RuntimeInformation.IsOSPlatform(OSPlatform.Linux), x => x.UseLinuxEnvironmentStatistics()) .UseIf( RuntimeInformation.IsOSPlatform(OSPlatform.Windows), x => x.UsePerfCounterEnvironmentStatistics()) .UseDashboard();
private static void ConfigureSilo(Microsoft.Extensions.Hosting.HostBuilderContext hostBuilderContext, ISiloBuilder siloBuilder) { // var orleansOptions = new OrleansOptions(); hostBuilderContext.Configuration.GetSection("Orleans").Bind(orleansOptions); siloBuilder .UseLocalhostClustering(serviceId: Constants.ServiceId, clusterId: Constants.ServiceId) .AddAzureTableGrainStorage(Constants.Store, (options) => { options.UseJson = true; options.ConnectionString = orleansOptions.DataConnectionString; }) .ConfigureApplicationParts((parts) => { parts.AddApplicationPart(typeof(BuildNRun.Model.AccountGrain).Assembly).WithReferences(); }) //.UseAzureTableReminderService(options => { // options.ConnectionString = orleansOptions.DataConnectionString; //}) //.UseInMemoryReminderService() ; }
private void BuildServices(HostBuilderContext context, IServiceCollection services) { if (HealthCheck) { services.Configure <ConsoleLifetimeOptions>(options => { options.SuppressStatusMessages = true; }) .Configure <HealthCheckHostedServiceOptions>(options => { options.Port = Configuration.GetValue <int>("HealthCheckPort"); options.PathString = "/health"; }) .AddHostedService <HealthCheckHostedService>(); } services.ConfigureHandlers <ICommandHandler>(context); services.ConfigureExcelFilesReader(Configuration.GetSection(nameof(ExcelReaderOptions))); services.Configure <OidcOptions>(Configuration.GetSection(nameof(OidcOptions))); services.Configure <ValidateCodeOptions>(Configuration.GetSection(nameof(ValidateCodeOptions))); }
private static void ConfigureServices(Microsoft.Extensions.Hosting.HostBuilderContext ctx, IServiceCollection services) { // Orleans Client services.AddDefaultClusterClient((builder, sp) => { builder.UseLocalhostClustering() .AddAssemblies(typeof(ISMSProviderProducerGrain)) .AddSimpleMessageStreamProvider(Constants.SMSProviderName) .AddKafka(Constants.KafkaProviderName) .WithOptions(options => { options.FromConfiguration(ctx.Configuration); options.ConsumeMode = ConsumeMode.StreamStart; options .AddTopicStream(Constants.MessageNamespace, ctx.Configuration); }) .AddJson() .Build(); }); }
public static void ConfigureSilo(this ISiloBuilder builder, Microsoft.Extensions.Hosting.HostBuilderContext context) { builder.ConfigureSilo(context.Configuration); }
private static void ConfigureApp(HostBuilderContext hostBuilderContext, IConfigurationBuilder configurationBuilder) { configurationBuilder .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json"); }
private static void ConfigureSiloBuilder( Microsoft.Extensions.Hosting.HostBuilderContext context, ISiloBuilder siloBuilder) => siloBuilder .ConfigureServices( (context, services) => { services.Configure <ApplicationOptions>(context.Configuration); services.Configure <ClusterOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Cluster))); services.Configure <StorageOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Storage))); }) .UseSiloUnobservedExceptionsHandler() //.UseAzureStorageClustering( // options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) #region custom .UseAdoNetClustering(options => { options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; options.Invariant = "System.Data.SqlClient"; }) #endregion .Configure <ClusterOptions>(options => { options.ClusterId = Cluster.ClusterId; options.ServiceId = Cluster.ServiceId; }) .ConfigureEndpoints( EndpointOptions.DEFAULT_SILO_PORT, EndpointOptions.DEFAULT_GATEWAY_PORT, listenOnAnyHostAddress: !context.HostingEnvironment.IsDevelopment()) .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(HelloGrain).Assembly).WithReferences()) //.AddAzureTableGrainStorageAsDefault( // options => // { // options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; // options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; // options.UseJson = true; // }) #region custom .AddAdoNetGrainStorageAsDefault( options => { options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJsonFormat = true; } ) #endregion //.UseAzureTableReminderService( // options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) //.UseTransactions(withStatisticsReporter: true) //.AddAzureTableTransactionalStateStorageAsDefault( // options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) //.AddSimpleMessageStreamProvider(StreamProviderName.Default) //.AddAzureTableGrainStorage( // "PubSubStore", // options => // { // options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; // options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; // options.UseJson = true; // }) //.UseIf( // RuntimeInformation.IsOSPlatform(OSPlatform.Linux), // x => x.UseLinuxEnvironmentStatistics()) //.UseIf( // RuntimeInformation.IsOSPlatform(OSPlatform.Windows), // x => x.UsePerfCounterEnvironmentStatistics()) #region custom .UseAdoNetReminderService(options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString) .UseTransactions(withStatisticsReporter: true) //.AddAzureTableTransactionalStateStorageAsDefault() .AddSimpleMessageStreamProvider(StreamProviderName.Default) .AddAdoNetGrainStorage("PubSubStore", options => { options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJsonFormat = true; }) .UseIf(RuntimeInformation.IsOSPlatform(OSPlatform.Linux), x => x.UseLinuxEnvironmentStatistics()) .UseIf(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), x => x.UsePerfCounterEnvironmentStatistics()) #endregion .UseDashboard();
private static void ConfigureSiloBuilder( Microsoft.Extensions.Hosting.HostBuilderContext context, ISiloBuilder siloBuilder) => siloBuilder .Configure <SerializationProviderOptions>(opt => opt.SerializationProviders.Add(typeof(ProtobufNetSerializer).GetTypeInfo())) .Configure <ClusterMembershipOptions>(opt => { opt.DefunctSiloExpiration = TimeSpan.FromHours(1); opt.DefunctSiloCleanupPeriod = TimeSpan.FromHours(1); }) #if DEBUG #else .Configure <EndpointOptions>(options => { var lst = Dns.GetHostEntry("appnode").AddressList; foreach (var item in lst) { Console.WriteLine(item.ToString()); } options.SiloPort = 11111; options.GatewayPort = 30000; options.AdvertisedIPAddress = Dns.GetHostAddresses("appnode").First(); options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, 40000); options.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, 50000); }) #endif .ConfigureServices( (context, services) => { var CircuitBreakerOpenTriggerCount = context.Configuration.GetSection("PollySetting:CircuitBreakerOpenTriggerCount").Get <int>(); //通用策略 services.AddHttpClientPolly(PollyHttpClientServiceCollectionExtensions.HttpclientName, options => { options.TimeoutTime = context.Configuration.GetSection("PollySetting:TimeoutTime").Get <int>(); options.RetryCount = context.Configuration.GetSection("PollySetting:RetryCount").Get <int>(); options.CircuitBreakerOpenFallCount = context.Configuration.GetSection("PollySetting:CircuitBreakerOpenFallCount").Get <int>(); options.CircuitBreakerDownTime = context.Configuration.GetSection("PollySetting:CircuitBreakerDownTime").Get <int>(); options.CircuitBreakerAction = (p => { int rcount = (int)p; if (rcount == CircuitBreakerOpenTriggerCount) { Environment.Exit(0); //断路器触发超过CircuitBreakerOpenTriggerCount次-退出程序 } }); }); services.AddSingleton <MsvClientCtrlSDK>(); services.AddSingleton <RestClient>(pd => { return(new RestClient(pd.GetService <IHttpClientFactory>().CreateClient(PollyHttpClientServiceCollectionExtensions.HttpclientName), context.Configuration.GetSection("IngestDBSvr").Value, context.Configuration.GetSection("CMServer").Value)); }); //services.AddSingleton<IDeviceMonitorService, DeviceMonitorService>(); services.AddSingleton <IDeviceMonitorClient, DeviceMonitorClient>(); services.AddSingleton <IGrainServiceDataBack, GrainServiceDataBack>(); services.AddTransient <ITaskHandlerFactory, TaskHandlerFactory>(sp => TaskHandlerFactory.Create(sp)); services.Configure <ApplicationOptions>(context.Configuration); services.Configure <ClusterOptions>(opt => { opt.ClusterId = Cluster.ClusterId; opt.ServiceId = Cluster.ServiceId; }); services.AddSingletonNamedService <PlacementStrategy, ScheduleTaskPlacementStrategy>(nameof(ScheduleTaskPlacementStrategy)); services.AddSingletonKeyedService <Type, IPlacementDirector, ScheduleTaskPlacementSiloDirector>(typeof(ScheduleTaskPlacementStrategy)); //services.BuildServiceProvider(); }) .UseSiloUnobservedExceptionsHandler() .UseAdoNetClustering( options => { options.Invariant = "MySql.Data.MySqlClient"; options.ConnectionString = context.Configuration.GetSection("ConnectDB").Value; }) #if DEBUG .ConfigureEndpoints( EndpointOptions.DEFAULT_SILO_PORT, EndpointOptions.DEFAULT_GATEWAY_PORT ) #endif .AddAdoNetGrainStorageAsDefault( options => { options.Invariant = "MySql.Data.MySqlClient"; options.ConnectionString = context.Configuration.GetSection("ConnectDB").Value; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJsonFormat = true; } ) .UseAdoNetReminderService( options => { options.Invariant = "MySql.Data.MySqlClient"; options.ConnectionString = context.Configuration.GetSection("ConnectDB").Value; }) .AddSimpleMessageStreamProvider(StreamProviderName.Default) .AddAdoNetGrainStorage( "PubSubStore", options => { options.Invariant = "MySql.Data.MySqlClient"; options.ConnectionString = context.Configuration.GetSection("ConnectDB").Value; options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings; options.UseJsonFormat = true; }) .AddGrainService <DeviceMonitorService>() .UseIf( RuntimeInformation.IsOSPlatform(OSPlatform.Linux), x => x.UseLinuxEnvironmentStatistics()) .UseIf( RuntimeInformation.IsOSPlatform(OSPlatform.Windows), x => x.UsePerfCounterEnvironmentStatistics()) .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(HelloGrain).Assembly).WithReferences()) .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory()) .UseDashboard(config => { config.Port = int.Parse(context.Configuration.GetSection("Port").Value, CultureInfo.CurrentCulture); });