예제 #1
0
파일: Startup.cs 프로젝트: lulzzz/piraeus-1
        public void ConfigureServices(IServiceCollection services)
        {
            pconfig = GetPiraeusConfig();
            config  = GetOrleansConfig();
            //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = !string.IsNullOrEmpty(pconfig.ClientIssuer),
                    ValidateAudience         = !string.IsNullOrEmpty(pconfig.ClientAudience),
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,


                    ValidIssuer      = pconfig.ClientIssuer,
                    ValidAudience    = pconfig.ClientAudience,
                    ClockSkew        = TimeSpan.FromMinutes(5.0),
                    IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(pconfig.ClientSymmetricKey))
                };
            });
            services.AddSingleton <PiraeusConfig>(pconfig);
            services.AddSingleton <IClusterClient>(CreateClusterClient);
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            //services.AddPiraeusWebSocket();

            services.AddRouting();
            services.AddMvcCore();
        }
    /// <summary>
    /// Configures clustering for the Orleans Client based on
    /// the Orleans environment.
    /// </summary>
    /// <param name="builder">The client builder.</param>
    /// <param name="orleansConfig">The Orleans configuration.</param>
    /// <param name="environmentName">The environment.</param>
    public static IClientBuilder ConfigureClustering(
        this IClientBuilder builder,
        OrleansConfig orleansConfig,
        string environmentName
        )
    {
        if (builder == null)
        {
            throw new ArgumentNullException(nameof(builder));
        }

        builder.UseLocalhostClustering();

        //            switch (environmentName.ToLower())
        //            {
        //                case "dev":
        //                    builder.UseLocalhostClustering();
        //                    break;
        //                default:
        //                    var orleansConfig = orleansConfigOptions.Value;
        //                    List<IPEndPoint> nodes = new List<IPEndPoint>();
        //                    foreach (var node in orleansConfig.NodeIpAddresses)
        //                    {
        //                        nodes.Add(new IPEndPoint(IPAddress.Parse(node), orleansConfig.GatewayPort));
        //                    }
        //                    builder.UseStaticClustering(nodes.ToArray());
        //                    break;
        //            }

        return(builder);
    }
예제 #3
0
파일: Program.cs 프로젝트: lulzzz/piraeus-1
        private static IClusterClient GetClient(OrleansConfig config)
        {
            if (!config.Dockerized)
            {
                var client = new ClientBuilder()
                             .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPiSystem).Assembly))
                             .UseLocalhostClustering()
                             .Build();

                return(client);
            }
            else if (config.ClusterId != null)// && config.OrleansDataProviderType == "AzureStore")
            {
                var client = new ClientBuilder()
                             .Configure <ClusterOptions>(options =>
                {
                    options.ClusterId = config.ClusterId;
                    options.ServiceId = config.ServiceId;
                })
                             .UseAzureStorageClustering(options => options.ConnectionString = config.DataConnectionString)
                             .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPiSystem).Assembly))
                             .ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning))
                             .Build();

                return(client);
            }
            else
            {
                throw new InvalidOperationException("Invalid configuration for Orleans client");
            }
        }
예제 #4
0
        public static IHostBuilder CreateHostBuilder(string[] args)
        {
            return(Host.CreateDefaultBuilder(args)
                   .ConfigureLogging(builder =>
            {
                OrleansConfig orleansConfig = GetOrleansConfiguration();
                LogLevel orleansLogLevel = Enum.Parse <LogLevel>(orleansConfig.LogLevel, true);
                LoggerType loggers = orleansConfig.GetLoggerTypes();

                if (loggers.HasFlag(LoggerType.Console))
                {
                    builder.AddConsole();
                }

                if (loggers.HasFlag(LoggerType.Debug))
                {
                    builder.AddDebug();
                }

                if (loggers.HasFlag(LoggerType.AppInsights) &&
                    !string.IsNullOrEmpty(orleansConfig.InstrumentationKey))
                {
                    builder.AddApplicationInsights(orleansConfig.InstrumentationKey);
                }

                builder.SetMinimumLevel(orleansLogLevel);
                builder.Services.AddSingleton <ILog, Logger>();
            })
                   .ConfigureServices((hostContext, services) =>
            {
                services.AddOrleansConfiguration();
                services.AddSingleton <Logger>();              //add the logger
                services.AddHostedService <SiloHostService>(); //start the silo host
            }));
        }
예제 #5
0
    private static async Task <IClusterClient> StartClientWithRetries(string env, OrleansConfig orleansConfig)
    {
        attempt = 0;
        IClusterClient client;

        client = new ClientBuilder()
                 .ConfigureClustering(
            orleansConfig,
            env
            )
                 .Configure <ClusterOptions>(options =>
        {
            options.ClusterId = "dev";
            options.ServiceId = "HelloWorldApp";
        })
                 .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IGrainInterfaceMarker).Assembly).WithReferences())
                 // I don't want the chatter of logging from the client for now.
                 //.ConfigureLogging(logging => logging.AddConsole())
                 .Build();

        await client.Connect(RetryFilter);

        Console.WriteLine("Client successfully connect to silo host");
        return(client);
    }
예제 #6
0
        public static ISiloHostBuilder AddLoggers(this ISiloHostBuilder siloBuilder, OrleansConfig config)
        {
            LoggerType loggerType = config.GetLoggerTypes();

            siloBuilder.ConfigureLogging(builder =>
            {
                if (loggerType.HasFlag(LoggerType.Console))
                {
                    builder.AddConsole();
                }

                if (loggerType.HasFlag(LoggerType.Debug))
                {
                    builder.AddDebug();
                }

                builder.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel));
            });

            if (loggerType.HasFlag(LoggerType.AppInsights))
            {
                siloBuilder.AddApplicationInsightsTelemetryConsumer(config.AppInsightsKey);
            }

            return(siloBuilder);
        }
예제 #7
0
 public UdpGatewayHost(PiraeusConfig config, OrleansConfig orleansConfig, Logger logger)
 {
     this.config        = config;
     this.orleansConfig = orleansConfig;
     this.logger        = logger;
     sources            = new Dictionary <int, CancellationTokenSource>();
     listeners          = new Dictionary <int, UdpServerListener>();
 }
예제 #8
0
        /// <summary>
        /// Creates a singleton of the GraphManager
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        /// <remarks>This will mean that only 1 IClusterClient will be used.</remarks>
        public static GraphManager Create(OrleansConfig config)
        {
            if (instance == null)
            {
                instance = new GraphManager(config);
            }

            return(instance);
        }
        public static IConfigurationBuilder AddOrleansConfiguration(this IConfigurationBuilder configure, out OrleansConfig orleansConfig)
        {
            configure.AddJsonFile("./orleansconfig.json")
            .AddEnvironmentVariables("OR_");
            IConfigurationRoot root = configure.Build();

            orleansConfig = new OrleansConfig();
            ConfigurationBinder.Bind(root, orleansConfig);
            return(configure);
        }
예제 #10
0
 public PiraeusGatewayOptions(OrleansConfig config)
 {
     Dockerized           = config.Dockerized;
     ClusterId            = config.ClusterId;
     ServiceId            = config.ServiceId;
     DataConnectionString = config.DataConnectionString;
     AppInsightKey        = config.AppInsightsKey;
     LoggerTypes          = config.GetLoggerTypes();
     LoggingLevel         = Enum.Parse <LogLevel>(config.LogLevel);
     SetStorageType();
 }
예제 #11
0
        public OrleansSiloHost(
            ILogger <OrleansSiloHost> logger,
            IConfiguration configuration,
            IOptions <OrleansConfig> orleansConfig)
        {
            _logger = logger;
            _logger.LogInformation("Orleans Silo initializing.");

            _configuration = configuration;
            _orleansConfig = orleansConfig.Value;
        }
예제 #12
0
        private static OrleansConfig GetOrleansConfiguration()
        {
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .AddJsonFile("./orleansconfig.json")
                                            .AddEnvironmentVariables("OR_");
            IConfigurationRoot root   = builder.Build();
            OrleansConfig      config = new OrleansConfig();

            root.Bind(config);
            return(config);
        }
예제 #13
0
        //private static ILoggerFactory CreateLoggerFactory(IServiceProvider serviceProvider)
        //{

        //    OrleansConfig config = serviceProvider.GetService<OrleansConfig>();
        //    ILoggerFactory loggerFactory = new LoggerFactory();
        //    LogLevel logLevel = Enum.Parse<LogLevel>(config.LogLevel, true);
        //    string[] loggerTypes = config.LoggerTypes?.Split(";", StringSplitOptions.RemoveEmptyEntries);

        //    if(HasLoggerType(config, "console"))
        //    {
        //        loggerFactory.AddConsole(logLevel);
        //    }

        //    if (HasLoggerType(config, "debug"))
        //    {
        //        loggerFactory.AddDebug(logLevel);
        //    }

        //    if(HasLoggerType(config, "appinsights"))
        //    {
        //        AppInsightsOptions appOptions = new AppInsightsOptions()
        //        {
        //            DeveloperMode = false,
        //            InstrumentationKey = config.AppInsightsKey

        //        };

        //        loggerFactory.AddAppInsights(appOptions);
        //    }

        //    return loggerFactory;
        //}

        private static IClusterClient CreateClusterClient(IServiceProvider serviceProvider)
        {
            OrleansConfig config      = serviceProvider.GetService <OrleansConfig>();
            string        storageType = GetStorageType(config.DataConnectionString);

            TcpGatewayOptions options = serviceProvider.GetOptionsByName <TcpGatewayOptions>("TcpGatewayOptions");

            if (config.Dockerized)
            {
                var localClient = new ClientBuilder()
                                  .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPiSystem).Assembly))
                                  .UseLocalhostClustering()
                                  .Build();

                localClient.Connect(RetryFilter).GetAwaiter();
                return(localClient);
            }
            else
            {
                var client = new ClientBuilder()
                             .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPiSystem).Assembly))
                             .Configure <testME.ClusterOptions>(op =>
                {
                    op.ClusterId = config.ClusterId;
                    op.ServiceId = config.ServiceId;
                });



                if (HasLoggerType(config, "appinsights"))
                {
                    client.AddApplicationInsightsTelemetryConsumer(config.AppInsightsKey);
                }

                if (storageType == "Redis")
                {
                    ILoggerFactory loggerFactory = serviceProvider.GetService <ILoggerFactory>();
                    ILogger <RedisGatewayListProvider> logger = loggerFactory.CreateLogger <RedisGatewayListProvider>();
                    client.UseRedisGatewayListProvider(logger, op =>
                                                       op.ConnectionString = config.DataConnectionString
                                                       );
                }
                else if (storageType == "AzureStorage")
                {
                    client.UseAzureStorageClustering(op => op.ConnectionString = config.DataConnectionString);
                }

                IClusterClient clusterClient = client.Build();

                clusterClient.Connect(RetryFilter).GetAwaiter();
                return(clusterClient);
            }
        }
예제 #14
0
파일: Startup.cs 프로젝트: lulzzz/piraeus-1
        private OrleansConfig GetOrleansConfig()
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile(Environment.CurrentDirectory + "\\orleansconfig.json")
                          .AddEnvironmentVariables("OR_");

            IConfigurationRoot root   = builder.Build();
            OrleansConfig      config = new OrleansConfig();

            ConfigurationBinder.Bind(root, config);

            return(config);
        }
예제 #15
0
        public OrleansConfig GetOrlConfig()
        {
            OrleansConfig dc = new OrleansConfig();

            dc.NodeIpAddresses = new List <string>();
            string nid = _config.GetValue <string>("OrleansConfig:NodeIpAddresses");

            string[] nidip = nid.Split(',');
            dc.NodeIpAddresses = nidip.ToList <string>();
            dc.GatewayPort     = _config.GetValue <int>("OrleansConfig:GatewayPort");
            dc.SiloPort        = _config.GetValue <int>("OrleansConfig:SiloPort");
            return(dc);
        }
예제 #16
0
        public static IServiceCollection AddOrleansConfiguration(this IServiceCollection services)
        {
            IConfigurationBuilder builder = new ConfigurationBuilder();

            builder.AddJsonFile(Environment.CurrentDirectory + "\\orleansconfig.json")
            .AddEnvironmentVariables("OR_");
            IConfigurationRoot root   = builder.Build();
            OrleansConfig      config = new OrleansConfig();

            ConfigurationBinder.Bind(root, config);
            services.AddSingleton <OrleansConfig>(config);

            return(services);
        }
예제 #17
0
        public void ConfigureServices(IServiceCollection services)
        {
            OrleansConfig oconfig = null;
            PiraeusConfig pconfig = null;

            //LoggerFactory loggerFactory = new LoggerFactory();

            IConfigurationBuilder configBuilder = new ConfigurationBuilder();

            configBuilder.AddOrleansConfiguration(out oconfig);
            configBuilder.AddPiraeusConfiguration(out pconfig);

            PiraeusGatewayOptions pgo = new PiraeusGatewayOptions(oconfig);
            //services.AddGatewayService(typeof(TcpGatewayService), null);

            //services.AddOrleansConfiguration();
            //services.AddPiraeusConfiguration();
            //services.AddOrleansClusterClient(loggerFactory, options => options.IsLocal = false);

            IServiceProvider sp         = services.BuildServiceProvider();
            LoggerType       loggerType = oconfig.GetLoggerTypes();

            if (!loggerType.HasFlag(LoggerType.None))
            {
                services.AddLogging(builder =>
                {
                    if (loggerType.HasFlag(LoggerType.Console))
                    {
                        builder.AddConsole();
                    }
                    if (loggerType.HasFlag(LoggerType.Debug))
                    {
                        builder.AddDebug();
                    }
                    if (loggerType.HasFlag(LoggerType.AppInsights) && !string.IsNullOrEmpty(oconfig.AppInsightsKey))
                    {
                        builder.AddApplicationInsights(oconfig.AppInsightsKey);
                    }

                    builder.SetMinimumLevel(LogLevel.Warning);
                });
            }

            TcpGatewayService tgs = sp.GetRequiredService <TcpGatewayService>();

            tgs.Init(oconfig.Dockerized);

            //services.AddSingleton<TcpGatewayService>((f) => f.GetRequiredService<TcpGatewayService>());
        }
예제 #18
0
        public static IServiceCollection AddOrleansConfiguration(this IServiceCollection services,
                                                                 out OrleansConfig config)
        {
            IConfigurationBuilder builder = new ConfigurationBuilder();

            builder.AddJsonFile("./orleansconfig.json")
            .AddEnvironmentVariables("OR_");
            IConfigurationRoot root = builder.Build();

            config = new OrleansConfig();
            root.Bind(config);
            services.AddSingleton(config);

            return(services);
        }
예제 #19
0
파일: Host.cs 프로젝트: lulzzz/piraeus-1
        public void Init()
        {
            orleansConfig = GetOrleansConfiguration();

            if (orleansConfig.Dockerized)
            {
                CreateClusteredSiloHost();
            }
            else
            {
                CreateLocalSiloHost();
            }

            host.StartAsync().GetAwaiter();
        }
예제 #20
0
파일: Startup.cs 프로젝트: lulzzz/piraeus-1
        public void ConfigureServices(IServiceCollection services)
        {
            OrleansConfig oconfig = null;

            IConfigurationBuilder configBuilder = new ConfigurationBuilder();

            configBuilder.AddOrleansConfiguration(out oconfig);
            ServiceDescriptor sd = new ServiceDescriptor(typeof(Host), new Host());

            services.Add(sd);

            IServiceProvider sp = services.BuildServiceProvider();

            host = sp.GetRequiredService <Host>();
            host.Init();
        }
예제 #21
0
파일: Startup.cs 프로젝트: lulzzz/piraeus
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            config  = GetOrleansConfig();
            pconfig = GetPiraeusConfig();
            //Capl.Authorization.AuthorizationPolicy authzPolicy = GetCaplPolicy();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest)
            .AddXmlSerializerFormatters();


            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,

                    ValidIssuer      = pconfig.ManagementApiIssuer,
                    ValidAudience    = pconfig.ManagementApiAudience,
                    ClockSkew        = TimeSpan.FromMinutes(5.0),
                    IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(pconfig.ManagmentApiSymmetricKey))
                };
            });

            PskStorageAdapter pskAdpater = GetPskAdapter();


            if (pskAdpater != null)
            {
                services.AddSingleton <PskStorageAdapter>(pskAdpater);
            }

            services.AddSingleton <PiraeusConfig>(pconfig);
            services.AddSingleton <IClusterClient>(CreateClusterClient);
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddRouting();
            //services.AddAuthorization(options =>
            //{
            //    options.AddPolicy("Access", policy =>
            //        policy.Requirements.Add(new ApiAccessRequirement(authzPolicy)));
            //});
        }
예제 #22
0
        public TcpServerListener(IPEndPoint localEP, PiraeusConfig config, OrleansConfig orleansConfig, ILog logger = null, CancellationToken token = default)
        {
            serverIP           = localEP.Address;
            serverPort         = localEP.Port;
            listener           = new TcpListener(localEP);
            this.token         = token;
            dict               = new Dictionary <string, ProtocolAdapter>();
            this.config        = config;
            this.orleansConfig = orleansConfig;
            this.logger        = logger;

            if (config.ClientTokenType != null && config.ClientSymmetricKey != null)
            {
                SecurityTokenType  stt    = Enum.Parse <SecurityTokenType>(config.ClientTokenType, true);
                BasicAuthenticator bauthn = new BasicAuthenticator();
                bauthn.Add(stt, config.ClientSymmetricKey, config.ClientIssuer, config.ClientAudience);
                this.authn = bauthn;
            }
        }
예제 #23
0
        public void Init()
        {
            orleansConfig = GetOrleansConfiguration();

#if DEBUG
            CreateClusteredSiloHost();
#else
            CreateLocalSiloHost();
#endif
            //if (orleansConfig.Dockerized)
            //{
            //    CreateClusteredSiloHost();
            //}
            //else
            //{
            //    CreateLocalSiloHost();
            //}

            host.StartAsync().GetAwaiter();
        }
예제 #24
0
        public UdpServerListener(IPEndPoint localEP, PiraeusConfig config, OrleansConfig orleansConfig,
                                 ILog logger = null, CancellationToken token = default)
        {
            this.localEP = localEP;
            listener     = new UdpClient();
            this.token   = token;
            dict         = new Dictionary <string, ProtocolAdapter>();
            this.config  = config;
            this.logger  = logger;
            graphManager = new GraphManager(orleansConfig);

            if (config.ClientTokenType != null && config.ClientSymmetricKey != null)
            {
                SecurityTokenType  stt    = Enum.Parse <SecurityTokenType>(config.ClientTokenType, true);
                BasicAuthenticator bauthn = new BasicAuthenticator();
                bauthn.Add(stt, config.ClientSymmetricKey, config.ClientIssuer, config.ClientAudience);
                authn = bauthn;
            }

            cache = MemoryCache.Default;
        }
예제 #25
0
    /// <summary>
    /// Configures clustering for the Orleans Silo Host based on
    /// the Orleans environment.
    /// </summary>
    /// <param name="builder">The silo builder.</param>
    /// <param name="orleansConfig">The Orleans configuration.</param>
    /// <param name="environmentName">The environment.</param>
    public static ISiloBuilder ConfigureClustering(
        this ISiloBuilder builder,
        OrleansConfig orleansConfig,
        string environmentName
        )
    {
        if (builder == null)
        {
            throw new ArgumentNullException(nameof(builder));
        }

        builder.UseLocalhostClustering();
        builder.Configure <EndpointOptions>(options => options.AdvertisedIPAddress = IPAddress.Loopback);

        //            switch (environmentName.ToLower())
        //            {
        //                case "dev":
        //                    builder.UseLocalhostClustering();
        //                    builder.Configure<EndpointOptions>(options => options.AdvertisedIPAddress = IPAddress.Loopback);
        //                    break;
        //                default:
        //                    var orleansConfig = orleansConfigOptions.Value;
        //                    // Configure the first listed node as the "primary node".
        //                    // Note this type of configuration should probably not be used in prod - using HA clustering instead.
        //                    builder.UseDevelopmentClustering(
        //                        new IPEndPoint(
        //                            IPAddress.Parse(orleansConfig.NodeIpAddresses[0]),
        //                            orleansConfig.SiloPort
        //                        )
        //                    );
        //                    builder.ConfigureEndpoints(
        //                        siloPort: orleansConfig.SiloPort,
        //                        gatewayPort: orleansConfig.GatewayPort
        //                    );
        //                    break;
        //            }

        return(builder);
    }
예제 #26
0
        public TcpServerListener(IPAddress address, int port, PiraeusConfig config, OrleansConfig orleansConfig, ILog logger = null, CancellationToken token = default)
        {
            serverIP   = address;
            serverPort = port;
            listener   = new TcpListener(address, port)
            {
                ExclusiveAddressUse = false
            };
            this.token         = token;
            dict               = new Dictionary <string, ProtocolAdapter>();
            this.config        = config;
            this.orleansConfig = orleansConfig;
            this.logger        = logger;


            if (config.ClientTokenType != null && config.ClientSymmetricKey != null)
            {
                SecurityTokenType  stt    = (SecurityTokenType)System.Enum.Parse(typeof(SecurityTokenType), config.ClientTokenType, true);
                BasicAuthenticator bauthn = new BasicAuthenticator();
                bauthn.Add(stt, config.ClientSymmetricKey, config.ClientIssuer, config.ClientAudience);
                this.authn = bauthn;
            }
        }
예제 #27
0
 private static IHostBuilder CreateHostBuilder(string[] args, string env, IConfigurationRoot configurationRoot, OrleansConfig orleansConfig)
 {
     return(Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((context, builder) =>
     {
         context.HostingEnvironment.EnvironmentName = env;
         builder.AddConfiguration(configurationRoot);
     })
            .ConfigureServices(DependencyInjectionHelper.IocContainerRegistration)
            .ConfigureWebHostDefaults(builder => { builder.UseStartup <Startup>(); })
            .UseOrleans(siloBuilder =>
     {
         siloBuilder
         .ConfigureClustering(
             orleansConfig,
             env
             )
         .Configure <ClusterOptions>(options =>
         {
             options.ClusterId = "dev";
             options.ServiceId = "HelloWorldApp";
         })
         .AddMemoryGrainStorage(Constants.OrleansMemoryProvider)
         .ConfigureApplicationParts(parts =>
         {
             parts.AddApplicationPart(typeof(IGrainMarker).Assembly).WithReferences();
         })
         .UsePerfCounterEnvironmentStatistics()
         .UseDashboard(options => { })
         .UseInMemoryReminderService()
         .ConfigureLogging(logging =>
         {
             logging.SetMinimumLevel(LogLevel.Warning);
             logging.AddConsole();
         });
     }));
 }
예제 #28
0
 private static LogLevel GetLogLevel(OrleansConfig config)
 {
     return(Enum.Parse <LogLevel>(config.LogLevel, true));
 }
예제 #29
0
        //public static IServiceCollection AddOrleansClusterClient(this IServiceCollection services, ILoggerFactory loggerFactory,
        //    Action<TcpGatewayOptions> configureOptions)
        //{
        //    return services.AddOrleansClusterClient(loggerFactory, ob => ob.Configure(configureOptions));
        //}

        //public static IServiceCollection AddOrleansClusterClient(this IServiceCollection services, ILoggerFactory loggerFactory,
        //    Action<Microsoft.Extensions.Options.OptionsBuilder<TcpGatewayOptions>> configureOptions)
        //{
        //    configureOptions?.Invoke(services.AddOptions<TcpGatewayOptions>());
        //    //services.AddSingleton<ILoggerFactory>(CreateLoggerFactory);
        //    services.AddSingleton<IClusterClient>(CreateClusterClient);
        //    return services.AddSingleton<TcpGatewayService>();
        //}

        private static bool HasLoggerType(OrleansConfig config, string typeName)
        {
            string[] loggerTypes = config.LoggerTypes?.Split(";", StringSplitOptions.RemoveEmptyEntries);
            return(!string.IsNullOrEmpty(loggerTypes.Where((t) => t.ToLowerInvariant() == typeName).FirstOrDefault()));
        }
예제 #30
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     OrleansConfig.Register();
 }