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

A RPC service generated by multiple proto files? #4099

Open
liangyuan1 opened this issue Apr 21, 2024 · 3 comments
Open

A RPC service generated by multiple proto files? #4099

liangyuan1 opened this issue Apr 21, 2024 · 3 comments

Comments

@liangyuan1
Copy link

基础proto
image
用户proto
image
角色proto
image
执行命令
goctl rpc protoc basicServices.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=./basicServices -m

如何基于多个proto文件按照分组的方式生成服务类似api服务那样
image

@jaronnie
Copy link
Contributor

go-zero 目前应该是不支持你想要的效果。目前我推荐的方式是这样的。比如一个 user.proto, 一个 role.proto 文件。可以使用多个 goctl 命令进行生成,但是会产生一些多余的 etc 配置文件,多余的 main 文件等。在 shell 脚本中进行删除,并在注册 grpc 服务的地方手动注册进去进行了。如果觉得麻烦,可以考虑 Jzero。一个对 go-zero 的封装,可以一键创建项目,一键生成代码。支持多 proto 分组等特性。项目地址:https://github.com/jaronnie/jzero

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


go-zero currently probably does not support the effect you want. The way I currently recommend is this. For example, a user.proto, a role.proto file. Multiple goctl commands can be used for generation, but some redundant etc configuration files, redundant main files, etc. will be generated. Delete it in the shell script and manually register it where the grpc service is registered. If you find it troublesome, you can consider Jzero. A package of go-zero that can create projects and generate code with one click. Supports features such as multi-proto grouping. Project address: https://github.com/jaronnie/jzero

@kevwan kevwan changed the title 一个rpc服务如何基于多个proto文件进行生成 A RPC service generated by multiple proto files? Apr 24, 2024
@kesonan
Copy link
Collaborator

kesonan commented Apr 25, 2024

The message of rpc service must be defined in the same proto file as the service. Importing from outside is not supported. Please refer to the documentation https://go-zero.dev/docs/tutorials/cli/rpc#goctl-rpc-protoc

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

4 participants