Esempio n. 1
0
        public AggregateReactions()
        {
            TypeMapper RegisterTypes()
            {
                var m = new TypeMapper();

                m.Register(typeof(RegistrationSucceeded),
                           nameof(RegistrationSucceeded));
                m.Register(typeof(RegistrationFailed),
                           nameof(RegistrationFailed));
                m.Register(typeof(RegistrationStarted),
                           nameof(RegistrationStarted));
                return(m);
            }

            _store = new InMemoryStreamStore();
            var types = RegisterTypes();

            _repo = new SqlStreamStoreRepository(_store, types);
            var users = new UsersHandlers(_repo);

            _bus.Register <RegistrationStarted>(users.When);

            _registration = new UserRegistrationHandlers(_repo);

            _bus.Register <RegistrationSucceeded>(_registration.When);
            _bus.Register <RegistrationFailed>(_registration.When);

            var _ = new AllStreamSubscriber(_store, _bus, types, true);
        }
Esempio n. 2
0
        public ChannelActivity()
        {
            _store = new InMemoryStreamStore();
            var types = RegisterTypes();
            var repo  = new SqlStreamStoreRepository(_store, types);
            var bus   = new EventBus();

            _userService = new UserRegistrationHandlers(repo);
            var user = new UsersHandlers(repo);

            _readRepo = new InMemoryReadModelRepository();
            var channelHistoryService = new ChannelHistoryHandlers(_readRepo);

            _channelService = new ChannelCommandHandlers(repo);
            _chatService    = new ChatMessageHandlers(repo);
            bus.Register <ChannelCreated>(channelHistoryService.When);
            bus.Register <ChannelJoined>(channelHistoryService.When);
            bus.Register <ChannelLeft>(channelHistoryService.When);
            bus.Register <MessageSubmitted>(channelHistoryService.When);
            bus.Register <MessageEdited>(channelHistoryService.When);
            bus.Register <RegistrationStarted>(user.When);
            bus.Register <RegistrationSucceeded>(_userService.When);

            var _ = new AllStreamSubscriber(_store, bus, types, true);
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            //TODO: Get ConnStr from ENV vars or args. -LC
            var repo = new SqlStreamStoreRepository(@"Server=db;Database=CoD;User=sa;Password=Your_password123;");
            var createLoanHandler   = new CreateLoanCommandHandler(repo).WithLogging();
            var disbursementHandler = new DisburseLoanFundsCommandHandler(repo).WithLogging();
            var takePaymentHandler  = new TakePaymentCommandHandler(repo).WithLogging();

            var server = new Server(new RepositoryHealthCheck(repo), createLoanHandler, disbursementHandler, takePaymentHandler);

            server.Serve();
        }
Esempio n. 4
0
 public RepositoryHealthCheck(SqlStreamStoreRepository sqlStreamStoreRepository)
 {
     this.sqlStreamStoreRepository = sqlStreamStoreRepository;
 }