Ejemplo n.º 1
0
 public static IClientBuilder ConfigureClustering(
     this IClientBuilder builder, IHostingEnvironment hostingEnvironment)
 {
     if (hostingEnvironment.IsDevelopment())
     {
         return(builder.UseLocalhostClustering());
     }
     else if (hostingEnvironment.IsEnvironment("Compose"))
     {
         return(builder.UseComposeClustering("host"));
     }
     else
     {
         return(builder.UseKubeGatewayListProvider(opt => { opt.Group = "orleans.dot.net"; }));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Configures Kubernetes Clustering.
        /// </summary>
        /// <param name="builder">The Orleans <see cref="IClientBuilder"/>.</param>
        /// <param name="configurationSection">The <see cref="IConfigurationSection"/> which binds to <see cref="KubernetesOptions"/>.</param>
        /// <returns>The <see cref="IClientBuilder"/>.</returns>
        public static IClientBuilder ConfigureKubernetesClustering([NotNull] this IClientBuilder builder, [NotNull] IConfigurationSection configurationSection)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (configurationSection?.Exists() != true)
            {
                throw new ConfigurationErrorsException($"Configuration section '{configurationSection?.Path}' is incorrect.");
            }

            var kubernetesOptions = configurationSection.Get <KubernetesClientOptions>() ?? new KubernetesClientOptions();

            return(builder.UseKubeGatewayListProvider(options =>
            {
                options.Group = kubernetesOptions.Group;
                options.CertificateData = kubernetesOptions.CertificateData;
                options.APIEndpoint = kubernetesOptions.ApiEndpoint;
                options.APIToken = kubernetesOptions.ApiToken;
            }));
        }