Ejemplo n.º 1
0
 private static IClientBuilder WithParts(this IClientBuilder builder)
 {
     return(builder
            .ConfigureApplicationParts(parts => parts
                                       .AddFromAppDomain()
                                       .WithReferences()));
 }
Ejemplo n.º 2
0
 public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
 {
     clientBuilder.Configure <GatewayOptions>(options => options.PreferedGatewayIndex = 0);
     clientBuilder.ConfigureApplicationParts(parts =>
     {
         parts.AddApplicationPart(typeof(IVersionUpgradeTestGrain).Assembly);
     });
 }
Ejemplo n.º 3
0
            public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
            {
                ILoggerFactory codeGenLoggerFactory = new LoggerFactory();

                codeGenLoggerFactory.AddProvider(new FileLoggerProvider("ClientCodeGeneration.log"));
                clientBuilder.ConfigureApplicationParts(
                    parts => parts.AddApplicationPart(typeof(IRuntimeCodeGenGrain).Assembly).WithCodeGeneration(codeGenLoggerFactory));
            }
Ejemplo n.º 4
0
 public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
 {
     clientBuilder.ConfigureApplicationParts(parts =>
     {
         GridConfigurationHelper.AddClientApplicationParts(parts);
         parts.AddApplicationPart(typeof(ITestSpatialGrain).Assembly);
     });
     clientBuilder.AddSimpleMessageStreamProvider(Constants.StreamProviderName);
 }
 public static IClientBuilder Configure_Grains(this IClientBuilder builder, IEnumerable <Assembly> assemblies)
 {
     return(builder.ConfigureApplicationParts(parts =>
     {
         foreach (var assembly in assemblies)
         {
             parts.AddApplicationPart(assembly).WithReferences();
         }
     }));
 }
 /// <summary>
 /// Configure cluster client to use SQS persistent streams.
 /// </summary>
 public static IClientBuilder AddSqsStreams(this IClientBuilder builder, string name, Action <OptionsBuilder <SqsStreamOptions> > configureOptions = null)
 {
     return(builder
            .ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(SQSAdapterFactory).Assembly))
            .ConfigureServices(services =>
     {
         services.ConfigureNamedOptionForLogging <SqsStreamOptions>(name)
         .AddClusterClientPersistentStreams <SqsStreamOptions>(name, SQSAdapterFactory.Create, configureOptions);
     }));
 }
Ejemplo n.º 7
0
 public ClusterClientEventHubStreamConfigurator(string name, IClientBuilder builder)
     : base(name, builder, EventHubAdapterFactory.Create)
 {
     builder.ConfigureApplicationParts(parts =>
     {
         parts.AddFrameworkPart(typeof(EventHubAdapterFactory).Assembly)
         .AddFrameworkPart(typeof(EventSequenceTokenV2).Assembly);
     })
     .ConfigureServices(services => services.ConfigureNamedOptionForLogging <EventHubOptions>(name)
                        .AddTransient <IConfigurationValidator>(sp => new EventHubOptionsValidator(sp.GetOptionsByName <EventHubOptions>(name), name)));
 }
Ejemplo n.º 8
0
 public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
 {
     clientBuilder.ConfigureApplicationParts(parts => parts
                                             .AddApplicationPart(typeof(TestSourceA).Assembly)
                                             .AddApplicationPart(typeof(Source <object>).Assembly)
                                             .AddApplicationPart(typeof(Job).Assembly)
                                             .AddApplicationPart(typeof(ISource).Assembly)
                                             .AddApplicationPart(typeof(TestSink1).Assembly)
                                             .WithReferences()
                                             ).AddSimpleMessageStreamProvider("SMSProvider");
 }
Ejemplo n.º 9
0
 public void Configure(IConfiguration configuration, IClientBuilder builder)
 {
     builder.ConfigureApplicationParts(manager =>
     {
         builder.UseServiceProviderFactory(
             new AutofacServiceProviderFactory(ConfigureContainer));
         manager.AddApplicationPart(typeof(Crawler).Assembly);
         manager.AddApplicationPart(typeof(CrawlRequestBase).Assembly);
         manager.AddApplicationPart(typeof(IManageCrawlRequests).Assembly);
     });
 }
Ejemplo n.º 10
0
 public ClusterClientPubSubStreamConfigurator(string name, IClientBuilder builder)
     : base(name, builder, PubSubAdapterFactory <TDataAdapter> .Create)
 {
     builder
     .ConfigureApplicationParts(parts =>
     {
         parts.AddFrameworkPart(typeof(PubSubAdapterFactory <>).Assembly)
         .AddFrameworkPart(typeof(EventSequenceTokenV2).Assembly);
     })
     .ConfigureServices(services => services.ConfigureNamedOptionForLogging <PubSubOptions>(name));
 }
Ejemplo n.º 11
0
        private static IClientBuilder AddOrleansClusterClient(this IClientBuilder builder, OrleansConfig config)
        {
            builder.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPiSystem).Assembly));

#if DEBUG
            builder.UseLocalhostClustering();
#else
            builder.Configure <ClusterOptions>(options =>
            {
                options.ClusterId = config.ClusterId;
                options.ServiceId = config.ServiceId;
            });

            if (config.DataConnectionString.Contains("6379") || config.DataConnectionString.Contains("6380"))
            {
                builder.UseRedisGatewayListProvider(options => options.ConnectionString = config.DataConnectionString);
            }
            else
            {
                builder.UseAzureStorageClustering(options => options.ConnectionString = config.DataConnectionString);
            }
#endif

            LoggerType loggers = config.GetLoggerTypes();

            if (loggers.HasFlag(LoggerType.AppInsights))
            {
                builder.AddApplicationInsightsTelemetryConsumer(config.InstrumentationKey);
            }

            builder.ConfigureLogging(op =>
            {
                if (loggers.HasFlag(LoggerType.AppInsights))
                {
                    op.AddApplicationInsights(config.InstrumentationKey);
                    op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true));
                }

                if (loggers.HasFlag(LoggerType.Console))
                {
                    op.AddConsole();
                    op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true));
                }

                if (loggers.HasFlag(LoggerType.Debug))
                {
                    op.AddDebug();
                    op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true));
                }
            });

            return(builder);
        }
Ejemplo n.º 12
0
            public ClusterClientRabbitMqStreamConfigurator(string name, IClientBuilder builder)
                : base(name, builder, RabbitMqAdapterFactory <TSerializer> .Create)
            {
                this.ConfigureComponent(SimpleQueueCacheOptionsValidator.Create);

                builder
                .ConfigureApplicationParts(RabbitMQStreamConfiguratorCommon <TSerializer> .AddParts)
                .ConfigureServices(services =>
                                   services.ConfigureNamedOptionForLogging <RabbitMqOptions>(name)
                                   .AddTransient <IConfigurationValidator>(sp => new RabbitMqOptionsValidator(sp.GetOptionsByName <RabbitMqOptions>(name), name))
                                   .ConfigureNamedOptionForLogging <HashRingStreamQueueMapperOptions>(name));
            }
Ejemplo n.º 13
0
 /// <summary>
 /// Configure cluster client to use azure queue persistent streams.
 /// </summary>
 public static IClientBuilder AddAzureQueueStreams <TDataAdapter>(this IClientBuilder builder,
                                                                  string name,
                                                                  Action <OptionsBuilder <AzureQueueStreamOptions> > configureOptions = null)
     where TDataAdapter : IAzureQueueDataAdapter
 {
     return(builder
            .ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(AzureQueueAdapterFactory <>).Assembly))
            .ConfigureServices(services =>
     {
         services.ConfigureNamedOptionForLogging <AzureQueueStreamOptions>(name)
         .AddClusterClientPersistentStreams <AzureQueueStreamOptions>(name, AzureQueueAdapterFactory <TDataAdapter> .Create, configureOptions);
     }));
 }
        /// <summary>
        /// Configures the parts.
        /// </summary>
        /// <param name="builder">The builder.</param>
        private static void ConfigureParts(IClientBuilder builder)
        {
            if (partsConfigured)
            {
                return;
            }

            builder.ConfigureApplicationParts(parts =>
                                              parts.AddApplicationPart(typeof(IOrleansEFStorageGrain).Assembly).WithReferences()
                                              );

            partsConfigured = true;
        }
Ejemplo n.º 15
0
        public ClusterClientRabbitMqStreamConfigurator(string name, IClientBuilder builder)
            : base(name, builder, RabbitMqAdapterFactory.Create)
        {
            builder
            .ConfigureApplicationParts(RabbitMqStreamConfiguratorCommon.AddParts);
            this.ConfigureComponent(RabbitMqOptionsValidator.Create);
            this.ConfigureComponent(RabbitMqOnlineConnectorFactory.Create);

            this.ConfigureDelegate(services =>
            {
                services.TryAddSingleton <IRabbitMqStreamQueueMapperFactory, RabbitMqStreamQueueMapperFactory>();
                services.TryAddSingleton <ITopologyProviderFactory, TopologyProviderFactory>();
            });
        }
Ejemplo n.º 16
0
 public static IClientBuilder AddJobFacServicesParts(this IClientBuilder builder)
 {
     // Only interfaces intended to be used by the client are listed, although
     // technically they're all accessible since they're in the same assembly.
     // In the future these could be separated into client and non-client assemblies.
     builder.ConfigureApplicationParts(parts =>
     {
         parts.AddApplicationPart(typeof(IJobFactory).Assembly).WithReferences();
         parts.AddApplicationPart(typeof(IJobExternalProcess).Assembly).WithReferences();
         //parts.AddApplicationPart(typeof(IJobSequence).Assembly).WithReferences();
         parts.AddApplicationPart(typeof(IDataUtilities).Assembly).WithReferences();
     });
     return(builder);
 }
        private static IClientBuilder AddClientProvider(IClientBuilder builder, string providerName, Action <OptionsBuilder <EventStoreRepositoryConfiguration> > configureOptions = null)
        {
            builder
            .ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(EventStoreAdapterFactory).Assembly).WithReferences())
            .ConfigureServices(services =>
            {
                services
                .ConfigureNamedOptionForLogging <EventStoreRepositoryConfiguration>(providerName)
                .ConfigureNamedOptionForLogging <HashRingStreamQueueMapperOptions>(providerName);
            })
            .AddPersistentStreams(providerName, EventStoreAdapterFactory.Create, stream => stream.Configure(configureOptions));

            return(builder);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Configure cluster client to use memory streams.
 /// </summary>
 public static IClientBuilder AddMemoryStreams <TSerializer>(
     this IClientBuilder builder,
     string name,
     Action <OptionsBuilder <MemoryStreamOptions> > configureOptions = null)
     where TSerializer : class, IMemoryMessageBodySerializer
 {
     return(builder
            .ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(MemoryAdapterFactory <>).Assembly))
            .ConfigureServices(services =>
     {
         services.ConfigureNamedOptionForLogging <MemoryStreamOptions>(name)
         .AddClusterClientPersistentStreams <MemoryStreamOptions>(name, MemoryAdapterFactory <TSerializer> .Create, configureOptions);
     }));
 }
Ejemplo n.º 19
0
 public ClusterClientSqsStreamConfigurator(string name, IClientBuilder builder)
     : base(name, builder, SQSAdapterFactory.Create)
 {
     builder
     .ConfigureApplicationParts(parts =>
     {
         parts.AddFrameworkPart(typeof(SQSAdapterFactory).Assembly)
         .AddFrameworkPart(typeof(EventSequenceTokenV2).Assembly);
     })
     .ConfigureServices(services =>
     {
         services.ConfigureNamedOptionForLogging <SqsOptions>(name)
         .ConfigureNamedOptionForLogging <HashRingStreamQueueMapperOptions>(name);
     });
 }
Ejemplo n.º 20
0
 public ClusterClientRedisStreamConfigurator(string name, IClientBuilder builder)
     : base(name, builder, RedisQueueAdapterFactory.Create)
 {
     builder.ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(RedisQueueAdapterFactory).Assembly))
     .ConfigureServices(services =>
     {
         services.TryAddSingleton(SilentLogger.Logger);
         services.ConfigureNamedOptionForLogging <RedisStreamOptions>(name);
         services.TryAddSingleton(CachedConnectionMultiplexerFactory.Default);
         services.TryAddSingleton <ISerializationManager, OrleansSerializationManager>();
         services.AddSingleton <IRedisDataAdapter, RedisDataAdapter>();
         services.AddTransient <IConfigurationValidator>(sp => new RedisStreamOptionsValidator(sp.GetOptionsByName <RedisStreamOptions>(name), name));
         services.ConfigureNamedOptionForLogging <HashRingStreamQueueMapperOptions>(name);
     });
 }
Ejemplo n.º 21
0
        public ClusterClientAzureQueueStreamConfigurator(string name, IClientBuilder builder)
            : base(name, builder, AzureQueueAdapterFactory.Create)
        {
            builder.ConfigureApplicationParts(AzureQueueStreamConfiguratorCommon.AddParts);
            this.ConfigureComponent <IConfigurationValidator>(AzureQueueOptionsValidator.Create);

            //configure default queue names
            this.ConfigureAzureQueue(ob => ob.PostConfigure <IOptions <ClusterOptions> >((op, clusterOp) =>
            {
                if (op.QueueNames == null || op.QueueNames?.Count == 0)
                {
                    op.QueueNames =
                        AzureQueueStreamProviderUtils.GenerateDefaultAzureQueueNames(clusterOp.Value.ServiceId, this.name);
                }
            }));
            base.configureDelegate(services => services.TryAddSingleton <IQueueDataAdapter <CloudQueueMessage, IBatchContainer>, AzureQueueDataAdapterV2>());
        }
        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));
            });
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Adds Assemblies to Cluster Client Builder with references.
        /// </summary>
        /// <param name="builder">The <see cref="IClientBuilder"/>.</param>
        /// <param name="types">The <see cref="Type"/> array which will be added to the cluster client.</param>
        /// <returns>Returns the <see cref="IClientBuilder"/> so that more methods can be chained.</returns>
        public static IClientBuilder AddAssemblies([NotNull] this IClientBuilder builder, [NotNull] params Type[] types)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (types == null)
            {
                throw new ArgumentNullException(nameof(types));
            }

            return(builder.ConfigureApplicationParts(parts =>
            {
                foreach (var type in types)
                {
                    parts.AddApplicationPart(type.Assembly).WithReferences();
                }
            }));
        }
        private static IClientBuilder AddClientProvider(
            IClientBuilder builder,
            string providerName,
            Action <OptionsBuilder <KafkaStreamOptions> > configureOptions = null
            )
        {
            builder
            .ConfigureApplicationParts(parts => parts.AddFrameworkPart(typeof(KafkaAdapterFactory).Assembly).WithReferences())
            .ConfigureServices(services =>
            {
                services
                .ConfigureNamedOptionForLogging <KafkaStreamOptions>(providerName)
                .ConfigureNamedOptionForLogging <HashRingStreamQueueMapperOptions>(providerName);
            })
            .AddPersistentStreams(providerName, KafkaAdapterFactory.Create, stream => stream.Configure(configureOptions))
            .Configure <SimpleQueueCacheOptions>(ob => ob.CacheSize = DefaultCacheSize)
            ;

            return(builder);
        }
Ejemplo n.º 25
0
 public static IClientBuilder ConfigureStreamsAndLogging(this IClientBuilder builder)
 {
     return(builder
            .ConfigureApplicationParts(p => p.AddApplicationPart(typeof(IAggregatorGrain).Assembly))
            .AddRabbitMqStream(Globals.StreamProviderNameDefault, configurator =>
     {
         configurator.ConfigureRabbitMq(host: "localhost", port: ToxiProxyHelpers.RmqProxyPort,
                                        virtualHost: "/", user: "******", password: "******", queueName: Globals.StreamNameSpaceDefault);
     })
            .AddRabbitMqStream <ProtoBufBatchContainerSerializer>(Globals.StreamProviderNameProtoBuf, configurator =>
     {
         configurator.ConfigureRabbitMq(host: "localhost", port: ToxiProxyHelpers.RmqProxyPort,
                                        virtualHost: "/", user: "******", password: "******", queueName: Globals.StreamNameSpaceDefault);
     })
            .ConfigureLogging(log => log
                              .ClearProviders()
                              .SetMinimumLevel(LogLevel.Trace)
                              .AddConsole()
                              .AddDebug()));
 }
Ejemplo n.º 26
0
            public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
            {
                clientBuilder.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPingGrain).Assembly));

                var encodedCertificate = configuration[CertificateConfigKey];
                var localCertificate   = TestCertificateHelper.ConvertFromBase64(encodedCertificate);

                clientBuilder.UseTls(localCertificate, options =>
                {
                    options.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
                    options.RemoteCertificateValidation = (remoteCertificate, chain, errors) =>
                    {
                        return(true);
                    };

                    options.OnAuthenticateAsClient = (connection, sslOptions) =>
                    {
                        sslOptions.TargetHost = CertificateSubjectName;
                    };
                });
            }
Ejemplo n.º 27
0
            public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
            {
                clientBuilder.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPingGrain).Assembly));

                var encodedCertificate = configuration[CertificateConfigKey];
                var localCertificate   = TestCertificateHelper.ConvertFromBase64(encodedCertificate);

                var certificateModeString = configuration[ClientCertificateModeKey];
                var certificateMode       = (RemoteCertificateMode)Enum.Parse(typeof(RemoteCertificateMode), certificateModeString);

                clientBuilder.UseTls(options =>
                {
                    options.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
                    options.AllowAnyRemoteCertificate();
                    options.LocalCertificate       = localCertificate;
                    options.RemoteCertificateMode  = RemoteCertificateMode.RequireCertificate;
                    options.ClientCertificateMode  = certificateMode;
                    options.OnAuthenticateAsClient = (connection, sslOptions) =>
                    {
                        sslOptions.TargetHost = CertificateSubjectName;
                    };
                });
            }
Ejemplo n.º 28
0
        public ClusterClientAzureQueueStreamConfigurator(string name, IClientBuilder builder)
            : base(name, builder, AzureQueueAdapterFactory <TDataAdapter> .Create)
        {
            builder
            .ConfigureApplicationParts(parts =>
            {
                parts.AddFrameworkPart(typeof(AzureQueueAdapterFactory <>).Assembly)
                .AddFrameworkPart(typeof(EventSequenceTokenV2).Assembly);
            })
            .ConfigureServices(services => services
                               .ConfigureNamedOptionForLogging <AzureQueueOptions>(name)
                               .AddTransient <IConfigurationValidator>(sp => new AzureQueueOptionsValidator(sp.GetOptionsByName <AzureQueueOptions>(name), name))
                               .ConfigureNamedOptionForLogging <HashRingStreamQueueMapperOptions>(name));

            //configure default queue names
            this.ConfigureAzureQueue(ob => ob.PostConfigure <IOptions <ClusterOptions> >((op, clusterOp) =>
            {
                if (op.QueueNames == null || op.QueueNames?.Count == 0)
                {
                    op.QueueNames =
                        AzureQueueStreamProviderUtils.GenerateDefaultAzureQueueNames(clusterOp.Value.ServiceId, this.name);
                }
            }));
        }
Ejemplo n.º 29
0
 public void Configure(IConfiguration configuration, IClientBuilder clientBuilder)
 {
     clientBuilder
     .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IAccount).Assembly).WithReferences())
     .ConfigureLogging(logging => logging.AddConsole());
 }
Ejemplo n.º 30
0
        public static IClientBuilder UseDashboard(this IClientBuilder builder)
        {
            builder.ConfigureApplicationParts(appParts => appParts.AddFrameworkPart(typeof(Dashboard).Assembly));

            return(builder);
        }