Пример #1
0
        public override async Task <TResponse> UnaryServerHandler <TRequest, TResponse>(TRequest request,
                                                                                        ServerCallContext context, UnaryServerMethod <TRequest, TResponse> continuation)
        {
            if (context.Method == "/grpc.health.v1.Health/Check")
            {
                return(await continuation(request, context));
            }

            ValidateWhitelist(context).ValidateBlacklist(context);

            if (!provider.LimitMaxRequest(context))
            {
                throw new RpcException(new Status(StatusCode.Aborted, "has reached the maximum current limit"));
            }

            var result = await provider.BreakerRequestCircuitBreaker(context, async() => await continuation(request, context));

            return(result);
        }