• 【学习笔记】gRPC-python


    protobuf数据类型和pb文件

    protobuf数据类型

    string
    bytes
    bool
    int32,int64
    float
    repeated 数组,如repeated string data = 1; //["hah", "heh", "oha"]
    map 例如map<string, string> data = 1;

    protobuf特殊字符

    package
    syntax
    service
    rpc
    stream
    message
    extend
    import
    //

    pb文件

    python grpc工具生成的两个文件:

    1. *_pb2.py
      每一个消息体(message)对应的信息存储,如request和response
    2. *_pb2_grpc.py
      存储每一个服务的server与客户端以及注册server的工具。
      客户端名:service_name+Stub
      服务器名:service_name+Servicer
      注册服务为:add_service_name_to_server

    传输方式

    单程(unary)和流(stream)

    流(stream)

    分为:

    1. 双向:client请求服务器端为stream,服务器端发送客户端为stream;
    2. 单向但也是双方建立了长连接:有两种,一种是服务器接受为stream;
    3. 一种是服务器发送客户端为stream。
  • 相关阅读:
    hdu 3074 Multiply game
    uva 10717 Mint
    uva 10128 Queue
    uva 10673 Play with Floor and Ceil
    hdu 1754 I Hate It
    hdu 1166 敌兵布阵
    uva 10079 Pizza Cutting
    费波那列素数
    uva 10236 The Fibonacci Primes
    hdu 1698 Just a Hook
  • 原文地址:https://www.cnblogs.com/lvjincheng/p/13555619.html
Copyright © 2020-2023  润新知