gRPC in Java - Blocking/nonblocking stubs -
i attempting create java grpc client communicate server in go. new grpc following tutorial grpc java tutorial. in these examples refer blocking , nonblocking stubs appear import elsewhere in github.
import io.grpc.examples.routeguide.routeguidegrpc.routeguideblockingstub; import io.grpc.examples.routeguide.routeguidegrpc.routeguidestub; ... ... blockingstub = routeguidegrpc.newblockingstub(channel); asyncstub = routeguidegrpc.newstub(channel);
however cannot find these classes in repo. still hazy on for, should have been produced when compiling .proto file? help/pointers appreciated. thanks.
the grpc stub classes generated when run protoc compiler , finds service declaration in proto file. stub classes api client uses make rpc calls on service endpoint.
these stubs come in 2 flavors: blocking , async.
blocking stubs synchronous (block running thread) , ensure rpc call invoked on doesn't return until returns response or raises exception. care should taken not invoke rpc on blocking stub ui thread result in unresponsive/janky ui.
asynchronous stubs make non-blocking rpc calls response returned asynchronously via streamobserver callback object.
for more information, refer grpc documentation regarding stubs here.
Comments
Post a Comment