public IClusterClientPersistentStreamConfigurator Configure <TOptions>(Action <OptionsBuilder <TOptions> > configureOptions) where TOptions : class, new()
 {
     clientBuilder.ConfigureServices(services =>
     {
         configureOptions?.Invoke(services.AddOptions <TOptions>(this.name));
         services.ConfigureNamedOptionForLogging <TOptions>(this.name);
     });
     return(this);
 }
    public static IClientBuilder UseUnixSocketConnection(this IClientBuilder clientBuilder)
    {
        clientBuilder.ConfigureServices(services =>
        {
            services.AddSingletonKeyedService <object, IConnectionFactory>(ClientOutboundConnectionFactory.ServicesKey, CreateUnixSocketConnectionFactory());
        });

        return(clientBuilder);
    }
Exemplo n.º 3
0
        /// <summary>
        /// Configures the cluster general options.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="configureOptions">The delegate that configures the options.</param>
        /// <returns>The same instance of the <see cref="IClientBuilder"/> for chaining.</returns>
        public static IClientBuilder ConfigureCluster(this IClientBuilder builder, Action <ClusterOptions> configureOptions)
        {
            if (configureOptions != null)
            {
                builder.ConfigureServices(services => services.Configure <ClusterOptions>(configureOptions));
            }

            return(builder);
        }
Exemplo n.º 4
0
 public static IClientBuilder UseRedisGatewayListProvider(this IClientBuilder builder, ILogger <RedisGatewayListProvider> logger)
 {
     return(builder.ConfigureServices(services =>
     {
         services.AddOptions <RedisClusteringOptions>();
         services.AddSingleton <IGatewayListProvider, RedisGatewayListProvider>();
         services.TryAddSingleton <ILogger <RedisGatewayListProvider> >(logger);
     }));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Configures the cluster client general options.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <param name="configureOptions">The delegate that configures the options using the options builder.</param>
        /// <returns>The same instance of the <see cref="IClientBuilder"/> for chaining.</returns>
        public static IClientBuilder ConfigureClusterClient(this IClientBuilder builder, Action <OptionsBuilder <ClusterClientOptions> > configureOptions)
        {
            if (configureOptions != null)
            {
                builder.ConfigureServices(services => configureOptions.Invoke(services.AddOptions <ClusterClientOptions>()));
            }

            return(builder);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Use Windows performance counters as source for host environment statistics
 /// </summary>
 public static IClientBuilder UsePerfCounterEnvironmentStatistics(this IClientBuilder builder)
 {
     return(builder.ConfigureServices(services =>
     {
         services.AddSingleton <PerfCounterEnvironmentStatistics>();
         services.AddFromExisting <IHostEnvironmentStatistics, PerfCounterEnvironmentStatistics>();
         services.AddFromExisting <ILifecycleParticipant <IClusterClientLifecycle>, PerfCounterEnvironmentStatistics>();
     }));
 }
Exemplo n.º 7
0
 public ClusterClientSqsStreamConfigurator(string name, IClientBuilder builder)
     : base(name, builder, SQSAdapterFactory.Create)
 {
     builder
     .ConfigureServices(services =>
     {
         services.ConfigureNamedOptionForLogging <SqsOptions>(name)
         .ConfigureNamedOptionForLogging <HashRingStreamQueueMapperOptions>(name);
     });
 }
Exemplo n.º 8
0
 /// <summary>
 /// Use Linux host environment statistics
 /// </summary>
 public static IClientBuilder UseLinuxEnvironmentStatistics(this IClientBuilder builder)
 {
     return(builder.ConfigureServices(services =>
     {
         services.AddTransient <IConfigurationValidator, LinuxEnvironmentStatisticsValidator>();
         services.AddSingleton <LinuxEnvironmentStatistics>();
         services.AddFromExisting <IHostEnvironmentStatistics, LinuxEnvironmentStatistics>();
         services.AddFromExisting <ILifecycleParticipant <IClusterClientLifecycle>, LinuxEnvironmentStatistics>();
     }));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Configures the client to use dns name lookup clustering.
 /// </summary>
 public static IClientBuilder UseDnsNameLookupClustering(this IClientBuilder builder, Action <OptionsBuilder <DnsNameGatewayListProviderOptions> > configureOptions)
 {
     return(builder.ConfigureServices(
                collection =>
     {
         configureOptions?.Invoke(collection.AddOptions <DnsNameGatewayListProviderOptions>());
         collection.AddSingleton <IGatewayListProvider, DnsNameGatewayListProvider>()
         .ConfigureFormatter <DnsNameGatewayListProviderOptions>();
     }));
 }
Exemplo n.º 10
0
        public void Configure(IConfiguration configuration, IClientBuilder hostBuilder)
        {
            hostBuilder
            .AddSimpleMessageStreamProvider(InterfaceConst.SMSProvider);

            hostBuilder.ConfigureServices(services =>
            {
                services.AddEventStoreService();
                services.AddAggregateServices();
            });
        }
 /// <summary>
 /// Configures the client to use Azure Storage for clustering.
 /// </summary>
 /// <param name="builder">
 /// The client builder.
 /// </param>
 /// <param name="configureOptions">
 /// The configuration delegate.
 /// </param>
 /// <returns>
 /// The provided <see cref="IClientBuilder"/>.
 /// </returns>
 public static IClientBuilder UseAzureStorageClustering(
     this IClientBuilder builder,
     Action <OptionsBuilder <AzureStorageGatewayOptions> > configureOptions)
 {
     return(builder.ConfigureServices(
                services =>
     {
         configureOptions?.Invoke(services.AddOptions <AzureStorageGatewayOptions>());
         services.AddSingleton <IGatewayListProvider, AzureGatewayListProvider>();
     }));
 }
 public static IClientBuilder UseRedisClustering(this IClientBuilder builder, string redisConnectionString, int db = 0)
 {
     return(builder.ConfigureServices(services => services
                                      .Configure <RedisOptions>(opt =>
     {
         opt.ConnectionString = redisConnectionString;
         opt.Database = db;
     })
                                      .AddRedis()
                                      .AddSingleton <IGatewayListProvider, RedisGatewayListProvider>()));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Specified the configuration to use for this client.
 /// </summary>
 /// <param name="builder">The client builder.</param>
 /// <param name="configuration">The configuration.</param>
 /// <remarks>This method may only be called once per builder instance.</remarks>
 /// <returns>The builder.</returns>
 public static IClientBuilder UseConfiguration(this IClientBuilder builder, ClientConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException(nameof(configuration));
     }
     return(builder.ConfigureServices(services =>
     {
         services.AddLegacyClientConfigurationSupport(configuration);
     }));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Configures the client to use DynamoDB for clustering.
 /// </summary>
 /// <param name="builder">
 /// The builder.
 /// </param>
 /// <param name="configureOptions">
 /// The configuration delegate.
 /// </param>
 /// <returns>
 /// The provided <see cref="IClientBuilder"/>.
 /// </returns>
 public static IClientBuilder UseDynamoDBClustering(
     this IClientBuilder builder,
     Action <OptionsBuilder <DynamoDBClusteringClientOptions> > configureOptions)
 {
     return(builder.ConfigureServices(
                services =>
     {
         configureOptions?.Invoke(services.AddOptions <DynamoDBClusteringClientOptions>());
         services.AddSingleton <IGatewayListProvider, DynamoDBGatewayListProvider>();
     }));
 }
        /// <summary>
        /// Uses the entity framework clustering.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns></returns>
        public static IClientBuilder UseEntityFrameworkClustering(this IClientBuilder builder)
        {
            ConfigureParts(builder);

            builder.ConfigureServices(services =>
            {
                services.AddSingleton <IGatewayListProvider, OrleansEFGatewayListProvider>();
            });

            return(builder);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Configure the client to use ZooKeeper for clustering.
 /// </summary>
 /// <param name="builder">
 /// The builder.
 /// </param>
 /// <param name="configureOptions">
 /// The configuration delegate.
 /// </param>
 /// <returns>
 /// The provided <see cref="IClientBuilder"/>.
 /// </returns>
 public static IClientBuilder UseZooKeeperClustering(
     this IClientBuilder builder,
     Action <OptionsBuilder <ZooKeeperGatewayListProviderOptions> > configureOptions)
 {
     return(builder.ConfigureServices(
                services =>
     {
         configureOptions?.Invoke(services.AddOptions <ZooKeeperGatewayListProviderOptions>());
         services.AddSingleton <IGatewayListProvider, ZooKeeperGatewayListProvider>();
     }));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Configures this client to use ADO.NET for clustering. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
 /// </summary>
 /// <param name="builder">
 /// The builder.
 /// </param>
 /// <param name="configureOptions">
 /// The configuration delegate.
 /// </param>
 /// <returns>
 /// The provided <see cref="IClientBuilder"/>.
 /// </returns>
 /// <remarks>
 /// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
 /// </remarks>
 public static IClientBuilder UseAdoNetClustering(
     this IClientBuilder builder,
     Action <OptionsBuilder <AdoNetClusteringClientOptions> > configureOptions)
 {
     return(builder.ConfigureServices(
                services =>
     {
         configureOptions?.Invoke(services.AddOptions <AdoNetClusteringClientOptions>());
         services.AddSingleton <IGatewayListProvider, AdoNetGatewayListProvider>();
         services.AddSingleton <IConfigurationValidator, AdoNetClusteringClientOptionsValidator>();
     }));
 }
Exemplo n.º 18
0
        public static IClientBuilder UseCassandraClustering(this IClientBuilder builder, Action <CassandraClusteringOptions> configureOptions)
        {
            return(builder.ConfigureServices(
                       services =>
            {
                if (configureOptions != null)
                {
                    services.Configure(configureOptions);
                }

                services.AddSingleton <IGatewayListProvider, CassandraGatewayListProvider>();
            }));
        }
Exemplo n.º 19
0
 /// <summary>
 /// Configures default client services.
 /// </summary>
 /// <param name="builder">The host builder.</param>
 /// <returns>The client builder.</returns>
 public static IClientBuilder ConfigureDefaults(this IClientBuilder builder)
 {
     // Configure the container to use an Orleans client.
     builder.ConfigureServices(services =>
     {
         const string key = "OrleansClientServicesAdded";
         if (!builder.Properties.ContainsKey(key))
         {
             DefaultClientServices.AddDefaultServices(services);
             builder.Properties.Add(key, true);
         }
     });
     return(builder);
 }
        public static IClientBuilder UseRedisClustering(this IClientBuilder builder, Action <RedisOptions> configuration)
        {
            return(builder.ConfigureServices(services =>
            {
                if (configuration != null)
                {
                    services.Configure(configuration);
                }

                services
                .AddRedis()
                .AddSingleton <IGatewayListProvider, RedisGatewayListProvider>();
            }));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Configures the client to use static clustering.
        /// </summary>
        public static IClientBuilder UseStaticClustering(this IClientBuilder builder, Action <StaticGatewayListProviderOptions> configureOptions)
        {
            return(builder.ConfigureServices(
                       collection =>
            {
                if (configureOptions != null)
                {
                    collection.Configure(configureOptions);
                }

                collection.AddSingleton <IGatewayListProvider, StaticGatewayListProvider>()
                .TryConfigureFormatter <StaticGatewayListProviderOptions, StaticGatewayListProviderOptionsFormatter>();
            }));
        }
Exemplo n.º 22
0
            public override void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
            {
                var primaryGw = this.ClusterConfiguration.Overrides["Primary"].ProxyGatewayEndpoint.ToGatewayUri();

                clientBuilder.ConfigureServices(services =>
                {
                    services.AddSingleton(sp =>
                    {
                        var gateway = new TestGatewayManager();
                        gateway.Gateways.Add(primaryGw);
                        return(gateway);
                    });
                    services.AddFromExisting <IGatewayListProvider, TestGatewayManager>();
                });
            }
Exemplo n.º 23
0
        /// <summary>
        /// Adds Request Context Grain call filter.
        /// </summary>
        /// <param name="builder">The <see cref="IClientBuilder"/>.</param>
        /// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
        /// <returns>The <see cref="IClientBuilder"/>.</returns>
        public static IClientBuilder AddRequestContextOutgoingFilter([NotNull] this IClientBuilder builder, [NotNull] IServiceProvider serviceProvider)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            builder.ConfigureServices(services => services.TryAddSingleton(serviceProvider.GetRequiredService <IRequestContextAccessor>()));

            return(builder.AddOutgoingGrainCallFilter <RequestContextGrainCallFilter>());
        }
Exemplo n.º 24
0
        /// <summary>
        /// Configure the client to use ZooKeeper for clustering.
        /// </summary>
        /// <param name="builder">
        /// The builder.
        /// </param>
        /// <param name="configureOptions">
        /// The configuration delegate.
        /// </param>
        /// <returns>
        /// The provided <see cref="IClientBuilder"/>.
        /// </returns>
        public static IClientBuilder UseZooKeeperClustering(
            this IClientBuilder builder,
            Action <ZooKeeperGatewayListProviderOptions> configureOptions)
        {
            return(builder.ConfigureServices(
                       services =>
            {
                if (configureOptions != null)
                {
                    services.Configure(configureOptions);
                }

                services.AddSingleton <IGatewayListProvider, ZooKeeperClusteringClientOptions>();
            }));
        }
Exemplo n.º 25
0
        public static IClientBuilder AddSignalR(this IClientBuilder builder, Action <SimpleMessageStreamProviderOptions> configureOptions)
        {
            builder.AddSimpleMessageStreamProvider(Constants.STREAM_PROVIDER, configureOptions)
            .ConfigureApplicationParts(manager =>
            {
                manager.AddApplicationPart(typeof(IClientGrain).Assembly).WithReferences();
            });

            builder.ConfigureServices(services =>
            {
                services.TryAddSingleton(typeof(IClientSetPartitioner <>), typeof(DefaultClientSetPartitioner <>));
            });

            return(builder);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Configures the client to use Azure Storage for clustering.
        /// </summary>
        /// <param name="builder">
        /// The client builder.
        /// </param>
        /// <param name="configureOptions">
        /// The configuration delegate.
        /// </param>
        /// <returns>
        /// The provided <see cref="IClientBuilder"/>.
        /// </returns>
        public static IClientBuilder UseAzureStorageClustering(
            this IClientBuilder builder,
            Action <AzureStorageGatewayOptions> configureOptions)
        {
            return(builder.ConfigureServices(
                       services =>
            {
                if (configureOptions != null)
                {
                    services.Configure(configureOptions);
                }

                services.AddSingleton <IGatewayListProvider, AzureGatewayListProvider>()
                .ConfigureFormatter <AzureStorageGatewayOptions>();
            }));
        }
Exemplo n.º 27
0
        /// <summary>
        /// Configures this client to use ADO.NET for clustering. Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
        /// </summary>
        /// <param name="builder">
        /// The builder.
        /// </param>
        /// <param name="configureOptions">
        /// The configuration delegate.
        /// </param>
        /// <returns>
        /// The provided <see cref="IClientBuilder"/>.
        /// </returns>
        /// <remarks>
        /// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts"/>.
        /// </remarks>
        public static IClientBuilder UseAdoNetClustering(
            this IClientBuilder builder,
            Action <AdoNetClusteringClientOptions> configureOptions)
        {
            return(builder.ConfigureServices(
                       services =>
            {
                if (configureOptions != null)
                {
                    services.Configure(configureOptions);
                }

                services.AddSingleton <IGatewayListProvider, AdoNetGatewayListProvider>();
                services.AddSingleton <IConfigurationValidator, AdoNetClusteringClientOptionsValidator>();
            }));
        }
Exemplo n.º 28
0
 public static IClientBuilder UseRedisMembership(this IClientBuilder builder, string redisConnectionString, int db = 0)
 {
     builder.Configure <ClusterMembershipOptions>(x => x.ValidateInitialConnectivity = true);
     return(builder.ConfigureServices(services => services
                                      .Configure <RedisOptions>(opt =>
     {
         opt.ConnectionString = redisConnectionString;
         opt.Database = db;
     })
                                      .AddSingleton(new GatewayOptions()
     {
         GatewayListRefreshPeriod = GatewayOptions.DEFAULT_GATEWAY_LIST_REFRESH_PERIOD
     })
                                      .AddRedis()
                                      .AddSingleton <IGatewayListProvider, RedisGatewayListProvider>()));
 }
        /// <summary>
        /// Adds support for connecting to a cluster hosted in Service Fabric.
        /// </summary>
        /// <param name="clientBuilder">The client builder.</param>
        /// <param name="serviceName">The Service Fabric service name.</param>
        /// <returns>The provided client builder.</returns>
        public static IClientBuilder UseServiceFabricClustering(
            this IClientBuilder clientBuilder,
            Uri serviceName)
        {
            clientBuilder.ConfigureServices(
                serviceCollection =>
            {
                AddStandardServices(serviceCollection);

                // Use Service Fabric for cluster membership.
                serviceCollection.TryAddSingleton <IFabricServiceSiloResolver>(sp => ActivatorUtilities.CreateInstance <FabricServiceSiloResolver>(sp, serviceName));

                serviceCollection.TryAddSingleton <IGatewayListProvider, FabricGatewayProvider>();
            });

            return(clientBuilder);
        }
        public ClusterClientRabbitMQStreamConfigurator(string name, IClientBuilder builder)
            : base(name, builder, RabbitMQAdapterFactory.Create)
        {
            builder.ConfigureApplicationParts(parts =>
            {
                parts.AddFrameworkPart(typeof(RabbitMQAdapterFactory).Assembly);
                parts.AddFrameworkPart(typeof(EventSequenceTokenV2).Assembly);
                parts.AddFrameworkPart(typeof(EventSequenceToken).Assembly);
            });

            builder.ConfigureServices(services =>
            {
                services.ConfigureNamedOptionForLogging<HashRingStreamQueueMapperOptions>(name);
                services.ConfigureNamedOptionForLogging<RabbitMQOptions>(name);
                services.AddTransient<IConfigurationValidator>(sp => new RabbitMQOptionsValidator(sp.GetOptionsByName<RabbitMQOptions>(name), name));
            });
        }