예제 #1
0
 /// <summary>
 /// Construct my default state.
 /// </summary>
 /// <param name="streamName">the string unique identity of this entity</param>
 protected Sourced(string?streamName)
 {
     StreamName      = streamName != null ? streamName : Address.IdString;
     _currentVersion = 0;
     _journalInfo    = Info();
     _interest       = SelfAs <IAppendResultInterest>();
 }
예제 #2
0
        public FeedTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world = World.StartWithDefaults("feed-test");

            _dispatcher = new MockJournalDispatcher();

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

            _entryReader = _journal.JournalReader("feed-test-reader").Await <IJournalReader>();

            _consumer = new MockFeedConsumer();

            _interest = NoOpInterest();
        }
예제 #3
0
 public void AppendWith <TSource, TSnapshotState>(string streamName, int streamVersion, TSource source,
                                                  TSnapshotState snapshot, IAppendResultInterest interest, object @object) where TSource : ISource
 {
     if (!actor.IsStopped)
     {
         Action <IJournal <T> > cons1922720892 = __ =>
                                                 __.AppendWith(streamName, streamVersion, source, snapshot, interest, @object);
         if (mailbox.IsPreallocated)
         {
             mailbox.Send(actor, cons1922720892, null, AppendWithRepresentation5);
         }
         else
         {
             mailbox.Send(new LocalMessage <IJournal <T> >(actor, cons1922720892, AppendWithRepresentation5));
         }
     }
     else
     {
         actor.DeadLetters?.FailedDelivery(new DeadLetter(actor, AppendWithRepresentation5));
     }
 }
예제 #4
0
 public void AppendAll <TSource>(string streamName, int fromStreamVersion,
                                 IEnumerable <ISource> sources, IAppendResultInterest interest, object @object) where TSource : ISource
 {
     if (!actor.IsStopped)
     {
         Action <IJournal <T> > cons1438749561 = __ =>
                                                 __.AppendAll <TSource>(streamName, fromStreamVersion, sources, interest, @object);
         if (mailbox.IsPreallocated)
         {
             mailbox.Send(actor, cons1438749561, null, AppendAllRepresentation7);
         }
         else
         {
             mailbox.Send(new LocalMessage <IJournal <T> >(actor, cons1438749561, AppendAllRepresentation7));
         }
     }
     else
     {
         actor.DeadLetters?.FailedDelivery(new DeadLetter(actor, AppendAllRepresentation7));
     }
 }
예제 #5
0
 public void Append <TSource>(string streamName, int streamVersion, TSource source,
                              Metadata metadata, IAppendResultInterest interest, object @object) where TSource : ISource
 {
     if (!actor.IsStopped)
     {
         Action <IJournal <T> > cons397294566 = __ =>
                                                __.Append(streamName, streamVersion, source, metadata, interest, @object);
         if (mailbox.IsPreallocated)
         {
             mailbox.Send(actor, cons397294566, null, AppendRepresentation4);
         }
         else
         {
             mailbox.Send(new LocalMessage <IJournal <T> >(actor, cons397294566, AppendRepresentation4));
         }
     }
     else
     {
         actor.DeadLetters?.FailedDelivery(new DeadLetter(actor, AppendRepresentation4));
     }
 }
예제 #6
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());
        }
예제 #7
0
 public void AppendAllWith <TSource, TSnapshotState>(string streamName, int fromStreamVersion, IEnumerable <TSource> sources, TSnapshotState snapshot, IAppendResultInterest interest, object @object) where TSource : Source
 {
     throw new NotImplementedException();
 }
예제 #8
0
        public override void AppendAll <TSource>(string streamName, int fromStreamVersion, IEnumerable <ISource> sources, Metadata metadata, IAppendResultInterest interest, object @object)
        {
            var sourcesForEntries   = sources.ToList();
            var entries             = _entryAdapterProvider.AsEntries <TSource, IEntry <T> >(sourcesForEntries, fromStreamVersion, metadata);
            var dispatchableEntries = entries.ToList();

            Insert(streamName, fromStreamVersion, dispatchableEntries);

            Dispatch(streamName, fromStreamVersion, dispatchableEntries, null);
            interest.AppendAllResultedIn(Success.Of <StorageException, Result>(Result.Success), streamName, fromStreamVersion, sourcesForEntries, Optional.Empty <object>(), @object);
        }
예제 #9
0
        public override void AppendWith <TSource, TSnapshotState>(string streamName, int streamVersion, TSource source, Metadata metadata, TSnapshotState snapshot, IAppendResultInterest interest, object @object)
        {
            var entry = _entryAdapterProvider.AsEntry <TSource, IEntry>(source, streamVersion, metadata);

            Insert(streamName, streamVersion, entry);
            IState?raw;
            Optional <TSnapshotState> snapshotResult;

            if (snapshot != null)
            {
                raw = _stateAdapterProvider.AsRaw <TSnapshotState, IState>(streamName, snapshot, streamVersion);
                _snapshots.Add(streamName, raw);
                snapshotResult = Optional.Of(snapshot);
            }
            else
            {
                raw            = null;
                snapshotResult = Optional.Empty <TSnapshotState>();
            }

            Dispatch(streamName, streamVersion, new List <IEntry> {
                entry
            }, raw);
            interest.AppendResultedIn(Success.Of <StorageException, Result>(Result.Success), streamName, streamVersion, source, snapshotResult, @object);
        }
예제 #10
0
        public override void Append <TSource>(string streamName, int streamVersion, TSource source, Metadata metadata, IAppendResultInterest interest, object @object)
        {
            var entry = _entryAdapterProvider.AsEntry <TSource, IEntry>(source, streamVersion, metadata);

            Insert(streamName, streamVersion, entry);
            Dispatch(streamName, streamVersion, new List <IEntry> {
                entry
            }, null);
            interest.AppendResultedIn(Success.Of <StorageException, Result>(Result.Success), streamName, streamVersion, source, Optional.Empty <object>(), @object);
        }
예제 #11
0
        public override void AppendAllWith <TSource, TSnapshotState>(string streamName, int fromStreamVersion, IEnumerable <ISource> sources,
                                                                     Metadata metadata, TSnapshotState snapshot, IAppendResultInterest interest, object @object)
        {
            var sourcesForEntries   = sources.ToList();
            var entries             = _entryAdapterProvider.AsEntries <TSource, IEntry <T> >(sourcesForEntries, fromStreamVersion, metadata);
            var dispatchableEntries = entries.ToList();

            Insert(streamName, fromStreamVersion, dispatchableEntries);
            IState?raw;
            Optional <TSnapshotState> snapshotResult;

            if (snapshot != null)
            {
                raw = _stateAdapterProvider.AsRaw <TSnapshotState, IState>(streamName, snapshot, fromStreamVersion);
                _snapshots.Add(streamName, raw);
                snapshotResult = Optional.Of(snapshot);
            }
            else
            {
                raw            = null;
                snapshotResult = Optional.Empty <TSnapshotState>();
            }

            Dispatch(streamName, fromStreamVersion, dispatchableEntries, raw);
            interest.AppendAllResultedIn(Success.Of <StorageException, Result>(Result.Success), streamName, fromStreamVersion, sourcesForEntries, snapshotResult, @object);
        }
예제 #12
0
 public virtual void Append <TSource>(string streamName, int streamVersion, TSource source, IAppendResultInterest interest, object @object) where TSource : ISource
 => Append(streamName, streamVersion, source, Metadata.NullMetadata(), interest, @object);
 public void AppendAll <TSource>(string streamName, int fromStreamVersion, IEnumerable <ISource> sources, Metadata metadata, IAppendResultInterest interest, object @object) where TSource : ISource
 {
     throw new NotImplementedException();
 }
예제 #14
0
 public abstract void AppendAllWith <TSource, TSnapshotState>(string streamName, int fromStreamVersion, IEnumerable <ISource> sources, Metadata metadata, TSnapshotState snapshot, IAppendResultInterest interest, object @object) where TSource : ISource;
예제 #15
0
 public virtual void AppendAllWith <TSource, TSnapshotState>(string streamName, int fromStreamVersion, IEnumerable <ISource> sources, TSnapshotState snapshot, IAppendResultInterest interest, object @object) where TSource : ISource
 => AppendAllWith <TSource, TSnapshotState>(streamName, fromStreamVersion, sources, Metadata.NullMetadata(), snapshot, interest, @object);
예제 #16
0
 public abstract void AppendWith <TSource, TSnapshotState>(string streamName, int streamVersion, TSource source, Metadata metadata, TSnapshotState snapshot, IAppendResultInterest interest, object @object) where TSource : ISource;
예제 #17
0
 public virtual void AppendWith <TSource, TSnapshotState>(string streamName, int streamVersion, TSource source, TSnapshotState snapshot, IAppendResultInterest interest, object @object) where TSource : ISource
 => AppendWith(streamName, streamVersion, source, Metadata.NullMetadata(), snapshot, interest, @object);
예제 #18
0
 public abstract void Append <TSource>(string streamName, int streamVersion, TSource source, Metadata metadata, IAppendResultInterest interest, object @object) where TSource : ISource;
예제 #19
0
 public void AppendWith <TSource, TSnapshotState>(string streamName, int streamVersion, TSource source, Metadata metadata, TSnapshotState snapshot, IAppendResultInterest interest, object @object) where TSource : Source
 {
     throw new NotImplementedException();
 }
 public void Append <TSource>(string streamName, int streamVersion, TSource source, Metadata metadata, IAppendResultInterest interest, object @object) where TSource : ISource
 {
     throw new NotImplementedException();
 }
예제 #21
0
 public void AppendAllWith <TSource, TSnapshotState>(string streamName, int fromStreamVersion,
                                                     IEnumerable <ISource> sources, Metadata metadata, TSnapshotState snapshot, IAppendResultInterest interest,
                                                     object @object) where TSource : ISource
 {
     if (!actor.IsStopped)
     {
         Action <IJournal <T> > cons2042766341 = __ =>
                                                 __.AppendAllWith <TSource, TSnapshotState>(streamName, fromStreamVersion, sources, metadata, snapshot, interest, @object);
         if (mailbox.IsPreallocated)
         {
             mailbox.Send(actor, cons2042766341, null, AppendAllWithRepresentation10);
         }
         else
         {
             mailbox.Send(new LocalMessage <IJournal <T> >(actor, cons2042766341, AppendAllWithRepresentation10));
         }
     }
     else
     {
         actor.DeadLetters?.FailedDelivery(new DeadLetter(actor, AppendAllWithRepresentation10));
     }
 }