{ gRPC }

  • 00 proto

    /

    proto

    syntax = "proto3";
    <!--more-->

    option java_package = "ex.grpc";

    package mathtest;

    // Defines the service
    service MathTest {
    // Function invoked to send the request
    rpc sendRequest (MathRequest) returns (MathReply) {}
    }

    // The request message containing requested numbers
    message MathRequest {
    int32 a = 1;
    int32 b = 2;
    }

    // The response message containing response
    message MathReply {
    int32 result = 1;
    }
  • 02 Client

    /

    Client

    • 通过grpc::CreateChannel传入IP string创建channel。
    • 通过ServiceName::NewStub传入channel创建Stub