grpc stream c++ example

  • codes:

     https://github.com/kacakaca/Test/tree/master/grpc_examples
    
    • It can be successfully executed on ubuntu (grpc needs to be installed), and makeexecutable files serverand files are generated after execution client. ./serverThen run and in different terminals respectively ./client.
    • In the information.proto defined by service
    • The implementation of server is in server.cc
    • The implementation of client is in client.cc
  • Implemented 4 kinds of services

        rpc AddRecord (Person) returns (google.protobuf.Empty) {
          
          }
        rpc DeleteRecords (stream ReqName) returns (google.protobuf.Empty) {
          
          }
        rpc GetRecordsByAge (AgeRange) returns (stream Person) {
          
          }
        rpc GetRecordsByNames (stream ReqName) returns (stream Person) {
          
          }
    
    • AddRecord is used to add a record, the name needs to be unique (Unary RPCs)
    • DeleteRecords is used to delete multiple records and delete records corresponding to ReqName (client streaming RPCs)
    • GetRecordsByAge is used to get records in a certain age range (server streaming RPCs)
    • GetRecordsByNames is used to get multiple records of requested names (bi-streaming RPCs)

Guess you like

Origin blog.csdn.net/iamanda/article/details/112539366