using Grpc.Core; using System; using System.Threading.Tasks; using Grpc.Extension.BaseService.Model; namespace Grpc.Extension.BaseService { /// /// 执行命令的服务 /// public class CmdService : IGrpcBaseService { /// /// 添加删除截流的method /// public Task AddDelThrottle(AddDelThrottleRQ rq, ServerCallContext context) { return Task.Run(() => { if (string.IsNullOrWhiteSpace(rq.MethodName)) { return CmdRS.Fail("MethodName is null"); } if(rq.IsDel) ThrottleManager.Instance.Del(rq.MethodName); else ThrottleManager.Instance.Add(rq.MethodName); return CmdRS.Success(); }); } /// /// 添加删除是否允许保存响应的method /// public Task AddDelSaveResponseEnable(AddDelSaveResponseEnableRQ rq, ServerCallContext context) { return Task.Run(() => { if (string.IsNullOrWhiteSpace(rq.MethodName)) { return CmdRS.Fail("MethodName is null"); } if (rq.IsDel) MonitorManager.Instance.DelSaveResponseMethod(rq.MethodName); else MonitorManager.Instance.AddSaveResponseMethod(rq.MethodName); return CmdRS.Success(); }); } } }