コード例 #1
0
 internal override void ReceiveEvent(DurableEvent e)
 {
     base.ReceiveEvent(e);
     if (!(e.DeliveryId is null) && e.EmitterId == this.Id)
     {
         Confirm(e.DeliveryId);
     }
 }
コード例 #2
0
 public override bool Invoke(DurableEvent durableEvent)
 {
     if (durableEvent.Payload is BinaryPayload payload)
     {
         return(Regex.IsMatch(payload.Manifest));
     }
     return(false);
 }
コード例 #3
0
 /// <summary>
 /// Evaluates to `true` if all `filters` evaluate to `true`, `false` otherwise.
 /// </summary>
 public override bool Invoke(DurableEvent durableEvent)
 {
     foreach (var filter in Filters)
     {
         if (!filter.Invoke(durableEvent))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #4
0
        internal override bool ReceiveEventInternal(DurableEvent e, Receive behavior)
        {
            var previousVersion = this.CurrentVersion;

            this.UpdateVersion(e);
            var handled = base.ReceiveEventInternal(e, behavior);

            if (!handled)
            {
                this.CurrentVersion = previousVersion;
            }
            return(handled);
        }
コード例 #5
0
        internal override void ReceiveEvent(DurableEvent e)
        {
            base.ReceiveEvent(e);
            if (e.EmitterId == Id && TryFindPersistOnEventRequest(e, out var request))
            {
                ConfirmRequest(request);
            }

            if (invocations.Count != 0)
            {
                DeliverRequest(new PersistOnEventRequest(LastSequenceNr, LastHandledEvent.Id, invocations.ToImmutableArray(), InstanceId));
                invocations.Clear();
            }
        }
コード例 #6
0
        private bool TryFindPersistOnEventRequest(DurableEvent e, out PersistOnEventRequest request)
        {
            if (e.PersistOnEventId.HasValue && this.requestsByEventId.TryGetValue(e.PersistOnEventId.Value, out request))
            {
                return(true);
            }

            if (e.PersistOnEventSequenceNr.HasValue && this.requestsBySequenceNr.TryGetValue(e.PersistOnEventSequenceNr.Value, out request))
            {
                return(true);
            }

            request = default;
            return(false);
        }
コード例 #7
0
 public Snapshot(
     object payload,
     string emitterId,
     DurableEvent lastEvent,
     VectorTime currentTime,
     long sequenceNr,
     ImmutableHashSet <DeliveryAttempt> deliveryAttempts             = null,
     ImmutableHashSet <PersistOnEventRequest> persistOnEventRequests = null)
 {
     Payload                = payload;
     EmitterId              = emitterId;
     LastEvent              = lastEvent;
     CurrentTime            = currentTime;
     SequenceNr             = sequenceNr;
     DeliveryAttempts       = deliveryAttempts ?? ImmutableHashSet <DeliveryAttempt> .Empty;
     PersistOnEventRequests = persistOnEventRequests ?? ImmutableHashSet <PersistOnEventRequest> .Empty;
 }
コード例 #8
0
 /// <summary>
 /// Updates the current version from the given <paramref name="event"/>.
 /// </summary>
 public static void UpdateVersion <T>(this T actor, DurableEvent @event) where T : EventsourcedView, IEventsourcedVersion
 {
     actor.CurrentVersion = actor.CurrentVersion.Merge(@event.VectorTimestamp);
 }
コード例 #9
0
 internal void PersistDurableEvent(DurableEvent durableEvent, Action <Try <object> > handler)
 {
     writeRequests.Add(durableEvent);
     writeHandlers.AddLast(handler);
 }
コード例 #10
0
 /// <summary>
 /// Override to allow post-processing of DurableEvent instances wrapping events generated by <see cref="ProcessEvent(object)"/>.
 ///
 /// Amongst other things, this can e.g. be used to set different or additional aggregate IDs for custom routing
 /// destinations (which by default take the same routing destinations as the original event that was processed).
 /// </summary>
 protected virtual DurableEvent PostProcessDurableEvent(DurableEvent e) => e;
コード例 #11
0
 /// <summary>
 /// Evaluates this filter on the given <paramref name="durableEvent"/>.
 /// </summary>
 public abstract bool Invoke(DurableEvent durableEvent);
コード例 #12
0
 public override bool Invoke(DurableEvent durableEvent) => true;