public static IClientBuilder TryUseAdoNetClustering(this IClientBuilder builder, IConfiguration configuration)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var orleans = configuration.GetSection("Orleans");
            var section = orleans.GetSection("Providers:Clustering");

            if (section["Provider"] == "AdoNet")
            {
                section = section.GetSection("AdoNet");

                builder
                .UseAdoNetClustering(_ =>
                {
                    _.ConnectionString = configuration.GetConnectionString(section["ConnectionStringName"]);
                    _.Invariant        = section["Invariant"];
                })
                .Configure <ClusterOptions>(_ =>
                {
                    _.ClusterId = orleans["ClusterId"];
                    _.ServiceId = orleans["ServiceId"];
                });
            }

            return(builder);
        }
Ejemplo n.º 2
0
 private void ConfigureOrleansSQL(IClientBuilder builder)
 {
     builder
     .UseAdoNetClustering(options =>
     {
         options.Invariant        = "System.Data.SqlClient";
         options.ConnectionString = Environment.GetEnvironmentVariable("SqlConnectionString");
     });
 }
Ejemplo n.º 3
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="T:Orleans.IClientBuilder" />.
        /// </returns>
        /// <remarks>
        /// Instructions on configuring your database are available at <see href="http://aka.ms/orleans-sql-scripts" />.
        /// </remarks>
        public static IClientBuilder UseOrleansAdoNetClustering <T>(
            this IClientBuilder builder,
            Action <T> configureOptions) where T : AdoNetClusteringClientOptions, new()
        {
            var newAction = new Action <AdoNetClusteringClientOptions>(options =>
            {
                var t = new T();
                configureOptions(t);
                options.Invariant        = t.Invariant;
                options.ConnectionString = t.ConnectionString;
            });

            return(builder.UseAdoNetClustering(newAction));
        }