Ejemplo n.º 1
0
        internal Tuple <EventStoreConnectionString, IEventStoreConnection> CreateConnection(IApplicationConfiguration configuration)
        {
            var connectionString = new EventStoreConnectionString(ConnectionStringName, configuration);

            var connection = connectionString.CreateConnection(x =>
            {
                foreach (var modifier in _settingsModifiers)
                {
                    modifier(x);
                }
            });

            return(new Tuple <EventStoreConnectionString, IEventStoreConnection>(connectionString, connection));
        }
Ejemplo n.º 2
0
        public IEnumerable <ConfigurationSetupResult> Setup(string applicationEnvironment)
        {
            yield return(new ConfigurationSetupResult("superglue.EventStore.Setup", environment =>
            {
                environment.AlterSettings <EventStoreSettings>(x =>
                {
                    x.ModifySettings(y =>
                    {
                        y.KeepReconnecting();
                        y.KeepRetrying();
                        y.UseCustomLogger(new EventStoreLog(environment));
                    });

                    x.StoreCommands((env, command, id, causationId) => "commands");
                });

                environment.AlterSettings <IocConfiguration>(x => x.Register(typeof(IEventStoreConnection), (y, z) => connection, RegistrationLifecycle.Singletone)
                                                             .Register(typeof(EventStoreConnectionString), (y, z) => connectionString, RegistrationLifecycle.Singletone)
                                                             .Register(typeof(IHandleEventSerialization), typeof(DefaultEventSerializer))
                                                             .Register(typeof(IRepository), typeof(DefaultRepository))
                                                             .Register(typeof(ICheckConflicts), typeof(DefaultConflictChecker))
                                                             .Register(typeof(IManageTimeOuts), typeof(DefaultTimeOutManager))
                                                             .Scan(typeof(IManageChanges))
                                                             .ScanOpenType(typeof(ICheckConflict <,>)));

                TimeOutManager.Configure(() => new StoreTimeoutsInMemory());

                return Task.CompletedTask;
            }, "superglue.LoggingSetup", environment =>
            {
                connection.Close();

                return Task.CompletedTask;
            }, configuration =>
            {
                var connectionInformation = configuration
                                            .WithSettings <EventStoreSettings>()
                                            .CreateConnection(configuration.Settings.Resolve <IApplicationConfiguration>());

                connection = connectionInformation.Item2;
                connectionString = connectionInformation.Item1;

                return connection.ConnectAsync();
            }));
        }