apache / apache/brpc

[E1002]Fail to find method 客户端和服务端的命名空间必须保持一致?

Open
#1,208 0 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

之前使用thrift的时候,server和client的接口文件中的命名空间不一致,不会影响调用。
但是用brpc后,及使用pb协议,发现命名空间修改后,调用失败了,报错:[E1002]Fail to find method,
也就是proto接口文件里的package AAA.service; 改成了:package BBB.service;
查到的错误出处在下面这块:
```

// NOTE(gejun): jprotobuf sends service names without packages. So the
// name should be changed to full when it's not.
butil::StringPiece svc_name(request_meta.service_name());
if (svc_name.find('.') == butil::StringPiece::npos) {
const Server::ServiceProperty* sp =
server_accessor.FindServicePropertyByName(svc_name);
if (NULL == sp) {
cntl->SetFailed(ENOSERVICE, "Fail to find service=%s",
request_meta.service_name().c_str());
break;
}
svc_name = sp->service->GetDescriptor()->full_name();
}
const Server::MethodProperty* mp =
server_accessor.FindMethodPropertyByFullName(
svc_name, request_meta.method_name());
if (NULL == mp) {
cntl->SetFailed(ENOMETHOD, "Fail to find method=%s/%s",
request_meta.service_name().c_str(),
request_meta.method_name().c_str());
break;

```
我估计是client和server的函数名full_name(包括前缀的命名空间)要完全一致,求大神们能解答一下?thrift是怎么实现的?

Contributor guide

Open the contributing guide

Research direction

The report points to the service and method lookup block shown in the issue; start there and compare the client and server .proto package declarations. Trace how service_name and method_name are resolved, then document the required namespace behavior and the thrift comparison; no source file or test is named, so completion is a confirmed explanation rather than a specified patch.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.