public override async Task <StateResp> State(StateReq request, ServerCallContext context)
        {
            var resetSource = new TaskCompletionSource <Value>();

            var options = request.Options;

            var name      = options.Name;
            var partition = options.Partition ?? string.Empty;

            var envelope = new CallbackEnvelope(OnMessage);

            _queue.Publish(new ProjectionManagementMessage.Command.GetState(envelope, name, partition));

            return(new StateResp {
                State = await resetSource.Task.ConfigureAwait(false)
            });

            void OnMessage(Message message)
            {
                if (!(message is ProjectionManagementMessage.ProjectionState result))
                {
                    resetSource.TrySetException(UnknownMessage <ProjectionManagementMessage.ProjectionState>(message));
                    return;
                }

                var document = JsonDocument.Parse(result.State);

                resetSource.TrySetResult(GetProtoValue(document.RootElement));
            }
        }
        public override async Task <StateResp> State(StateReq request, ServerCallContext context)
        {
            var user = context.GetHttpContext().User;

            if (!await _authorizationProvider.CheckAccessAsync(user, StateOperation, context.CancellationToken)
                .ConfigureAwait(false))
            {
                throw AccessDenied();
            }
            var resultSource = new TaskCompletionSource <Value>();

            var options = request.Options;

            var name      = options.Name;
            var partition = options.Partition ?? string.Empty;

            var envelope = new CallbackEnvelope(OnMessage);

            _queue.Publish(new ProjectionManagementMessage.Command.GetState(envelope, name, partition));

            return(new StateResp {
                State = await resultSource.Task.ConfigureAwait(false)
            });

            void OnMessage(Message message)
            {
                if (!(message is ProjectionManagementMessage.ProjectionState result))
                {
                    resultSource.TrySetException(UnknownMessage <ProjectionManagementMessage.ProjectionState>(message));
                    return;
                }

                if (string.IsNullOrEmpty(result.State))
                {
                    resultSource.TrySetResult(new Value {
                        StructValue = new Struct()
                    });
                    return;
                }
                var document = JsonDocument.Parse(result.State);

                resultSource.TrySetResult(GetProtoValue(document.RootElement));
            }
        }