Пример #1
0
        public MongoPersistenceWireup(Wireup inner, string connectionName, IDocumentSerializer serializer) : base(inner)
        {
            Logger.Debug("Configuring Mongo persistence engine.");

            var options = Container.Resolve <TransactionScopeOption>();

            if (options != TransactionScopeOption.Suppress)
            {
                Logger.Warn("MongoDB does not participate in transactions using TransactionScope.");
            }

            Container.Register(c => new MongoPersistenceFactory(connectionName, serializer).Build());
        }
        public MongoPersistenceWireup(Wireup inner, Func <string> connectionStringProvider, IDocumentSerializer serializer, MongoPersistenceOptions persistenceOptions)
            : base(inner)
        {
            Logger.LogDebug("Configuring Mongo persistence engine.");

            var options = Container.Resolve <TransactionScopeOption>();

            if (options != TransactionScopeOption.Suppress)
            {
                Logger.LogWarning("MongoDB does not participate in transactions using TransactionScope.");
            }

            Container.Register(_ => new MongoPersistenceFactory(connectionStringProvider, serializer, persistenceOptions).Build());
        }
Пример #3
0
        public AsynchronousDispatchSchedulerWireup(Wireup wireup, IDispatchCommits dispatcher)
            : base(wireup)
        {
            var option = Container.Resolve <TransactionScopeOption>();

            if (option != TransactionScopeOption.Suppress)
            {
                Logger.Warn(Messages.SynchronousDispatcherTwoPhaseCommits);
            }

            Logger.Debug(Messages.AsyncDispatchSchedulerRegistered);
            DispatchTo(dispatcher ?? new NullDispatcher());
            Container.Register <IScheduleDispatches>(c => new AsynchronousDispatchScheduler(
                                                         c.Resolve <IDispatchCommits>(), c.Resolve <IPersistStreams>()));
        }
Пример #4
0
        public SqlPersistenceWireup(Wireup wireup, IConnectionFactory connectionFactory)
            : base(wireup)
        {
            Logger.Debug(Messages.ConnectionFactorySpecified, connectionFactory);

            Logger.Verbose(Messages.AutoDetectDialect);
            Container.Register <ISqlDialect>(c => null); // auto-detect

            Container.Register(c => new SqlPersistenceFactory(
                                   connectionFactory,
                                   c.Resolve <ISerialize>(),
                                   c.Resolve <ISqlDialect>(),
                                   c.Resolve <TransactionScopeOption>(),
                                   _pageSize).Build());
        }
Пример #5
0
        public RavenPersistenceWireup(Wireup inner) : base(inner)
        {
            Logger.Debug("Configuring Raven persistence engine.");

            Container.Register(
                c =>
                new RavenConfiguration
            {
                Serializer        = ResolveSerializer(c),
                ScopeOption       = c.Resolve <TransactionScopeOption>(),
                ConsistentQueries = _consistentQueries,
                MaxServerPageSize = _maxServerPageSize,
                RequestedPageSize = _pageSize,
            });

            Container.Register <IPersistStreams>(c => new RavenPersistenceEngine(_getStoreAction(), c.Resolve <RavenConfiguration>()));
        }
 public SynchronousDispatchSchedulerWireup(Wireup wireup, IDispatchCommits dispatcher, DispatcherSchedulerStartup startup)
     : base(wireup)
 {
     Logger.Debug(Messages.SyncDispatchSchedulerRegistered);
     Startup(startup);
     DispatchTo(dispatcher ?? new NullDispatcher());
     Container.Register <IScheduleDispatches>(c =>
     {
         var dispatchScheduler = new SynchronousDispatchScheduler(
             c.Resolve <IDispatchCommits>(),
             c.Resolve <IPersistStreams>());
         if (c.Resolve <DispatcherSchedulerStartup>() == DispatcherSchedulerStartup.Auto)
         {
             dispatchScheduler.Start();
         }
         return(dispatchScheduler);
     });
 }
Пример #7
0
        private static void EventStoreTest()
        {
            Guid StreamId = Guid.NewGuid();
            var  bus      = ServiceBusFactory.New(sbc =>
            {
            });

            var store = Wireup.Init()
                        .LogToOutputWindow()
                        .UsingInMemoryPersistence()
                        .UsingSqlPersistence("EventStoreConnection") // Connection string is in app.config
                        .WithDialect(new MsSqlDialect())
                        .EnlistInAmbientTransaction()                // two-phase commit
                        .InitializeStorageEngine()
                        .TrackPerformanceInstance("example")
                        .UsingJsonSerialization()
                        .Compress()
                        .EncryptWith(EncryptionKey)
                        .HookIntoPipelineUsing(new[] { new AuthorizationPipelineHook() })
                        .UsingSynchronousDispatchScheduler()
                        .DispatchTo(new DelegateMessageDispatcher(DispatchCommit))
                        .Build();

            using (store)
            {
                using (var stream = store.CreateStream(StreamId))
                {
                    stream.Add(new EventMessage()
                    {
                        Body = "Hello World!"
                    });
                    stream.CommitChanges(StreamId);
                }

                using (var stream = store.OpenStream(StreamId, 0, int.MinValue))
                {
                    foreach (var evnt in stream.CommittedEvents)
                    {
                        Console.WriteLine(evnt.Body);
                    }
                }
            }
        }
Пример #8
0
        public EventUpconverterWireup(Wireup wireup) : base(wireup)
        {
            Logger.Debug(Messages.EventUpconverterRegistered);

            Container.Register(c =>
            {
                if (_registered.Count > 0)
                {
                    return(new EventUpconverterPipelineHook(_registered));
                }

                if (!_assembliesToScan.Any())
                {
                    _assembliesToScan.AddRange(GetAllAssemblies());
                }

                IDictionary <Type, Func <object, object> > converters = GetConverters(_assembliesToScan);
                return(new EventUpconverterPipelineHook(converters));
            });
        }
 public static PersistenceWireup UsingMongoPersistence(this Wireup wireup, string connectionName, IDocumentSerializer serializer)
 {
     return(new MongoPersistenceWireup(wireup, connectionName, serializer));
 }
Пример #10
0
 public SerializationWireup(Wireup inner, ISerialize serializer)
     : base(inner)
 {
     Container.Register(serializer);
 }
 protected override void Context()
 {
     _wireup = Wireup.Init()
               // .UsingInMemoryPersistence() // the InMemoryPersistence should be the default serializer
               .UseTestableWireup();
 }
Пример #12
0
 public PersistenceWireup(Wireup inner)
     : base(inner)
 {
     Container.Register(TransactionScopeOption.Suppress);
 }
Пример #13
0
 public static PersistenceWireup UsingMongoPersistence(this Wireup wireup, Func <string> connectionStringProvider, IDocumentSerializer serializer, MongoPersistenceOptions options = null)
 {
     return(new MongoPersistenceWireup(wireup, connectionStringProvider, serializer, options));
 }
Пример #14
0
 public static NoopDispatchSchedulerWireup DoNotDispatchCommits(this Wireup wireup)
 {
     return(new NoopDispatchSchedulerWireup(wireup));
 }
Пример #15
0
        public static SqlPersistenceWireup UsingSqlPersistence(this Wireup wireup, DbProviderFactory providerFactory, string connectionString)
        {
            var factory = new NetStandardConnectionFactory(providerFactory, connectionString);

            return(wireup.UsingSqlPersistence(factory));
        }
Пример #16
0
 public RavenPersistenceWireup(Wireup inner, Func <IDocumentStore> getStore) : this(inner)
 {
     _getStoreAction = getStore;
 }
Пример #17
0
 protected Wireup(Wireup inner)
 {
     _inner = inner;
 }
Пример #18
0
        public static SqlPersistenceWireup UsingSqlPersistence(this Wireup wireup, string connectionName)
        {
            var factory = new ConfigurationConnectionFactory(connectionName);

            return(wireup.UsingSqlPersistence(factory));
        }
Пример #19
0
 public static SqlPersistenceWireup UsingSqlPersistence(this Wireup wireup, IConnectionFactory factory)
 {
     return(new SqlPersistenceWireup(wireup, factory));
 }
Пример #20
0
 protected override Task Context()
 {
     _wireup = Wireup.Init()
               .UsingInMemoryPersistence();
     return(Task.CompletedTask);
 }
Пример #21
0
 protected override Task Context()
 {
     _wireup = Wireup.Init()
               .UsingInMemoryPersistence();
     return(Task.FromResult(true));
 }
Пример #22
0
 public RavenPersistenceWireup(Wireup inner, string connectionName) : this(inner)
 {
     _getStoreAction = CreateStore;
     CreateWithConnectionStringName(connectionName);
 }
Пример #23
0
        public static PersistenceWireup UsingInMemoryPersistence(this Wireup wireup)
        {
            wireup.With <IPersistStreams>(new InMemoryPersistenceEngine());

            return(new PersistenceWireup(wireup));
        }
 protected override void Context()
 {
     _wireup = Wireup.Init()
               .UsingSqlPersistence("fakeConnectionString")
               .WithDialect(new Persistence.Sql.SqlDialects.MsSqlDialect());
 }
Пример #25
0
 public NoopDispatchSchedulerWireup(Wireup wireup)
     : base(wireup)
 {
     Container.Register <IScheduleDispatches>(c => new NoopDispatcherScheduler());
 }
Пример #26
0
 public static Wireup LogToOutputWindow(this Wireup wireup)
 {
     return(wireup.LogTo(type => new OutputWindowLogger(type)));
 }
Пример #27
0
 public static AsynchronousDispatchSchedulerWireup UsingAsynchronousDispatchScheduler(
     this Wireup wireup,
     IDispatchCommits dispatcher)
 {
     return(new AsynchronousDispatchSchedulerWireup(wireup, dispatcher, DispatcherSchedulerStartup.Auto));
 }
Пример #28
0
 public static Wireup LogTo(this Wireup wireup, Func <Type, ILog> logger)
 {
     LogFactory.BuildLogger = logger;
     return(wireup);
 }
Пример #29
0
 public static SynchronousDispatchSchedulerWireup UsingSynchronousDispatchScheduler(this Wireup wireup)
 {
     return(wireup.UsingSynchronousDispatchScheduler(null));
 }
Пример #30
0
 public static Wireup LogToConsoleWindow(this Wireup wireup)
 {
     return(wireup.LogTo(type => new ConsoleWindowLogger(type)));
 }