public static World AddWorld(this IServiceCollection services, string eventStoreConnectionString, ConnectionSettingsBuilder connectionSettingsBuilder, Action <IEventStoreRepositoryConfiguration> getEventStoreRepositoryConfiguration = null) { var eventStoreConnection = EventStoreConnection.Create(eventStoreConnectionString, connectionSettingsBuilder); var connectionSettings = connectionSettingsBuilder.Build(); services.AddSingleton <IConnectionStatusMonitor <IEventStoreConnection>, EventStoreConnectionStatusMonitor>(); services.AddSingleton(eventStoreConnection); services.AddSingleton(connectionSettings); var eventStoreRepositoryConfiguration = new EventStoreRepositoryConfiguration(); getEventStoreRepositoryConfiguration?.Invoke(eventStoreRepositoryConfiguration); services.AddSingleton <IEventStoreRepositoryConfiguration>(eventStoreRepositoryConfiguration); services.AddTransient <IEventStoreRepository, EventStoreRepository>(); var world = new World(services, true); services.AddSingleton(world); return(world); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Session state ermöglichen services.AddRazorPages(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); }); services.AddMemoryCache(); services.AddMvc(); //Eventflow Konfiguration var eventflowDatabasesettings = new DatabaseSettings(); this.Configuration.GetSection("DatabaseSettings").Bind(eventflowDatabasesettings); ConnectionSettingsBuilder connectionSettings = ConnectionSettings.Create() .SetDefaultUserCredentials(new UserCredentials(eventflowDatabasesettings.EventstoreUser, eventflowDatabasesettings.EventstorePW)); services.AddEventFlow(o => { o.AddDefaults(typeof(Program).Assembly); //Reinladen der Assembly (Projekt wo Commands, Handler und Events sind, können auch mehrere Projekte sein) o.Configure(c => c.IsAsynchronousSubscribersEnabled = true); //Enable subscribers o.UseEventStoreEventStore(new Uri(eventflowDatabasesettings.EventStoreUri), connectionSettings); //Eventstore einrichten o.ConfigureMongoDb(eventflowDatabasesettings.MongoDBUri, eventflowDatabasesettings.DatabaseReadModels); //MOngoDb einrichten o.UseMongoDbReadModel <ConversationReadModel>(); //ReadModel registrieren o.AddAspNetCore(); //Asp.Net core bootstrapper verwenden (startet den IBootstrapper von Eventflow), ab core 3.0 notwendig }); }
private IEventStoreConnection CreateForCluster(ConnectionSettingsBuilder connectionSettingsBuilder) { var endpoints = Options.ClusterIpEndpoints.Select((x, i) => { var ipa = GetHostIp(x); var port = Options.TcpPort; if (Options.ClusterHttpPorts.Length >= i + 1) { port = Options.ClusterHttpPorts[i]; } _logger.LogTrace($"Creating Cluster IP Endpoint: {ipa}:{port}"); return(new IPEndPoint(ipa, port)); }); var clusterSettings = ClusterSettings.Create() .DiscoverClusterViaGossipSeeds() .SetGossipTimeout(TimeSpan.FromMilliseconds(500)) .SetGossipSeedEndPoints(endpoints.ToArray()) ; var con = EventStoreConnection.Create(connectionSettingsBuilder, clusterSettings); return(con); }
ConnectionHandler <AzureServiceBusConnection> GetConnection( Cache <string, ConnectionHandler <AzureServiceBusConnection> > cache, IAzureServiceBusEndpointAddress address) { var ns = address.Uri.Host; return(cache.Get(ns, _ => { if (_log.IsDebugEnabled) { _log.DebugFormat("Creating RabbitMQ connection: {0}", address.Uri); } ConnectionSettingsBuilder builder = _connectionSettingsBuilders.Get(ns, __ => { if (_log.IsDebugEnabled) { _log.DebugFormat("Using default configurator for connection: {0}", address.Uri); } var configurator = new NamespaceConnectionSettingsConfigurator(ns); return configurator.Configure(); }); IConnectionSettings connectionSettings = builder.Build(); var connection = new AzureServiceBusConnectionImpl(address, connectionSettings.TokenProvider); return new ConnectionHandlerImpl <AzureServiceBusConnection>(connection); })); }
internal EventStoreManager() { //uncomment to enable verbose logging in client. settings = ConnectionSettings.Create();//.EnableVerboseLogging().UseConsoleLogger(); tcpEndpoint = new IPEndPoint(IPAddress.Loopback, 1113); httpEndpoint = new IPEndPoint(IPAddress.Loopback, 2113); adminUserCredentials = new UserCredentials("admin", "changeit"); }
public TcpGetEventStoreWireup WithConnectionSettings(Func <ConnectionSettingsBuilder, ConnectionSettingsBuilder> configureBuilder) { Guard.AgainstNull(configureBuilder, "configureBuilder"); _connectionSettingsBuilder = configureBuilder(_connectionSettingsBuilder); return(this); }
public AzureServiceBusTransportFactoryBuilder Configure(AzureServiceBusTransportFactoryBuilder builder) { ConnectionSettingsBuilder connectionSettingsBuilder = Configure(); builder.AddConnectionSettingsBuilder(_namespace, connectionSettingsBuilder); return(builder); }
public void GetHandler_WhenNoDefaultCredentialsAreConfigured_TheClientShouldNotHaveAnyCredentials() { var settings = new ConnectionSettingsBuilder().WithHttpClientProxy(_httpClientProxyMock.Object); _connection = EventStoreHttpConnection.Create(settings, Endpoint); var handler = _connection.GetHandler(); handler.Credentials.Should().BeNull(); }
public void WithHttpClientProxy_ShouldStoreRequiredHttpClientProxy() { var expected = Mock.Of<IHttpClientProxy>(); var builder = new ConnectionSettingsBuilder(); builder.WithHttpClientProxy(expected); ((ConnectionSettings)builder).HttpClientProxy.Should().Be(expected); }
public void WithLogger_ShouldStoreRequiredLogger() { var expected = Mock.Of<ILog>(); var builder = new ConnectionSettingsBuilder(); builder.WithLog(expected); ((ConnectionSettings)builder).Log.Should().Be(expected); }
public void OnErrorOccured_ShouldSetPassedErrorHandler() { Action<IEventStoreHttpConnection, Exception> expectedHandler = (x, y) => { }; var builder = new ConnectionSettingsBuilder(); builder.OnErrorOccured(expectedHandler); ((ConnectionSettings)builder).ErrorHandler.Should().Be(expectedHandler); }
public void WithConnectionTimeoutOf_ShouldStoreRequiredTimeout() { var expectedTimeout = TimeSpan.FromSeconds(30); var builder = new ConnectionSettingsBuilder(); builder.WithConnectionTimeoutOf(expectedTimeout); ((ConnectionSettings)builder).ConnectionTimeout.Should().Be(expectedTimeout); }
public void SetDefaultUserCredentials_ShouldStoreSpecifiedCredentials() { var expectedCredentials = new UserCredentials("a", "b"); var builder = new ConnectionSettingsBuilder(); builder.SetDefaultUserCredentials(expectedCredentials); ((ConnectionSettings)builder).DefaultUserCredentials.Should().Be(expectedCredentials); }
public void WithConnectionName_ShouldStoreGivenConnectionName() { var expected = "SuperName9000"; var builder = new ConnectionSettingsBuilder(); builder.WithConnectionName(expected); ((ConnectionSettings)builder).ConnectionName.Should().Be(expected); }
public void OnErrorOccured_ShouldSetPassedErrorHandler() { Action <IEventStoreHttpConnection, Exception> expectedHandler = (x, y) => { }; var builder = new ConnectionSettingsBuilder(); builder.OnErrorOccured(expectedHandler); ((ConnectionSettings)builder).ErrorHandler.Should().Be(expectedHandler); }
public void SetDefaultUserCredentials_ShouldStoreSpecifiedCredentials() { var expectedCredentials = new UserCredentials("a", "b"); var builder = new ConnectionSettingsBuilder(); builder.SetDefaultUserCredentials(expectedCredentials); ((ConnectionSettings)builder).DefaultUserCredentials.Should().Be(expectedCredentials); }
public void WithConnectionTimeoutOf_ShouldStoreRequiredTimeout() { var expectedTimeout = TimeSpan.FromSeconds(30); var builder = new ConnectionSettingsBuilder(); builder.WithConnectionTimeoutOf(expectedTimeout); ((ConnectionSettings)builder).ConnectionTimeout.Should().Be(expectedTimeout); }
public void WithLogger_ShouldStoreRequiredLogger() { var expected = Mock.Of <ILog>(); var builder = new ConnectionSettingsBuilder(); builder.WithLog(expected); ((ConnectionSettings)builder).Log.Should().Be(expected); }
public void WithHttpClientProxy_ShouldStoreRequiredHttpClientProxy() { var expected = Mock.Of <IHttpClientProxy>(); var builder = new ConnectionSettingsBuilder(); builder.WithHttpClientProxy(expected); ((ConnectionSettings)builder).HttpClientProxy.Should().Be(expected); }
public void WithConnectionName_ShouldStoreGivenConnectionName() { var expected = "SuperName9000"; var builder = new ConnectionSettingsBuilder(); builder.WithConnectionName(expected); ((ConnectionSettings)builder).ConnectionName.Should().Be(expected); }
private ConnectionSettings GetConnectionSettings() { var cs = new ConnectionSettingsBuilder() .SetDefaultUserCredentials(new UserCredentials(Username, Password)) .WithConnectionTimeoutOf(TimeSpan.FromSeconds(30)) .WithHttpClientProxy(_httpClientProxyMock.Object); return(cs); }
public static EventStoreStatelessActorBuilder <TActor, TRegistry> Create(string eventStoreConnectionString, ConnectionSettingsBuilder connectionSettingsBuilder, IActorConfiguration actorConfiguration, ILoggerFactory loggerFactory = null, Action <IEventStoreRepositoryConfiguration> getEventStoreRepositoryConfiguration = null) { var connection = EventStoreConnection.Create(eventStoreConnectionString, connectionSettingsBuilder); return(CreateInternal(actorConfiguration, connection, loggerFactory, getEventStoreRepositoryConfiguration)); }
public void GetHandler_WhenNoDefaultCredentialsAreConfigured_TheClientShouldNotHaveAnyCredentials() { var settings = new ConnectionSettingsBuilder().WithHttpClientProxy(_httpClientProxyMock.Object); _connection = EventStoreHttpConnection.Create(settings, Endpoint); var handler = _connection.GetHandler(); handler.Credentials.Should().BeNull(); }
public static IEventStoreConnection Connect(ConnectionSettingsBuilder connectionSettingsBuilder, EventStoreConfiguration config, string port, string connectionName = null) { connectionSettingsBuilder .UseConsoleLogger() .SetDefaultUserCredentials(EventStoreCredentials.Config(config)); var endPoint = IPEndPointFactory.CreateIPEndPoint(config.HostName, port); var connection = EventStoreConnection.Create(connectionSettingsBuilder, endPoint, connectionName); connection.ConnectAsync(); return(connection); }
private static void InitConnection(ConnectionSettingsBuilder connectionSettings, IPAddress[] ipAddresses) { conn = EventStoreConnection.Create( connectionSettings, new IPEndPoint(IPAddress.Parse(ipAddresses.First().ToString()), 1113)); conn.Connected += ConnOnConnected; conn.Closed += ConnOnClosed; conn.ErrorOccurred += ConnOnErrorOccurred; conn.ConnectAsync(); }
public void WhenConnectionNameNotSet_ShouldDefaultToAUniqueConnectionName() { var builder = new ConnectionSettingsBuilder(); var connectionName = ((ConnectionSettings)builder).ConnectionName; connectionName.Should().NotBeNull(); connectionName.Should().StartWith("ES-"); var expectedGuid = connectionName.Substring(3); Guid parsed; Guid.TryParse(expectedGuid, out parsed).Should().BeTrue(); }
public OrderTests() { node = EmbeddedVNodeBuilder .AsSingleNode() .OnDefaultEndpoints() .RunInMemory(); connectionSettingsBuilder = ConnectionSettings .Create() .SetDefaultUserCredentials(new UserCredentials("admin", "changeit")) .KeepReconnecting(); }
private static void CreateConnection(ConnectionSettingsBuilder settings) { WaitTillDoneReSubscribing.WaitOne(); Connection?.Dispose(); //var newConnection = EventStoreConnection.Create(settings, new Uri(EventStoreLiveUri)); var newConnection = EventStoreConnection.Create(settings, new IPEndPoint(IPAddress.Loopback, DefaultPort)); newConnection.Connected += (connection, a) => { WaitTillDoneReSubscribing.Reset(); Console.WriteLine("Connected"); //if (_esConnectedTask == null || _esConnectedTask.IsCompleted) //{ Task.Factory.StartNew(() => { EsConnectedEvent?.Invoke(newConnection); Console.WriteLine("Reconnected all subscriptions"); WaitTillDoneReSubscribing.Set(); }); //} //else // Console.WriteLine("ALREADY RECONNECTING!"); Console.WriteLine("EsConnectedEvent Invoked"); }; newConnection.Reconnecting += (sender, a) => { Console.WriteLine("Reconnecting"); }; newConnection.Closed += (sender, a) => { //waitTillDoneReSubscribing.Set(); Console.WriteLine("Closed"); //var esClosedTask = new Task(() => //{ CreateConnection(settings); //}); //esClosedTask.Start(); }; //newConnection.Disconnected += (sender, a) => //{ // Console.WriteLine("Disconnected"); //}; newConnection.ConnectAsync().Wait(); Connection = newConnection; }
public EventStoreTarget(IOptions <EventStoreSettings> settings, IEventPublisher publisher) { if (!IPAddress.TryParse(settings.Value.Address, out var address)) { throw new Exception(); } this.publisher = publisher; eventStoreEndPoint = new IPEndPoint(address, settings.Value.Port); credentials = new UserCredentials(settings.Value.Username, settings.Value.Password); builder = ConnectionSettings.Create(); connection = EventStoreConnection.Create(builder, eventStoreEndPoint); connection.ConnectAsync().Wait(); }
public Exploratory(ITestOutputHelper testOutputHelper) { _testOutputHelper = testOutputHelper; IPEndPoint noEndpoint = new IPEndPoint(IPAddress.None, 0); _node = EmbeddedVNodeBuilder .AsSingleNode() .WithExternalTcpOn(noEndpoint) .WithInternalTcpOn(noEndpoint) .WithExternalHttpOn(noEndpoint) .WithInternalHttpOn(noEndpoint) .RunProjections(ProjectionsMode.All) .WithTfChunkSize(16000000) .RunInMemory(); _connectionSettingsBuilder = ConnectionSettings .Create() .SetDefaultUserCredentials(new UserCredentials("admin", "changeit")) .KeepReconnecting(); }
/// <summary> /// Configures the application's services /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> to configure</param> public void ConfigureServices(IServiceCollection services) { services.AddSingleton(Options.Create(this.ApplicationOptions)); services.AddMediatR(typeof(SubscribeCommand).Assembly); services.AddCommandBehavior(typeof(OperationExceptionHandlingBehavior <,>), typeof(SubscribeCommand).Assembly); services.AddHttpClient(typeof(EventChannel).Name, options => { options.BaseAddress = this.ApplicationOptions.Sink; options.DefaultRequestHeaders.Add(EventingDefaults.Headers.Origin, "natss"); }); services.AddSingleton(provider => { ConnectionSettingsBuilder settingsBuilder = ConnectionSettings.Create() .DisableTls() .KeepReconnecting(); return(EventStoreConnection.Create(this.ApplicationOptions.EventStore.ConnectionString, settingsBuilder, "CloudEventsChannel")); }); services.AddSingleton(provider => { return(new ProjectionsManager(new ConsoleLogger(), new DnsEndPoint(this.ApplicationOptions.EventStore.Host, this.ApplicationOptions.EventStore.HttpPort), TimeSpan.FromMilliseconds(3000), httpSchema: "http")); }); services.AddSingleton <IEventChannel, EventChannel>(); services.AddStartupTask <EventStoreInitializationTask>(); services.AddStartupTask <ProjectionsInitializationTask>(); services.AddStartupTask <EventChannelInitializationTask>(); services.AddHealthChecks() .AddCheck <StartupTasksHealthCheck>("Startup Tasks"); services.AddIstioHeadersPropagation(); services.AddControllers(options => { options.InputFormatters.Insert(0, new CloudEventJsonInputFormatter()); }) .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; }); }
private static ConnectionSettingsBuilder DefaultConfigureSettings( ConnectionSettingsBuilder builder) => builder;
public void WhenLoggerNotSet_ShouldDefaultToNull() { var builder = new ConnectionSettingsBuilder(); ((ConnectionSettings)builder).Log.Should().BeNull(); }
/// <summary> /// Creates a logging adapter for registered ILoggerProviders. /// </summary> /// <param name="connectionSettingsBuilder">The connection settings builder.</param> /// <param name="loggerFactory">The logger factory.</param> /// <returns></returns> public static ConnectionSettingsBuilder UseNetCoreLogger(this ConnectionSettingsBuilder connectionSettingsBuilder, ILoggerFactory loggerFactory) { return(connectionSettingsBuilder.UseCustomLogger(new EventStoreNetCoreLogger(loggerFactory))); }
public void WhenHttpClientProxyNotSet_ShouldDefaultToAHttpClientProxy() { var builder = new ConnectionSettingsBuilder(); ((ConnectionSettings)builder).HttpClientProxy.Should().NotBeNull(); }
public static ConnectionSettingsBuilder UseSsl(this ConnectionSettingsBuilder builder, bool useSsl) => useSsl?builder.UseSslConnection(false) : builder;
public void WhenHttpClientProxyNotSet_ShouldDefaultToAHttpClientProxy() { var builder = new ConnectionSettingsBuilder(); ((ConnectionSettings)builder).HttpClientProxy.Should().NotBeNull(); }
public void WhenConnectionNameNotSet_ShouldDefaultToAUniqueConnectionName() { var builder = new ConnectionSettingsBuilder(); var connectionName = ((ConnectionSettings)builder).ConnectionName; connectionName.Should().NotBeNull(); connectionName.Should().StartWith("ES-"); var expectedGuid = connectionName.Substring(3); Guid parsed; Guid.TryParse(expectedGuid, out parsed).Should().BeTrue(); }
public void AddConnectionSettingsBuilder(string ns, ConnectionSettingsBuilder connectionSettingsBuilder) { _connectionSettingsBuilders[ns] = connectionSettingsBuilder; }
public void AddConnectionSettingsBuilder(string ns, ConnectionSettingsBuilder connectionSettingsBuilder) { _connectionSettingsBuilders[ns] = connectionSettingsBuilder; }
private ConnectionSettings GetConnectionSettings() { var cs = new ConnectionSettingsBuilder() .SetDefaultUserCredentials(new UserCredentials(Username, Password)) .WithConnectionTimeoutOf(TimeSpan.FromSeconds(30)) .WithHttpClientProxy(_httpClientProxyMock.Object); return cs; }
public static ConnectionSettingsBuilder UseSsl(this ConnectionSettingsBuilder builder, bool useSsl) => useSsl?builder.UseSslConnection(Guid.NewGuid().ToString("n"), false) : builder;