Example #1
0
 public MigrationHandler(EventStoreFactory eventStoreFactory, IEnumerable<IMigration<AggregateCommit>> migrations, IMigrationCustomLogic theLogic, ILogger<MigrationHandler> logger)
 {
     eventStore = eventStoreFactory.GetEventStore();
     this.migrations = migrations;
     this.theLogic = theLogic;
     this.logger = logger;
 }
        public FollowersRepositoryTests()
        {
            var factory = new EventStoreFactory();

            factory.EnsureEventStoreIsCreated();
            _documentSession = factory.DocumentSession();
            _repository      = new FollowersRepository(_documentSession);
        }
        protected void ConfigureEventStore()
        {
            var loggerFactory = Substitute.For <ILoggerFactory>();

            loggerFactory.Create(Arg.Any <Type>()).Returns(NullLogger.Instance);
            var factory = new EventStoreFactory(loggerFactory);

            _eventStore = factory.BuildEventStore(_eventStoreConnectionString);
        }
Example #4
0
        public void SetUp()
        {
            _connectionString = ConfigurationManager.ConnectionStrings["eventstore"].ConnectionString;
            this._db          = TestHelper.CreateNew(_connectionString);

            var loggerFactory = Substitute.For <ILoggerFactory>();

            loggerFactory.Create(Arg.Any <Type>()).Returns(NullLogger.Instance);
            _factory = new EventStoreFactory(loggerFactory);
        }
Example #5
0
 public FullNameRepository(IFullNameProjector modelProjector)
 {
     _connection        = EventStoreFactory.GetConnection();
     _modelProjector    = modelProjector;
     _eventTypeResolver = new Dictionary <string, Type>()
     {
         { typeof(FullNameCreatedEvent).Name, typeof(FullNameCreatedEvent) },
         { typeof(FullNameUpdatedEvent).Name, typeof(FullNameUpdatedEvent) }
     };
 }
        /// <summary>
        /// Creates a new instance of <see cref="CompositionRoot"/>
        /// </summary>
        public CompositionRoot()
        {
            this.jitneyFactory           = new JitneyFactory();
            this.eventStoreFactory       = new EventStoreFactory();
            this.jitneyConfiguration     = new ContainerLessJitneyConfiguration(this.jitneyFactory);
            this.eventStoreConfiguration = new ContainerLessEventStoreConfiguration(this.eventStoreFactory);
            this.boundedContexts         = new List <IBoundedContext>();

            this.executionContext = null;
        }
Example #7
0
        private static void ConnectToEventStore()
        {
            EventStore = EventStoreFactory.CreateEventStore();
            string connectionString = "tcp://" + ConfigManager.ServiceDiscovery.EventStoreUrl + ":" + ConfigManager.ServiceDiscovery.EventStoreTcpPort;

            EventStore.Connect(connectionString, ConfigManager.ServiceDiscovery.EventStoreUser,
                               ConfigManager.ServiceDiscovery.EventStorePassword,
                               ConfigManager.ServiceDiscovery.EventStoreCommonName,
                               false, ConfigManager.ServiceDiscovery.EventStoreReconnectionAttempts,
                               ConfigManager.EventStoreHeartbeatInterval, ConfigManager.EventStoreHeartbeatTimeout);
        }
Example #8
0
        public SqlIntegrationTest()
        {
            this.aggregateId = Guid.NewGuid();
            this.bus         = A.Fake <IDeliverMessages>();

            var factory       = new EventStoreFactory();
            var configuration = new ContainerLessEventStoreConfiguration(factory);

            configuration.UseSqlEventStore();

            this.testee = factory.Create(configuration, bus);
        }
Example #9
0
        public IntegrationTest()
        {
            var factory       = new EventStoreFactory();
            var configuration = new ContainerLessEventStoreConfiguration(factory);

            configuration.UseRavenEventStore(this.DocumentStore);

            var bus = A.Fake <IDeliverMessages>();

            var eventStore = factory.Create(configuration, bus);

            this.repository = new EventStoreRepository(eventStore).WithGlobalSnapshotStrategy(10);
        }
Example #10
0
        public void SetUp()
        {
            _connectionString = ConfigurationManager.ConnectionStrings["saga"].ConnectionString;
            var db = TestHelper.CreateNew(_connectionString);

            var loggerFactory = Substitute.For <ILoggerFactory>();

            loggerFactory.Create(Arg.Any <Type>()).Returns(NullLogger.Instance);
            _factory = new EventStoreFactory(loggerFactory);

            _eventStore = _factory.BuildEventStore(_connectionString);
            _repo       = new SagaEventStoreRepositoryEx(_eventStore, new SagaFactory());
            _listener   = new DeliverPizzaSagaListener2();
        }
        public void CanOpenTypedEventStream()
        {
            var factory       = new EventStoreFactory();
            var configuration = new ContainerLessEventStoreConfiguration(factory);

            configuration.UseRavenEventStore(this.DocumentStore);

            var bus = A.Fake <IDeliverMessages>();

            var testee = factory.Create(configuration, bus);

            var eventStream = testee.OpenStream <MyStaticEventSourcedAggregateRoot>(Guid.NewGuid());

            eventStream.Should().BeAssignableTo <RavenEventStream <MyStaticEventSourcedAggregateRoot> >();
        }
Example #12
0
        public ICqrsRuntime Build(
            AssemblyScanConfig[] assembliesWithCommandHandlers,
            AssemblyScanConfig[] assembliesWithEventHandlers)
        {
            var commandHandlers = OnResolveCommandHandlers(assembliesWithCommandHandlers);
            var eventHandlers   = OnResolveEventHandlers(assembliesWithEventHandlers);

            return(new CqrsRuntime
                   (
                       CommandBusFactory.Invoke(commandHandlers),
                       EventStoreFactory.Invoke(),
                       EventApplierFactory.Invoke(),
                       EventPublisherFactory.Invoke(eventHandlers)
                   ));
        }
        protected void ConfigureEventStore()
        {
            var loggerFactory = Substitute.For <ILoggerFactory>();

            loggerFactory.Create(Arg.Any <Type>()).Returns(NullLogger.Instance);
            var factory = new EventStoreFactory(loggerFactory);

            _eventStore = factory.BuildEventStore(_eventStoreConnectionString);
            Repository  = new RepositoryEx(
                _eventStore,
                new AggregateFactory(),
                new ConflictDetector(),
                _identityConverter
                );
        }
Example #14
0
        private static void DomoShare_ThermostatSystemModeChanged(object sender, ThermostatSystemModeChangedEventArgs e)
        {
            var tenantId = Guid.Parse(Configuration.GetSection("AppSettings").GetSection("ControllerId").Value);

            if (EventStore == null)
            {
                Trace.TraceInformation($"{DateTime.Now}: EventStore is null. Creating a new one");
                Console.WriteLine($"{DateTime.Now}: EventStore is null. Creating a new one");
                EventStore = EventStoreFactory.CreateEventStore();
            }
            SystemModeChangeCommand cmd = new SystemModeChangeCommand(e.TenantId, e.ThermostatId,
                                                                      e.ThermostatGuid, e.NewSystemMode);
            ChangeSystemMode changeSystemModeCommand = new ChangeSystemMode(EventStore, e.ThermostatId, e.ThermostatGuid,
                                                                            e.TenantId, e.NewSystemMode);
            var handler = new ThermostatCommandHandlers();

            handler.Handle(changeSystemModeCommand);
        }
Example #15
0
 public RebuildIndex_MessageCounter_Job(CronusContext context, TypeContainer <IEvent> eventTypes, EventStoreFactory eventStoreFactory, IMessageCounter eventCounter, EventToAggregateRootId eventToAggregateIndex, IProjectionReader projectionReader, ILogger <RebuildIndex_MessageCounter_Job> logger) : base(logger)
 {
     this.context               = context;
     this.eventTypes            = eventTypes;
     this.eventStore            = eventStoreFactory.GetEventStore();
     this.messageCounter        = eventCounter;
     this.eventToAggregateIndex = eventToAggregateIndex;
     this.projectionReader      = projectionReader;
 }
Example #16
0
 public MigrationRunner(IMigrationEventStorePlayer source, EventStoreFactory factory) : base(source, factory.GetEventStore())
 {
 }
Example #17
0
 public static void Init(string connectionString)
 {
     EventStoreFactory.Init(connectionString);
     InitializeDependencyInjection();
 }
Example #18
0
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration httpConfig = new HttpConfiguration();

            WebApiConfig.Register(httpConfig);
            ConfigureOAuthTokenConsumption(app);
            ConfigureWebApi(httpConfig);

            var container = new WindsorContainer();

            container.Register(Classes.FromThisAssembly()
                               .Pick().If(t => t.Name.EndsWith("Controller"))
                               .Configure(configurer => configurer.Named(configurer.Implementation.Name))
                               .LifestylePerWebRequest());

            var httpDependencyResolver = new WindsorHttpDependencyResolver(container.Kernel);

            container.Register(Types.FromAssemblyNamed("CashLady.Services").BasedOn <IConsumer>());

            var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri("rabbitmq://localhost/"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                cfg.ReceiveEndpoint("TestPublisher", ec =>
                {
                    ec.UseMessageScope();
                    ec.LoadFrom(container);
                });
            });

            busControl.Start();

            container.Register(Component.For <IBusControl>().Instance(busControl));

            container.Register(
                Component.For <IEventPublisher>().ImplementedBy <MassTransitServiceBus>().Named("EventPublisher")
                .DependsOn(busControl));


            container.Register(
                Component.For <ICommandSender>()
                .ImplementedBy <MassTransitServiceBus>().Named("CommandSender")
                .LifeStyle.Transient);


            var store = EventStoreFactory.CreateSqlEventStore("EventStoreSQLDatabase");


            container.Register(Component.For <IEventStore>().Instance(store));


            var eventStore = container.Resolve <IEventStore>();

            container.Register(
                Component.For <IRepository <LoanAggregate> >()
                .ImplementedBy <Repository <LoanAggregate> >().DependsOn(eventStore)
                .LifeStyle.Transient);

            container.Register(
                Component.For <IRepository <UserAggregate> >()
                .ImplementedBy <Repository <UserAggregate> >().DependsOn(eventStore)
                .LifeStyle.Transient);

            httpConfig.DependencyResolver = httpDependencyResolver;

            app.UseWebApi(httpConfig);
        }