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 InMemoryStateStoreRedispatchControlTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); _world = World.StartWithDefaults("test-store"); _interest = new MockStateStoreResultInterest(); _interest.AfterCompleting <string, Entity1>(0); _dispatcher = new MockStateStoreDispatcher <TextState>(_interest); var stateAdapterProvider = new StateAdapterProvider(_world); new EntryAdapterProvider(_world); stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter()); // NOTE: No adapter registered for Entity2.class because it will use the default StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity1).FullName, typeof(Entity1)); _store = _world.ActorFor <IStateStore>(typeof(InMemoryStateStoreActor <TextState>), new List <IDispatcher> { _dispatcher }); }
/// <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(); }
public InMemoryStateStoreTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); var testWorld = TestWorld.StartWithDefaults("test-store"); _world = testWorld.World; _interest = new MockStateStoreResultInterest(); _dispatcher = new MockStateStoreDispatcher <TextEntry, TextState>(_interest); var stateAdapterProvider = new StateAdapterProvider(_world); new EntryAdapterProvider(_world); stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter()); // NOTE: No adapter registered for Entity2.class because it will use the default _store = _world.ActorFor <IStateStore <TextEntry> >(typeof(InMemoryStateStoreActor <TextState, TextEntry>), _dispatcher); StateTypeStateStoreMap.StateTypeToStoreName(_storeName1, typeof(Entity1)); StateTypeStateStoreMap.StateTypeToStoreName(_storeName2, typeof(Entity2)); }
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))); }
public ProjectionDispatcherTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); World = World.StartWithDefaults("test-store"); var stateAdapterProvider = new StateAdapterProvider(World); stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter()); new EntryAdapterProvider(World); StateTypeStateStoreMap.StateTypeToStoreName(nameof(Entity1), typeof(Entity1)); StateTypeStateStoreMap.StateTypeToStoreName(nameof(Entity2), typeof(Entity2)); var dispatcherProtocols = World.Stage.ActorFor( new[] { DispatcherInterfaceType, typeof(IProjectionDispatcher) }, ProjectionDispatcherType); var dispatchers = Protocols.Two <IDispatcher, IProjectionDispatcher>(dispatcherProtocols); Dispatcher = dispatchers._1; ProjectionDispatcher = dispatchers._2; var storeProtocols = World.ActorFor( new[] { StateStoreInterfaceType, typeof(IDispatcherControl) }, typeof(InMemoryStateStoreActor <TextState>), Dispatcher); var storeWithControl = Protocols.Two <IStateStore, IDispatcherControl>(storeProtocols); Store = storeWithControl._1; DispatcherControl = storeWithControl._2; }
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)); }
/// <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 InMemoryObjectStoreDelegate(StateAdapterProvider stateAdapterProvider) { _stateAdapterProvider = stateAdapterProvider; _stores = new Dictionary <Type, Dictionary <long, TState> >(); _entries = new List <TEntry>(); _dispatchables = new List <Dispatchable <TEntry, TState> >(); _identityGenerator = IdentityGeneratorType.Random.Generator(); _nextId = 1; }
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 StatefulEntityTest(ITestOutputHelper output) { var converter = new Converter(output); Console.SetOut(converter); _world = World.StartWithDefaults("stateful-entity"); _dispatcher = new MockTextDispatcher(); _stateAdapterProvider = new StateAdapterProvider(_world); _stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter()); new EntryAdapterProvider(_world); var registry = new StatefulTypeRegistry(_world); var store = _world.ActorFor <IStateStore>(() => new InMemoryStateStoreActor <TextState>(new List <IDispatcher> { _dispatcher })); registry.Register(new Info(store, typeof(Entity1State), nameof(Entity1State))); }
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 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))); }
/// <summary> /// Answer myself after registering the <paramref name="adapter"/>. /// </summary> /// <param name="adapter"><see cref="IStateAdapter{TSource,TEntry}"/> to register</param> /// <param name="consumer">The consumer being registered</param> /// <typeparam name="TSource">The <see cref="Source{T}"/> extender being registered</typeparam> /// <typeparam name="TState">The <see cref="State{T}"/> extender being registered</typeparam> /// <returns><see cref="Info"/></returns> public Info RegisterStateAdapter <TSource, TState>(IStateAdapter <Source <TSource>, State <TState> > adapter, Action <Type, IStateAdapter <Source <TSource>, State <TState> > > consumer) { StateAdapterProvider.RegisterAdapter(adapter, consumer); return(this); }
/// <summary> /// Answer myself after registering the <paramref name="adapter"/>. /// </summary> /// <param name="adapter"><see cref="IStateAdapter{TSource,TEntry}"/> to register</param> /// <typeparam name="TSource">The <see cref="Source{T}"/> extender being registered</typeparam> /// <typeparam name="TState">The <see cref="State{T}"/> extender being registered</typeparam> /// <returns><see cref="Info"/></returns> public Info RegisterStateAdapter <TSource, TState>(IStateAdapter <Source <TSource>, State <TState> > adapter) { StateAdapterProvider.RegisterAdapter(adapter); 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 StatefulTypeRegistry(World world) { world.RegisterDynamic(InternalName, this); StateAdapterProvider.Instance(world); }