Exemplo n.º 1
0
        protected void OnEventInternal(DurableEvent e, Func <bool> handler = null)
        {
            var initialClock = clock;
            var initialEvent = lastEventHandled;

            lastEventHandled = e;
            if (HasSharedClockEntry)
            {
                clock = clock.Set(e.LocalLogId, e.LocalSequenceNr);
                if (e.EmitterId != Id)
                {
                    clock = clock.Merge(e.VectorTimestamp);
                }
            }
            else
            {
                if (e.EmitterId != Id)
                {
                    clock = clock.Update(e.VectorTimestamp);
                }
                else if (isRecovering)
                {
                    clock = clock.Merge(e.VectorTimestamp);
                }
            }

            if (handler != null && !handler())
            {
                clock            = initialClock;
                lastEventHandled = initialEvent;
            }
        }
Exemplo n.º 2
0
        private void ReceiveEvent(DurableEvent e)
        {
            OnEventInternal(e, () => OnEvent(e.Payload));

            if (!IsRecovering)
            {
                ConditionChanged(e.VectorTimestamp);
            }
        }
Exemplo n.º 3
0
        public bool Apply(DurableEvent e)
        {
            foreach (var filter in Filters)
            {
                if (filter.Apply(e))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 4
0
        public Snapshot(object payload, string emitterId, DurableEvent lastEvent, VectorTime currentTime, long sequenceNr,
                        ImmutableArray <DeliveryAttempt> deliveryAttempts             = default(ImmutableArray <DeliveryAttempt>),
                        ImmutableArray <PersistOnEventRequest> persistOnEventRequests = default(ImmutableArray <PersistOnEventRequest>))
        {
            Payload                = payload;
            EmitterId              = emitterId;
            LastEvent              = lastEvent;
            CurrentTime            = currentTime;
            SequenceNr             = sequenceNr;
            DeliveryAttempts       = deliveryAttempts;
            PersistOnEventRequests = persistOnEventRequests;

            Metadata = new SnapshotMetadata(EmitterId, LastEvent.LocalSequenceNr);
        }
Exemplo n.º 5
0
 private void Zeroize()
 {
     lastEventHandled = new DurableEvent(null, Id);
     clock            = new VectorClock(Id, VectorTime.Zero);
 }
Exemplo n.º 6
0
 protected void LoadedSnapshot(Snapshot snapshot)
 {
     lastEventHandled = snapshot.LastEvent;
     clock            = new VectorClock(clock.ProcessId, snapshot.CurrentTime);
 }
Exemplo n.º 7
0
 protected void OnEventInternal(DurableEvent e, Exception cause)
 {
     lastEventHandled = e;
 }
Exemplo n.º 8
0
 public bool Apply(DurableEvent e)
 {
     return(true);
 }
Exemplo n.º 9
0
 protected override void ReceiveEvent(DurableEvent e)
 {
     base.ReceiveEvent(e);
 }