• consul 支持GRPC 心跳地址封装 基于net 6


    新建一个HealthCheckService.proto  官方标准写法,不要问为什么?

    syntax = "proto3";
    
    package grpc.health.v1;
    
    message HealthCheckRequest {
    	string service = 1;
    }
    
    message HealthCheckResponse {
    	enum ServingStatus {
    		UNKNOWN = 0;
    		SERVING = 1;
    		NOT_SERVING = 2;
    	}
    	ServingStatus status = 1;
    }
    
    service Health {
    	rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
    
    	rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
    }
    

      

     services 

      public class HealthCheckService : Health.HealthBase
        {
            public override Task<HealthCheckResponse> Check(HealthCheckRequest request, ServerCallContext context)
            {
                Console.WriteLine($"This is {nameof(HealthCheckService)} Check ");
                //TODO:检查逻辑
                return Task.FromResult(new HealthCheckResponse() { Status = HealthCheckResponse.Types.ServingStatus.Serving });
            }
    
            public override async Task Watch(HealthCheckRequest request, IServerStreamWriter<HealthCheckResponse> responseStream, ServerCallContext context)
            {
                //TODO:检查逻辑
                await responseStream.WriteAsync(new HealthCheckResponse()
                { Status = HealthCheckResponse.Types.ServingStatus.Serving });
            }
        }
    

      

    Program 里面 

    管道流程写入方法

    app.MapGrpcService<HealthCheckService>();

  • 相关阅读:
    HDU 1385 Minimum Transport Cost
    TOJ 3488 Game Dice
    TOJ 1717 WOJ
    POJ 2553 The Bottom of a Graph
    TOJ 1836 Play on Words
    利用OpenCV建立视差图像
    分享一个PyTorch医学图像分割开源库
    WACV 2021 论文大盘点-图像分割篇
    SolidWorks动画教程(1):简单动画制作
    VS2013安装及破解教程
  • 原文地址:https://www.cnblogs.com/jasontarry/p/15814209.html
Copyright © 2020-2023  润新知