Пример #1
0
        void IAsyncLogProviderCommandHandler.ContinueAsynchronously(CommandContext ctx)
        {
            result = new DateBoundPositionResponseData();

            result.Position = PositionedMessagesUtils.LocateDateBound(ctx.Reader, date, bound, ctx.Cancellation);
            ctx.Tracer.Info("Position to return: {0}", result.Position);

            if (result.Position == ctx.Reader.EndPosition)
            {
                result.IsEndPosition = true;
                ctx.Tracer.Info("It is END position");
            }
            else if (result.Position == ctx.Reader.BeginPosition - 1)
            {
                result.IsBeforeBeginPosition = true;
                ctx.Tracer.Info("It is BEGIN-1 position");
            }
            else
            {
                ctx.Cancellation.ThrowIfCancellationRequested();
                if (userNeedsDate)
                {
                    result.Date = PositionedMessagesUtils.ReadNearestMessageTimestamp(ctx.Reader, result.Position);
                    ctx.Tracer.Info("Date to return: {0}", result.Date);
                }
            }
            dateBoundsCache.Set(date, result);
        }
Пример #2
0
        async Task IAsyncLogProviderCommandHandler.ContinueAsynchronously(CommandContext ctx)
        {
            result = new DateBoundPositionResponseData();

            result.Position = await PositionedMessagesUtils.LocateDateBound(ctx.Reader, date, bound, ctx.Cancellation);

            ctx.Tracer.Info("Position to return: {0}", result.Position);

            if (result.Position == ctx.Reader.EndPosition)
            {
                result.IsEndPosition = true;
                ctx.Tracer.Info("It is END position");
            }
            else if (result.Position == ctx.Reader.BeginPosition - 1)
            {
                result.IsBeforeBeginPosition = true;
                ctx.Tracer.Info("It is BEGIN-1 position");
            }
            else
            {
                ctx.Cancellation.ThrowIfCancellationRequested();
                if (messageRequested)
                {
                    result.Message = await PositionedMessagesUtils.ReadNearestMessage(ctx.Reader, result.Position, MessagesParserFlag.HintMessageContentIsNotNeeed);

                    ctx.Tracer.Info("Details to return: {0} at {1}", result.Message?.Time, result.Message?.Position);
                }
            }
            dateBoundsCache.Set(date, result);
        }