ValidateOrderAndEmitEvents() public method

public ValidateOrderAndEmitEvents ( EventStore.Projections.Core.Services.Processing.EmittedEventEnvelope events ) : void
events EventStore.Projections.Core.Services.Processing.EmittedEventEnvelope
return void
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _checkpoint = new ProjectionCheckpoint(
         _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), 250);
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
         {
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream2", Guid.NewGuid(), "type", true, "data2", null, CheckpointTag.FromPosition(0, 120, 110), null)),
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream3", Guid.NewGuid(), "type", true, "data3", null, CheckpointTag.FromPosition(0, 120, 110), null)),
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream2", Guid.NewGuid(), "type", true, "data4", null, CheckpointTag.FromPosition(0, 120, 110), null)),
         });
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
         {
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream1", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 140, 130), null))
         });
 }
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();;
     _checkpoint = new ProjectionCheckpoint(
         _readDispatcher, _writeDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(100, 50), new TransactionFilePositionTagger(),
         CheckpointTag.FromPosition(0, -1), 250);
     _checkpoint.Start();
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
             {
                 new EmittedDataEvent(
             "stream2", Guid.NewGuid(), "type", "data2", null, CheckpointTag.FromPosition(120, 110), null),
                 new EmittedDataEvent(
             "stream2", Guid.NewGuid(), "type", "data4", null, CheckpointTag.FromPosition(120, 110), null),
             });
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
             {
                 new EmittedDataEvent(
             "stream1", Guid.NewGuid(), "type", "data", null, CheckpointTag.FromPosition(140, 130), null)
             });
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
             {
                 new EmittedDataEvent(
             "stream1", Guid.NewGuid(), "type", "data", null, CheckpointTag.FromPosition(160, 150), null)
             });
 }
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _checkpoint = new ProjectionCheckpoint(
         _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0),
         CheckpointTag.FromPosition(0, 0, -1), 250);
     _checkpoint.Start();
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
         {
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream2", Guid.NewGuid(), "type", true, "data2", null, CheckpointTag.FromPosition(0, 120, 110), null)),
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream2", Guid.NewGuid(), "type", true, "data4", null, CheckpointTag.FromPosition(0, 120, 110), null)),
         });
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
         {
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream1", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 140, 130), null))
         });
     var writes = _consumer.HandledMessages.OfType<ClientMessage.WriteEvents>().ToArray();
     writes[0].Envelope.ReplyWith(new ClientMessage.WriteEventsCompleted(writes[0].CorrelationId, 0, 0));
     writes[1].Envelope.ReplyWith(new ClientMessage.WriteEventsCompleted(writes[1].CorrelationId, 0, 0));
     _checkpoint.Prepare(CheckpointTag.FromPosition(0, 200, 150));
     //TODO: test whether checkpoint does not allow positions before last emitted event caused by position
 }
Ejemplo n.º 4
0
        public void EventsEmitted(EmittedEventEnvelope[] scheduledWrites, Guid causedBy, string correlationId)
        {
            if (_stopped)
            {
                return;
            }
            EnsureStarted();
            if (_stopping)
            {
                throw new InvalidOperationException("Stopping");
            }
            if (scheduledWrites != null)
            {
                foreach (var @event in scheduledWrites)
                {
                    var emittedEvent = @event.Event;
                    if (string.IsNullOrEmpty(@event.Event.StreamId))
                    {
                        Failed("Cannot write to a null stream id");
                        return;
                    }

                    emittedEvent.SetCausedBy(causedBy);
                    emittedEvent.SetCorrelationId(correlationId);
                }

                _currentCheckpoint.ValidateOrderAndEmitEvents(scheduledWrites);
            }
        }
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();;
     _checkpoint = new ProjectionCheckpoint(_bus, _readyHandler, CheckpointTag.FromPosition(100, 50), CheckpointTag.FromPosition(0, -1), 250);
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
             {
                 new EmittedEvent("stream2", Guid.NewGuid(), "type", "data2", CheckpointTag.FromPosition(120, 110), null),
                 new EmittedEvent("stream3", Guid.NewGuid(), "type", "data3", CheckpointTag.FromPosition(120, 110), null),
                 new EmittedEvent("stream2", Guid.NewGuid(), "type", "data4", CheckpointTag.FromPosition(120, 110), null),
             }
         );
     _checkpoint.ValidateOrderAndEmitEvents(
         new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data",
         CheckpointTag.FromPosition(140, 130), null)});
 }
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();;
     _checkpoint = new ProjectionCheckpoint(_bus, _readyHandler, CheckpointTag.FromPosition(100, 50), CheckpointTag.FromPosition(0, -1), 250);
     try
     {
         _checkpoint.ValidateOrderAndEmitEvents(
             new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data",
             CheckpointTag.FromPosition(40, 30), null)});
     }
     catch (Exception ex)
     {
         _lastException = ex;
     }
 }
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _checkpoint = new ProjectionCheckpoint(
         _readDispatcher, _writeDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(100, 50), new TransactionFilePositionTagger(),
         CheckpointTag.FromPosition(0, -1), 250);
     try
     {
         _checkpoint.ValidateOrderAndEmitEvents(
             new[]
                 {
                     new EmittedDataEvent(
                 "stream1", Guid.NewGuid(), "type", "data", null, CheckpointTag.FromPosition(40, 30), null)
                 });
     }
     catch (Exception ex)
     {
         _lastException = ex;
     }
 }
 public void EventsEmitted(EmittedEvent[] scheduledWrites, Guid causedBy, string correlationId)
 {
     if (_stopped)
     {
         return;
     }
     EnsureStarted();
     if (_stopping)
     {
         throw new InvalidOperationException("Stopping");
     }
     if (scheduledWrites != null)
     {
         foreach (EmittedEvent @event in scheduledWrites)
         {
             @event.SetCausedBy(causedBy);
             @event.SetCorrelationId(correlationId);
         }
         _currentCheckpoint.ValidateOrderAndEmitEvents(scheduledWrites);
     }
 }