Exemplo n.º 1
0
        public IStoreEvents BuildEventStore(
            string connectionString,
            IPipelineHook[] hooks     = null,
            Boolean useSyncDispatcher = false,
            MongoPersistenceOptions mongoPersistenceOptions = null)
        {
            mongoPersistenceOptions = mongoPersistenceOptions ??
                                      new MongoPersistenceOptions()
            {
            };
            Wireup es = Wireup.Init()
                        .LogTo(t => new NEventStoreLog4NetLogger(_loggerFactory.Create(t)))
                        .UsingMongoPersistence(
                () => connectionString,
                new DocumentObjectSerializer(),
                mongoPersistenceOptions
                )
                        .InitializeStorageEngine();

            UseSyncDispatcher = useSyncDispatcher;

            if (hooks != null)
            {
                es.HookIntoPipelineUsing(hooks);
            }

            return(es.Build());
        }
        public IStoreEvents BuildEventStore(
            string connectionString,
            IPipelineHook[] hooks     = null,
            Boolean useSyncDispatcher = false,
            MongoPersistenceOptions mongoPersistenceOptions = null)
        {
            mongoPersistenceOptions = mongoPersistenceOptions ??
                                      new MongoPersistenceOptions()
            {
                ServerSideOptimisticLoop = true
            };
            Wireup es = Wireup.Init()
                        .LogTo(t => new NEventStoreLog4NetLogger(_loggerFactory.Create(t)))
                        .UsingMongoPersistence(
                () => connectionString,
                new DocumentObjectSerializer(),
                mongoPersistenceOptions
                )
                        .InitializeStorageEngine();

            UseSyncDispatcher = useSyncDispatcher;

            if (CommitsDispatcher != null && !(CommitsDispatcher is NullDispatcher))
            {
                if (UseSyncDispatcher)
                {
                    es = es.UsingSynchronousDispatchScheduler().DispatchTo(CommitsDispatcher);
                }
                else
                {
                    es = es.UsingAsynchronousDispatchScheduler().DispatchTo(CommitsDispatcher);
                }
            }
            else
            {
                es.DoNotDispatchCommits();
            }

            if (hooks != null)
            {
                es.HookIntoPipelineUsing(hooks);
            }

            return(es.Build());
        }