コード例 #1
0
        public InMemoryStateStoreActor(IEnumerable <IDispatcher> dispatchers, long checkConfirmationExpirationInterval, long confirmationExpiration)
        {
            if (dispatchers == null)
            {
                throw new ArgumentNullException(nameof(dispatchers), "Dispatcher must not be null.");
            }

            _dispatchers          = dispatchers.ToList();
            _entryAdapterProvider = EntryAdapterProvider.Instance(Stage.World);
            _stateAdapterProvider = StateAdapterProvider.Instance(Stage.World);
            _entries                = new List <IEntry>();
            _entryReaders           = new Dictionary <string, IStateStoreEntryReader>();
            _store                  = new Dictionary <string, Dictionary <string, TRawState> >();
            _dispatchables          = new List <Dispatchable>();
            _readAllResultCollector = new ReadAllResultCollector();

            var dispatcherControlDelegate = new InMemoryDispatcherControlDelegate(_dispatchables);

            _dispatcherControl = Stage.ActorFor <IDispatcherControl>(
                () => new DispatcherControlActor(
                    _dispatchers,
                    dispatcherControlDelegate,
                    checkConfirmationExpirationInterval,
                    confirmationExpiration));
        }
コード例 #2
0
        public EventSourcedTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            var testWorld = TestWorld.StartWithDefaults("test-es");

            _world = testWorld.World;

            _dispatcher = new MockJournalDispatcher();

            var entryAdapterProvider = EntryAdapterProvider.Instance(_world);

            entryAdapterProvider.RegisterAdapter(new Test1HappenedAdapter());
            entryAdapterProvider.RegisterAdapter(new Test2HappenedAdapter());
            entryAdapterProvider.RegisterAdapter(new Test3HappenedAdapter());

            var journal = _world.ActorFor <IJournal <string> >(() => new InMemoryJournalActor <string>(_dispatcher));

            var registry = new SourcedTypeRegistry(_world);

            registry.Register(Info.RegisterSourced <TestEventSourcedEntity>(journal));
            registry.Register(Info.RegisterSourced <ProductEntity>(journal));
            registry.Register(Info.RegisterSourced <ProductParent>(journal));
            registry.Register(Info.RegisterSourced <ProductGrandparent>(journal));

            _result = new Result();
            _entity = _world.ActorFor <IEntity>(() => new TestEventSourcedEntity(_result));
        }
コード例 #3
0
        public InMemoryStateStoreActor(IDispatcher <Dispatchable <TEntry, TRawState> > dispatcher, long checkConfirmationExpirationInterval, long confirmationExpiration)
        {
            if (dispatcher == null)
            {
                throw new ArgumentNullException(nameof(dispatcher), "Dispatcher must not be null.");
            }

            _dispatcher           = dispatcher;
            _entryAdapterProvider = EntryAdapterProvider.Instance(Stage.World);
            _stateAdapterProvider = StateAdapterProvider.Instance(Stage.World);
            _entries       = new List <TEntry>();
            _entryReaders  = new Dictionary <string, IStateStoreEntryReader <TEntry> >();
            _store         = new Dictionary <string, Dictionary <string, TRawState> >();
            _dispatchables = new List <Dispatchable <TEntry, TRawState> >();

            var dispatcherControlDelegate = new InMemoryDispatcherControlDelegate <TEntry, TRawState>(_dispatchables);

            _dispatcherControl = Stage.ActorFor <IDispatcherControl>(
                Definition.Has <DispatcherControlActor <TEntry, TRawState> >(
                    Definition.Parameters(
                        dispatcher,
                        dispatcherControlDelegate,
                        checkConfirmationExpirationInterval,
                        confirmationExpiration)));
        }
コード例 #4
0
        public InMemoryObjectStoreActor(IDispatcher <Dispatchable <TEntry, TState> > dispatcher, long checkConfirmationExpirationInterval, long confirmationExpiration)
        {
            _entryAdapterProvider = EntryAdapterProvider.Instance(Stage.World);
            _dispatcher           = dispatcher;

            _entryReaders = new Dictionary <string, IObjectStoreEntryReader <IEntry <T> > >();

            _storeDelegate = new InMemoryObjectStoreDelegate <TEntry, TState>(StateAdapterProvider.Instance(Stage.World));

            _dispatcherControl = Stage.ActorFor <IDispatcherControl>(
                () => new DispatcherControlActor <TEntry, TState>(dispatcher, _storeDelegate,
                                                                  checkConfirmationExpirationInterval, confirmationExpiration));
        }
コード例 #5
0
        public InMemoryEventJournalActorTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world      = World.StartWithDefaults("test-journal");
            _dispatcher = new MockDispatcher <string, TextEntry, TextState>(new MockConfirmDispatchedResultInterest());

            _journal = Journal <string> .Using <InMemoryJournalActor <string, TextEntry, TextState>, TextEntry, TextState>(_world.Stage, _dispatcher);

            EntryAdapterProvider.Instance(_world).RegisterAdapter(new Test1SourceAdapter());
            EntryAdapterProvider.Instance(_world).RegisterAdapter(new Test2SourceAdapter());
            StateAdapterProvider.Instance(_world).RegisterAdapter(new SnapshotStateAdapter());
        }
コード例 #6
0
        private void RegisterSourcedTypes <TSourced>()
        {
            var entryAdapterProvider = EntryAdapterProvider.Instance(_world);

            _sourcedTypeRegistry.Register(Vlingo.Xoom.Lattice.Model.Sourcing.Info.RegisterSourced <TSourced>(_journal));

            _sourcedTypeRegistry.Info <TSourced>()?
            .RegisterEntryAdapter(new ProcessMessageTextAdapter(),
                                  adapter => entryAdapterProvider.RegisterAdapter(adapter))
            .RegisterEntryAdapter(new DoStepOneAdapter(),
                                  adapter => entryAdapterProvider.RegisterAdapter(adapter))
            .RegisterEntryAdapter(new DoStepTwoAdapter(),
                                  adapter => entryAdapterProvider.RegisterAdapter(adapter))
            .RegisterEntryAdapter(new DoStepThreeAdapter(),
                                  adapter => entryAdapterProvider.RegisterAdapter(adapter))
            .RegisterEntryAdapter(new DoStepFourAdapter(),
                                  adapter => entryAdapterProvider.RegisterAdapter(adapter))
            .RegisterEntryAdapter(new DoStepFiveAdapter(),
                                  adapter => entryAdapterProvider.RegisterAdapter(adapter));
        }
コード例 #7
0
        public InMemoryJournal(IEnumerable <IDispatcher> dispatchers, World world, long checkConfirmationExpirationInterval = 1000L, long confirmationExpiration = 1000L)
        {
            _dispatchers          = dispatchers.ToList();
            _entryAdapterProvider = EntryAdapterProvider.Instance(world);
            _stateAdapterProvider = StateAdapterProvider.Instance(world);
            _journal        = new List <IEntry>();
            _journalReaders = new Dictionary <string, IJournalReader>(1);
            _streamReaders  = new Dictionary <string, IStreamReader>(1);
            _streamIndexes  = new Dictionary <string, Dictionary <int, int> >();
            _snapshots      = new Dictionary <string, IState>();
            _dispatchables  = new List <Dispatchable>();

            var dispatcherControlDelegate = new InMemoryDispatcherControlDelegate(_dispatchables);

            _dispatcherControl = world.Stage.ActorFor <IDispatcherControl>(
                () => new DispatcherControlActor(
                    _dispatchers,
                    dispatcherControlDelegate,
                    checkConfirmationExpirationInterval,
                    confirmationExpiration));
        }
コード例 #8
0
        public ObjectProcessTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world = World.StartWithDefaults("five-step-process-test");

            var queue = new AsyncMessageQueue(null);

            _exchange = new LocalExchange(queue);
            var adapter = new ProcessMessageTextAdapter();

            EntryAdapterProvider.Instance(_world).RegisterAdapter(adapter);

            var dispatcher  = new MockDispatcher();
            var objectStore = _world.ActorFor <IObjectStore>(() => new InMemoryObjectStoreActor <string>(dispatcher));

            var objectTypeRegistry = new ObjectTypeRegistry(_world);

            var stepCountStateInfo =
                new Info <StepCountObjectState>(
                    objectStore,
                    nameof(StepCountObjectState),
                    MapQueryExpression.Using <StepCountObjectState>("find", MapQueryExpression.Map("id", "id")),
                    StateObjectMapper.With <StepCountObjectState>(new object(), new object()));

            objectTypeRegistry.Register(stepCountStateInfo);

            _exchangeSender = new LocalExchangeSender(queue);

            var processTypeRegistry = new ProcessTypeRegistry(_world);

            processTypeRegistry.Register(new ObjectProcessInfo <FiveStepEmittingObjectProcess, StepCountObjectState>(nameof(FiveStepEmittingObjectProcess), _exchange, objectTypeRegistry));

            _exchangeReceivers = new ExchangeReceivers();

            RegisterExchangeCoveys();
        }
コード例 #9
0
        public JournalProjectionDispatcherTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world = World.StartWithDefaults("test-journal-projections");

            _accessHolder = new AccessHolder();

            var descriptions = new List <ProjectToDescription>
            {
                ProjectToDescription <OneHappenedProjectionActor> .With <OneHappened>(() =>
                                                                                      new OneHappenedProjectionActor(_accessHolder)),
                ProjectToDescription <TwoHappenedProjectionActor> .With <TwoHappened>(() =>
                                                                                      new TwoHappenedProjectionActor(_accessHolder)),
                ProjectToDescription <AllHappenedProjectionActor>
                .With <OneHappened>(() => new AllHappenedProjectionActor(_accessHolder))
                .AndWith <TwoHappened>()
                .AndWith <ThreeHappened>()
            };

            var dispatcherProtocols =
                _world.Stage.ActorFor(
                    new[] { typeof(IDispatcher), typeof(IProjectionDispatcher) },
                    Definition.Has(() => new TextProjectionDispatcherActor(descriptions)));

            var dispatchers = Protocols.Two <IDispatcher, IProjectionDispatcher>(dispatcherProtocols);

            var dispatcher = dispatchers._1;

            _journal = Journal <string> .Using <InMemoryJournalActor <string> >(_world.Stage, dispatcher);

            EntryAdapterProvider.Instance(_world).RegisterAdapter(new OneHappenedAdapter());
            EntryAdapterProvider.Instance(_world).RegisterAdapter(new TwoHappenedAdapter());
            EntryAdapterProvider.Instance(_world).RegisterAdapter(new ThreeHappenedAdapter());

            _appendInterest = _world.Stage.ActorFor <IAppendResultInterest>(() => new JournalAppendResultInterest());
        }
コード例 #10
0
        public InMemoryJournal(IDispatcher <Dispatchable <TEntry, TState> > dispatcher, World world, long checkConfirmationExpirationInterval = 1000L, long confirmationExpiration = 1000L)
        {
            _dispatcher           = dispatcher;
            _entryAdapterProvider = EntryAdapterProvider.Instance(world);
            _stateAdapterProvider = StateAdapterProvider.Instance(world);
            _journal        = new List <TEntry>();
            _journalReaders = new Dictionary <string, IJournalReader <TEntry> >(1);
            _streamReaders  = new Dictionary <string, IStreamReader <T> >(1);
            _streamIndexes  = new Dictionary <string, Dictionary <int, int> >();
            _snapshots      = new Dictionary <string, TState>();
            _dispatchables  = new List <Dispatchable <TEntry, TState> >();

            var dispatcherControlDelegate = new InMemoryDispatcherControlDelegate <TEntry, TState>(_dispatchables);

            _dispatcherControl = world.Stage.ActorFor <IDispatcherControl>(
                Definition.Has <DispatcherControlActor <TEntry, TState> >(
                    Definition.Parameters(
                        dispatcher,
                        dispatcherControlDelegate,
                        checkConfirmationExpirationInterval,
                        confirmationExpiration)));
        }
コード例 #11
0
        /// <summary>
        /// Construct my default state and register me with the <see cref="World"/>.
        /// </summary>
        /// <param name="world">The World to which I am registered</param>
        public SourcedTypeRegistry(World world)
        {
            world.RegisterDynamic(InternalName, this);

            EntryAdapterProvider.Instance(world);
        }