public ClientMessage.ReadStreamEventsBackwardCompleted ReadOrderStream( ClientMessage.ReadStreamEventsBackward message) { ResolvedEvent[] events; if (!_hasRead) { var checkpoint = CheckpointTag.FromStreamPositions(0, new Dictionary <string, long> { { "a", 5 }, { "b", 5 }, { "c", 5 } }); events = IODispatcherTestHelpers.CreateResolvedEvent <TLogFormat, TStreamId>(message.EventStreamId, "$>", "10@a", checkpoint.ToJsonString(new ProjectionVersion(3, 0, 1))); _hasRead = true; } else { events = new ResolvedEvent[0] { }; } return(new ClientMessage.ReadStreamEventsBackwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, events, null, true, "", message.FromEventNumber - events.Length, message.FromEventNumber, true, 10000)); }
public ClientMessage.ReadStreamEventsBackwardCompleted ReadTestStream(ClientMessage.ReadStreamEventsBackward message) { var events = IODispatcherTestHelpers.CreateResolvedEvent(message.EventStreamId, "testevent", "{ \"data\":1 }"); return(new ClientMessage.ReadStreamEventsBackwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, events, null, true, "", message.FromEventNumber - 1, message.FromEventNumber, true, 10000)); }
public void TestFixtureSetUp() { _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus), true); _projectionVersion = new ProjectionVersion(3, 1, 2); _projectionConfig = new ProjectionConfig(SystemAccounts.System, 10, 1000, 1000, 10, true, true, true, false, false, 5000, 10); _positionTagger = new MultiStreamPositionTagger(3, _streams); _positionTagger.AdjustTag(CheckpointTag.FromStreamPositions(3, new Dictionary <string, long> { { "a", 0 }, { "b", 0 }, { "c", 0 } })); _namingBuilder = ProjectionNamesBuilder.CreateForTest("projection"); IODispatcherTestHelpers.SubscribeIODispatcher(_ioDispatcher, _bus); _bus.Subscribe <ClientMessage.ReadStreamEventsBackward>(this); _coreProjectionCheckpointWriter = new CoreProjectionCheckpointWriter( _namingBuilder.MakeCheckpointStreamName(), _ioDispatcher, _projectionVersion, _projectionName); _checkpointManager = new MultiStreamMultiOutputCheckpointManager(_bus, _projectionId, _projectionVersion, SystemAccounts.System, _ioDispatcher, _projectionConfig, _projectionName, _positionTagger, _namingBuilder, true, true, false, _coreProjectionCheckpointWriter); When(); }
public virtual void Handle(ClientMessage.ReadStreamEventsBackward message) { var events = IODispatcherTestHelpers.CreateResolvedEvent(message.EventStreamId, ProjectionEventTypes.ProjectionCheckpoint, "0"); var reply = new ClientMessage.ReadStreamEventsBackwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, events, null, false, String.Empty, 0, message.FromEventNumber, true, 1000); message.Envelope.ReplyWith(reply); }
public virtual void TestFixtureSetUp() { _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus)); IODispatcherTestHelpers.SubscribeIODispatcher(_ioDispatcher, _bus); _bus.Subscribe <ClientMessage.ReadStreamEventsForward>(this); _bus.Subscribe <ClientMessage.ReadStreamEventsBackward>(this); _bus.Subscribe <TimerMessage.Schedule>(this); }
public void TestFixtureSetUp() { _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus)); IODispatcherTestHelpers.SubscribeIODispatcher(_ioDispatcher, _bus); _bus.Subscribe <ClientMessage.ReadStreamEventsBackward>(this); _projectionVersion = new ProjectionVersion(1, 2, 3); _reader = new CoreProjectionCheckpointReader(_bus, _projectionId, _ioDispatcher, _projectionCheckpointStreamId, _projectionVersion, true); When(); }
public ClientMessage.ReadStreamEventsBackwardCompleted CreateReadStreamEventsBackwardCompleted(ClientMessage.ReadStreamEventsBackward msg) { var startEventNumber = msg.FromEventNumber; var nextEventNumber = startEventNumber - 1; var events = IODispatcherTestHelpers.CreateResolvedEvent(msg.EventStreamId, "event_type", "test", eventNumber: 10); var res = new ClientMessage.ReadStreamEventsBackwardCompleted(msg.CorrelationId, msg.EventStreamId, msg.FromEventNumber, msg.MaxCount, ReadStreamResult.Success, events, null, false, String.Empty, nextEventNumber, startEventNumber, false, 0); return(res); }
public virtual void TestFixtureSetUp() { var _queue = QueuedHandler.CreateQueuedHandler(_bus, "TestQueuedHandler", new QueueStatsManager()); _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_queue)); IODispatcherTestHelpers.SubscribeIODispatcher(_ioDispatcher, _bus); _bus.Subscribe <ClientMessage.ReadStreamEventsForward>(this); _bus.Subscribe <ClientMessage.ReadStreamEventsBackward>(this); _bus.Subscribe <TimerMessage.Schedule>(this); _queue.Start(); }
protected virtual void TestFixtureSetUp() { _streamId = "$projection-$" + _masterProjectionId.ToString("N"); _bus = InMemoryBus.CreateTest(); _bus.Subscribe <ClientMessage.WriteEvents>(this); _bus.Subscribe <ClientMessage.ReadStreamEventsForward>(this); _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus)); IODispatcherTestHelpers.SubscribeIODispatcher(_ioDispatcher, _bus); _reader = new MasterCoreProjectionResponseReader(_bus, _ioDispatcher, _workerId, _masterProjectionId); }
public virtual void Handle(ClientMessage.ReadStreamEventsBackward message) { var evnts = IODispatcherTestHelpers.CreateResolvedEvent(message.EventStreamId, ProjectionEventTypes.ProjectionCheckpoint, "[]", @"{ ""$v"": ""1:-1:3:3"", ""$c"": 269728, ""$p"": 269728 }"); var reply = new ClientMessage.ReadStreamEventsBackwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, evnts, null, true, "", 0, 0, true, 10000); message.Envelope.ReplyWith(reply); }
public ClientMessage.ReadStreamEventsForwardCompleted CreateResultCommandReadResponse(ClientMessage.ReadStreamEventsForward message) { var result = new PartitionProcessingResultResponse { SubscriptionId = Guid.NewGuid().ToString("N"), Partition = "teststream", CausedBy = Guid.NewGuid().ToString("N"), Position = CheckpointTag.Empty, Result = "result" }; var data = JsonConvert.SerializeObject(result); var evnts = IODispatcherTestHelpers.CreateResolvedEvent(_streamId, "$result", data); return(new ClientMessage.ReadStreamEventsForwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, evnts, null, false, String.Empty, message.FromEventNumber + 1, message.FromEventNumber, true, 10000)); }
protected virtual void SetUp() { _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus), true); _projectionNamesBuilder = ProjectionNamesBuilder.CreateForTest(_projectionName); _checkpointName = _projectionNamesBuilder.GetEmittedStreamsCheckpointName(); _deleter = new EmittedStreamsDeleter(_ioDispatcher, _projectionNamesBuilder.GetEmittedStreamsName(), _checkpointName); IODispatcherTestHelpers.SubscribeIODispatcher(_ioDispatcher, _bus); _bus.Subscribe <ClientMessage.ReadStreamEventsForward>(this); _bus.Subscribe <ClientMessage.ReadStreamEventsBackward>(this); _bus.Subscribe <ClientMessage.DeleteStream>(this); When(); }
public virtual void Handle(ClientMessage.ReadStreamEventsForward message) { ClientMessage.ReadStreamEventsForwardCompleted reply; if (!_hasReadForward) { _hasReadForward = true; var events = IODispatcherTestHelpers.CreateResolvedEvent(message.EventStreamId, ProjectionEventTypes.ProjectionCheckpoint, _testStreamName); reply = new ClientMessage.ReadStreamEventsForwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, events, null, false, String.Empty, message.FromEventNumber + 1, message.FromEventNumber, true, 1000); } else { reply = new ClientMessage.ReadStreamEventsForwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, new ResolvedEvent[] {}, null, false, String.Empty, message.FromEventNumber, message.FromEventNumber, true, 1000); } message.Envelope.ReplyWith(reply); }
public override void Handle(ClientMessage.ReadStreamEventsBackward message) { if (!_hasTimedOut) { _timeoutCorrelationId = message.CorrelationId; _hasTimedOut = true; return; } var evnts = IODispatcherTestHelpers.CreateResolvedEvent <TLogFormat, TStreamId>(message.EventStreamId, ProjectionEventTypes.ProjectionCheckpoint, "[]", @"{ ""$v"": ""1:-1:3:3"", ""$c"": 269728, ""$p"": 269728 }"); var reply = new ClientMessage.ReadStreamEventsBackwardCompleted(message.CorrelationId, message.EventStreamId, message.FromEventNumber, message.MaxCount, ReadStreamResult.Success, evnts, null, true, "", 0, 0, true, 10000); message.Envelope.ReplyWith(reply); }