Slide 19
Slide 19 text
© LayerX Inc. 19
gRPCのコード生成
Protobuf と Connect
type GreetServiceClient interface { // クライアントがリクエストするとき の interface
Greet(context.Context, *connect.Request[v1.GreetRequest])
(*connect.Response[v1.GreetResponse], error)
}
type GreetServiceHandler interface { // サーバが実装することになる interface
Greet(context.Context, *connect.Request[v1.GreetRequest])
(*connect.Response[v1.GreetResponse], error)
}
こういうのを生成してくれる(これは connect-go の生成物の一部)
ボイラープレート的な処理はgRPCやConnectがうまくやってくれる