public static MongoDbConfigBuilder UseMongoDb(
            this EventStoreConfigurationBuilder builder,
            string mongoDbConnectionString,
            string eventCollectionName,
            bool automaticallyCreateIndexes = true)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (mongoDbConnectionString == null)
            {
                throw new ArgumentNullException("mongoDbConnectionString");
            }
            if (eventCollectionName == null)
            {
                throw new ArgumentNullException("eventCollectionName");
            }

            var mongoUrl = GetMongoUrl(mongoDbConnectionString);

            var database = new MongoClient(mongoUrl)
                           .GetServer()
                           .GetDatabase(mongoUrl.DatabaseName);

            return(UseMongoDbEventStore(builder, database, eventCollectionName, automaticallyCreateIndexes));
        }
        /// <summary>
        /// Configures Cirqus to use Postgres as the event store
        /// </summary>
        public static void UsePostgreSql(
            this EventStoreConfigurationBuilder builder,
            string connectionStringOrConnectionStringName,
            string tableName,
            bool automaticallyCreateSchema = true,
            Action <NpgsqlConnection> additionalConnectionSetup = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (connectionStringOrConnectionStringName == null)
            {
                throw new ArgumentNullException("connectionStringOrConnectionStringName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }

            //Brett
            builder.Register <IEventStore>(context =>
                                           new PostgreSqlEventStore(
                                               configuration: context.GetService <IConfigurationRoot>(),
                                               connectionStringOrConnectionStringName,
                                               tableName,
                                               automaticallyCreateSchema: automaticallyCreateSchema,
                                               additionalConnectionSetup: additionalConnectionSetup
                                               )
                                           );

            //builder.Register<IEventStore>(context => new PostgreSqlEventStore(connectionStringOrConnectionStringName, tableName, automaticallyCreateSchema: automaticallyCreateSchema, additionalConnectionSetup: additionalConnectionSetup));
        }
        static MongoDbConfigBuilder UseMongoDbEventStore(EventStoreConfigurationBuilder builder, MongoDatabase database, string eventCollectionName, bool automaticallyCreateIndexes)
        {
            var configBuilder = new MongoDbConfigBuilder();

            builder.Register<IEventStore>(context => new MongoDbEventStore(database, eventCollectionName, automaticallyCreateIndexes: automaticallyCreateIndexes));

            return configBuilder;
        }
        static MongoDbConfigBuilder UseMongoDbEventStore(EventStoreConfigurationBuilder builder, MongoDatabase database, string eventCollectionName, bool automaticallyCreateIndexes)
        {
            var configBuilder = new MongoDbConfigBuilder();

            builder.Register <IEventStore>(context => new MongoDbEventStore(database, eventCollectionName, automaticallyCreateIndexes: automaticallyCreateIndexes));

            return(configBuilder);
        }
Ejemplo n.º 5
0
        internal static Task <InMemoryEventStore> UseInMemoryEventStore(this EventStoreConfigurationBuilder builder)
        {
            var inMemoryEventStore = new InMemoryEventStore();

            builder.RegisterInstance <IEventStore>(inMemoryEventStore);

            return(Task.FromResult(inMemoryEventStore));
        }
Ejemplo n.º 6
0
        internal static Task <InMemoryEventStore> UseInMemoryEventStore(this EventStoreConfigurationBuilder builder)
        {
            var taskCompletionSource = new TaskCompletionSource <InMemoryEventStore>();

            builder.Register <IEventStore>(c =>
            {
                var inMemoryEventStore = new InMemoryEventStore(c.Get <IDomainEventSerializer>());
                taskCompletionSource.SetResult(inMemoryEventStore);
                return(inMemoryEventStore);
            });

            return(taskCompletionSource.Task);
        }
Ejemplo n.º 7
0
        public static void UseFiles(this EventStoreConfigurationBuilder builder, string path)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }

            builder.Register <IEventStore>(context => new NtfsEventStore(path));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Configures Cirqus to use SQLite as the event store
        /// </summary>
        public static void UseSQLite(this EventStoreConfigurationBuilder builder, string databasePath)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (databasePath == null)
            {
                throw new ArgumentNullException("databasePath");
            }

            builder.Register <IEventStore>(context => new SQLiteEventStore(databasePath));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Configures Cirqus to use Postgres as the event store
        /// </summary>
        public static void UsePostgreSql(this EventStoreConfigurationBuilder builder, string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateSchema = true)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (connectionStringOrConnectionStringName == null)
            {
                throw new ArgumentNullException("connectionStringOrConnectionStringName");
            }
            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }

            builder.Register <IEventStore>(context => new PostgreSqlEventStore(connectionStringOrConnectionStringName, tableName, automaticallyCreateSchema: automaticallyCreateSchema));
        }
Ejemplo n.º 10
0
        public static MongoDbConfigBuilder UseMongoDb(this EventStoreConfigurationBuilder builder, MongoDatabase database, string eventCollectionName, bool automaticallyCreateIndexes = true)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }
            if (eventCollectionName == null)
            {
                throw new ArgumentNullException("eventCollectionName");
            }

            return(UseMongoDbEventStore(builder, database, eventCollectionName, automaticallyCreateIndexes));
        }
        public static void UseSqlServer(this EventStoreConfigurationBuilder builder, string connectionStringName, string tableName, bool automaticallyCreateSchema = true)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (connectionStringName == null)
            {
                throw new ArgumentNullException(nameof(connectionStringName));
            }
            if (tableName == null)
            {
                throw new ArgumentNullException(nameof(tableName));
            }

            builder.Register <IEventStore>(context => new MsSqlEventStore(context.GetService <IConfigurationRoot>(),
                                                                          connectionStringName,
                                                                          tableName,
                                                                          automaticallyCreateSchema: automaticallyCreateSchema));
        }