Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc api调用报服务找不到 #63

Closed
liqiangno1 opened this issue May 13, 2020 · 5 comments
Closed

rpc api调用报服务找不到 #63

liqiangno1 opened this issue May 13, 2020 · 5 comments

Comments

@liqiangno1
Copy link

go-micro版本:V2.6

按照示例:https://github.com/micro-in-cn/tutorials/tree/master/examples/basic-practices/micro-api/rpc 运行rpc.go以及micro api

curl -H 'Content-Type: application/json' -d '{"name": "小小先"}' "http://localhost:8080/example/call"
curl -H 'Content-Type: application/json' -d '{}' http://localhost:8080/example/foo/bar
两个请求都是返回
{"id":"go.micro.api","code":500,"detail":"service not found","status":"Internal Server Error"}

添加enable_rpc参数,开启rpc路由则可以成功

post http://localhost:8080/rpc
参数:{"service":"go.micro.rpc.example","endpoint":"Example.Call","request":{"name":"qwe"}}
返回: { "message": "RPC Call收到了你的请求 qwe"}
@printfcoder
Copy link
Member

micro api在2.x版本中存在不兼容的问题,由于v2版本是过渡版本,我们没有太多时间进行跟进,等稳定后才会去更新我们的教程版本。不过不影响对micro的理解。

@liqiangno1
Copy link
Author

micro api在2.x版本中存在不兼容的问题,由于v2版本是过渡版本,我们没有太多时间进行跟进,等稳定后才会去更新我们的教程版本。不过不影响对micro的理解。

好吧。那一般情况下grpc转http对外提供接口要怎么搞呢?每个srv再加一层api服务吗?感觉这样很繁琐额
#60 看这个issue也是建议用micro api代理,现在就是走不通这个
看demo里面有用grpc-gateway这个组件,这个建议用吗?感觉在micro生态再引用其他组件是不是不太好呢。

@liqiangno1
Copy link
Author

另外我测试了一下,把命名空间改成go.micro.api就可以代理成功,可以通过地址路由转发过去。这个是不是限制了只能代理api层呢?

@hb-chen
Copy link

hb-chen commented May 14, 2020

micro api是只能代理命名空间下的,如果你每个srv都要暴露api,那实际是你可以不分这一层,可以把srv都在api服务层,再根据服务的演变逐步拆分出来srv层

@liqiangno1
Copy link
Author

micro api是只能代理命名空间下的,如果你每个srv都要暴露api,那实际是你可以不分这一层,可以把srv都在api服务层,再根据服务的演变逐步拆分出来srv层
好的,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants