Beispiel #1
0
 protected override Task DoHandleResultAsync(GrpcContext context)
 {
     return(Task.Run(() =>
     {
         AddGrpcRecord(context);
     }));
 }
Beispiel #2
0
 protected override Task DoHandleAsync(GrpcContext context)
 {
     return(Task.Run(() =>
     {
         context.StartMonitor();
         _logger.LogInformation(_jsonSerializer.Serialize(context.Message));
     }));
 }
        protected override async Task DoHandleAsync(GrpcContext context)
        {
            using (var scope = GrpcServerBuilder.ServiceProvider.CreateScope())
            {
                context.Result = await context.Hander(context.Message, scope);

                context.Complete();
            }
        }
Beispiel #4
0
        public virtual async Task HandleAsync(GrpcContext context)
        {
            await DoHandleAsync(context);

            if (!context.HasDone)
            {
                await _next(context);
            }
            await DoHandleResultAsync(context);
        }
Beispiel #5
0
        protected override async Task DoHandleAsync(GrpcContext context)
        {
            using (var scope = GrpcServerBuilder.ServiceProvider.CreateScope())
            {
                var handle = _proxy.GetHandleDelegate <BaseMessage, MessageResult>(
                    context.Message, scope.ServiceProvider);
                context.Result = await handle(context.Message);

                context.HasDone = true;
            }
        }
Beispiel #6
0
        private void AddGrpcRecord(GrpcContext context)
        {
            context.StopMonitor();
            var loggerData = new ArrayList();

            loggerData.Add(context.CallContext.Method);
            loggerData.Add($"{context.PerformanceInfo.UsedTime} ms");
            loggerData.Add(context.CallContext.Peer);
            loggerData.Add(context.Message);
            loggerData.Add(context.Result);

            var msg = new
            {
                Name      = "GrpcStatistics",
                Interface = context.CallContext.Method,
                Spend     = $"{context.PerformanceInfo.UsedTime} ms",
                FromIP    = context.CallContext.Peer,
                Request   = context.Message,
                Response  = context.Result
            };

            _logger.LogInformation(_jsonSerializer.Serialize(msg));
        }
Beispiel #7
0
 protected virtual Task DoHandleResultAsync(GrpcContext context)
 {
     return(Task.CompletedTask);
 }
Beispiel #8
0
 protected abstract Task DoHandleAsync(GrpcContext context);