public InMemoryStateStoreEntryReaderActorTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); var testWorld = TestWorld.StartWithDefaults("test-store"); var world = testWorld.World; _interest = new MockStateStoreResultInterest(); _dispatcher = new MockStateStoreDispatcher <IEntry <string>, TextState>(_interest); var stateAdapterProvider = new StateAdapterProvider(world); _entryAdapterProvider = new EntryAdapterProvider(world); stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter()); // NOTE: No adapter registered for Entity2.class because it will use the default _store = world.ActorFor <IStateStore <IEntry <string> > >(typeof(InMemoryStateStoreActor <TextState, IEntry <string> >), _dispatcher); var completes = _store.EntryReader("test"); _reader = completes.Await(); StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity1).FullName, typeof(Entity1)); StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity2).FullName, typeof(Entity2)); }
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)); }
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)); }
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))); }
/// <summary> /// Construct my default state. /// </summary> /// <param name="journal">The <see cref="IJournal{T}"/> of the registration</param> /// <param name="sourcedType">The type of the registered source</param> private Info(IJournal journal, Type sourcedType) { Journal = journal; SourcedType = sourcedType; EntryAdapterProvider = new EntryAdapterProvider(); StateAdapterProvider = new StateAdapterProvider(); }
/// <summary> /// Construct my default state. /// </summary> /// <param name="stateType">The type of state store state</param> /// <param name="storeName">The string name of the Store</param> /// <param name="store">The store</param> public Info(IStateStore store, Type stateType, string storeName) { Store = store; StoreType = stateType; StoreName = storeName; EntryAdapterProvider = new EntryAdapterProvider(); StateAdapterProvider = new StateAdapterProvider(); }
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)); }
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()); }
public InMemoryObjectStoreActorTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); _persistInterest = new MockPersistResultInterest(); _queryResultInterest = new MockQueryResultInterest(); _world = World.StartWithDefaults("test-object-store"); var entryAdapterProvider = new EntryAdapterProvider(_world); entryAdapterProvider.RegisterAdapter(new Test1SourceAdapter()); _dispatcher = new MockDispatcher <Test1Source, ObjectEntry <Test1Source>, State <string> >(new MockConfirmDispatchedResultInterest()); _objectStore = _world.ActorFor <IObjectStore>(typeof(Vlingo.Symbio.Store.Object.InMemory.InMemoryObjectStoreActor <Test1Source, ObjectEntry <Test1Source>, State <string> >), _dispatcher); }
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)); }
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)); }
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(); }
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()); }
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))); }
public Info RegisterEntryAdapter <TSource, TEntry>(IEntryAdapter <TSource, TEntry> adapter, Action <IEntryAdapter <TSource, TEntry> > consumer) where TSource : ISource where TEntry : IEntry { EntryAdapterProvider.RegisterAdapter(adapter, consumer); return(this); }
/// <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); }