原始文件结构
====== FILE pb/common.proto ======
package pb
message GetVersionReq { ... }
message GetVersionRsp { ... }
====== FILE pb/nvr/preview.proto ======
package nvr
Import “pb/common.proto”
service Previewer {
rpc GetVersion(pb.GetVersionReq) return (pb.GetVersionRsp) {}
}
我完成了GetVersion的实现,但是仍然遇到“找不到方法!”错误。
一些发现:
def _serve(state): while True: event = state.completion_queue.poll() if event.tag is _SHUTDOWN_TAG: with state.lock: state.due.remove(_SHUTDOWN_TAG) if _stop_serving(state): return elif event.tag is _REQUEST_CALL_TAG: with state.lock: state.due.remove(_REQUEST_CALL_TAG) concurrency_exceeded = ( state.maximum_concurrent_rpcs is not None and state.active_rpc_count >= state.maximum_concurrent_rpcs)
现在,我通过删除“ import pb / common.pb”并直接在 preview.proto 中定义GetVersionReq / Rsp来解决该问题,如下所示
====== FILE pb/nvr/preview.proto ======
message GetVersionReq { ... }
message GetVersionRsp { ... }
service Previewer {
rpc GetVersion(GetVersionReq) return (GetVersionRsp) {}
}