Пример #1
0
 private void ReadFor <TState>(string id, IReadResultInterest interest, object? @object)
 {
     if (interest != null)
     {
         if (id == null)
         {
             interest.ReadResultedIn <TState>(Failure.Of <StorageException, Result>(new StorageException(Result.Error, "The id is null.")), null, default !, -1, null, @object);
Пример #2
0
 /// <summary>
 /// Construct my default state.
 /// </summary>
 /// <param name="id">The unique identity of this entity</param>
 protected StatefulEntity(string?id)
 {
     Id = id ?? Address.IdString;
     _currentVersion = 0;
     _info           = Info();
     _readInterest   = SelfAs <IReadResultInterest>();
     _writeInterest  = SelfAs <IWriteResultInterest>();
 }
        /// <summary>
        /// Construct my final state with the <see cref="IStateStore"/>, which must
        /// be provided by my concrete extenders, as well as with a
        /// <see cref="IStateAdapter"/> and a <see cref="IEntryAdapter{TSource,TEntry}"/>.
        /// </summary>
        /// <param name="stateStore">The <see cref="IStateStore"/> from which previous state is read and merged current state is written</param>
        /// <param name="stateAdapter">The <see cref="IStateAdapter"/> used by my extenders to adapt persistent state</param>
        /// <param name="entryAdapter">The <see cref="IEntryAdapter{TSource,TEntry}"/> used by my extenders to adapt persistent entries</param>
        public StateStoreProjectionActor(IStateStore stateStore, IStateAdapter stateAdapter, IEntryAdapter entryAdapter)
        {
            _stateStore    = stateStore;
            _stateAdapter  = stateAdapter;
            _entryAdapter  = entryAdapter;
            _readInterest  = SelfAs <IReadResultInterest>();
            _writeInterest = SelfAs <IWriteResultInterest>();

            _adaptedSources = new List <ISource>();
        }
Пример #4
0
        public void ReadAll <TState>(IEnumerable <TypedStateBundle> bundles, IReadResultInterest interest, object? @object)
        {
            _readAllResultCollector.Prepare();

            var typedStateBundles = bundles.ToList();

            foreach (var bundle in typedStateBundles)
            {
                ReadFor <TState>(bundle.Id !, _readAllResultCollector, null);
            }

            var outcome = _readAllResultCollector.ReadResultOutcome(typedStateBundles.Count);

            interest.ReadResultedIn <TState>(outcome !, _readAllResultCollector.ReadBundles, @object);
        }
Пример #5
0
 public void ReadAll <TState>(IEnumerable <TypedStateBundle> bundles, IReadResultInterest interest, object? @object)
 {
     if (!_actor.IsStopped)
     {
         Action <IStateStore> cons128873 = __ => __.ReadAll <TState>(bundles, interest, @object);
         if (_mailbox.IsPreallocated)
         {
             _mailbox.Send(_actor, cons128873, null, ReadRepresentation3A);
         }
         else
         {
             _mailbox.Send(
                 new LocalMessage <IStateStore>(_actor, cons128873, ReadRepresentation3A));
         }
     }
     else
     {
         _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, ReadRepresentation3A));
     }
 }
Пример #6
0
 public void Read <TState>(string id, IReadResultInterest interest)
 {
     if (!_actor.IsStopped)
     {
         Action <IStateStore> cons128873 = __ => __.Read <TState>(id, interest);
         if (_mailbox.IsPreallocated)
         {
             _mailbox.Send(_actor, cons128873, null, ReadRepresentation2);
         }
         else
         {
             _mailbox.Send(
                 new LocalMessage <IStateStore>(_actor, cons128873,
                                                ReadRepresentation2));
         }
     }
     else
     {
         _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, ReadRepresentation2));
     }
 }
 public void ReadAll <TState1>(IEnumerable <TypedStateBundle> bundles, IReadResultInterest interest,
                               object @object)
 => _results.PutIncrementReadAll();
 public void Read <TState1>(string id, IReadResultInterest interest, object @object)
 => _results.PutIncrementRead(id, _totalPartitions);
Пример #9
0
 public void Read <TState>(string id, IReadResultInterest interest, object? @object) => ReadFor <TState>(id, interest, @object);
Пример #10
0
 public void Read <TState>(string id, IReadResultInterest interest) => Read <TState>(id, interest, null);
 public void ReadAll <TState>(IEnumerable <TypedStateBundle> bundles, IReadResultInterest interest, object? @object)
 => LeastBusyReader()?.ReadAll <TState>(bundles, interest, @object);