$ pyenv versions
$ pyenv 3.7.0
$ source env/bin/activate
$ pip install --upgrade pip
$ python -m pip install grpcio
$ pip install grpcio-tools
$ git clone -b v1.22.0 https://github.com/grpc/grpc
$ cd grpc/examples/python/helloworld
$ python greeter_server.py
## 다른 탭에서
$ python greeter_client.py
// pfservice.proto
syntax = "proto3";
option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";
// helloworld.poroto 복사해왔고
packagep lusfriend.service;
//
service PlusfriendService {
// Sends a greeting
rpc GetProfiles (ReqProfiles) returns (ResProfiles) {}
}
message Profile {
uint32 id = 1;
uint32 friend_count = 2;
}
// 프로필 조회하는 request 라서, id 리스트를 받을것이므로 Profile 메세지를 새로만들고 그것을 여러개 보내기로.
message ReqProfiles {
repeated string ids = 1;
}
// The response message containing the greetings
message ResProfiles {
repeated Profile profiles = 1;
}
$ python -m grpc_tools.protoc -I../../protos --python_out=. --grpc_python_out=. ../../protos/helloworld.proto
ids = ','.join(request.ids)