Exemple #1
0
        public virtual void Process(PartitionEventFragment e, EffectTracker effects)
        {
            // processing a reassembled event just applies the original event
            dynamic dynamicThis           = this;
            dynamic dynamicPartitionEvent = e.ReassembledEvent;

            dynamicThis.Process(dynamicPartitionEvent, effects);
        }
        public override void Process(PartitionEventFragment evt, EffectTracker effects)
        {
            // stores fragments until the last one is received
            var originalEventString = evt.OriginalEventId.ToString();

            if (evt.IsLast)
            {
                evt.ReassembledEvent = FragmentationAndReassembly.Reassemble <PartitionEvent>(this.Fragments[originalEventString], evt);

                this.Partition.EventDetailTracer?.TraceEventProcessingDetail($"Reassembled {evt.ReassembledEvent}");

                this.Fragments.Remove(originalEventString);

                switch (evt.ReassembledEvent)
                {
                case PartitionUpdateEvent updateEvent:
                    updateEvent.DetermineEffects(effects);
                    break;

                case PartitionReadEvent readEvent:
                    this.Partition.SubmitInternalEvent(readEvent);
                    break;

                case PartitionQueryEvent queryEvent:
                    this.Partition.SubmitInternalEvent(queryEvent);
                    break;

                default:
                    throw new InvalidCastException("Could not cast to neither PartitionReadEvent nor PartitionUpdateEvent");
                }
            }
            else
            {
                if (!this.Fragments.TryGetValue(originalEventString, out var list))
                {
                    this.Fragments[originalEventString] = list = new List <PartitionEventFragment>();
                }
                list.Add(evt);
            }
        }