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));
        }
示例#3
0
        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 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 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));
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }