Skip to content

Conversation

gszw90
Copy link

@gszw90 gszw90 commented Aug 2, 2025

Add the --rpc_name flag to the goctl rpc protoc command to set the RPC service name instead of using the proto file name.
It also allows to generate rpc service code from multiple proto files within the same service.
run:

goctl rpc protoc app/pb/user.proto --go_out=./app/pb --go-grpc_out=./app/pb --zrpc_out=./app --style=go_zero -m --rpc_name app
goctl rpc protoc app/pb/role.proto --go_out=./app/pb --go-grpc_out=./app/pb --zrpc_out=./app --style=go_zero -m --rpc_name app

generate files:

app/
├── app.go
├── client/
│   ├── roleservice/
│   │   └── role_service.go
│   └── userservice/
│       └── user_service.go
├── etc/
│   └── app.yaml
├── internal/
│   ├── config/
│   │   └── config.go
│   ├── logic/
│   │   ├── roleservice/
│   │   │   ├── create_role_logic.go
│   │   │   └── update_role_logic.go
│   │   └── userservice/
│   │       ├── create_user_logic.go
│   │       └── user_detail_logic.go
│   ├── server/
│   │   ├── roleservice/
│   │   │   └── role_service_server.go
│   │   └── userservice/
│   │       └── user_service_server.go
│   └── svc/
│       └── service_context.go
└── pb/
    ├── role/
    │   ├── role.pb.go
    │   └── role_grpc.pb.go
    ├── user/
    │     ├── user.pb.go
    │     └── user_grpc.pb.go
    ├── user.proto
    └── role.proto

gszw90 added 2 commits August 2, 2025 19:04
- Add --rpc_name flag to set the RPC service name
- Update configuration file and main file generation to use the specified service name
- Modify README to include new flag description and usage examples
- Enhance support for generating code from multiple proto files within the same service
@kevwan kevwan requested review from Copilot and kesonan August 2, 2025 13:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new --rpc_name flag to the goctl rpc protoc command, allowing users to specify a custom RPC service name instead of defaulting to the proto file name. This enables generating RPC service code from multiple proto files within the same service by providing a unified service name.

  • Adds --rpc_name flag to override default service naming behavior
  • Modifies generators to use the custom RPC name when provided
  • Updates documentation and help text for the new flag

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/goctl/rpc/generator/genmain.go Updates main file generation to use custom RPC name when provided
tools/goctl/rpc/generator/genetc.go Updates etc file generation to use custom RPC name and adds ZRpcContext parameter
tools/goctl/rpc/generator/gen.go Adds RpcName field to ZRpcContext struct and passes context to GenEtc
tools/goctl/rpc/cmd.go Registers the new rpc_name flag in the protoc command
tools/goctl/rpc/cli/zrpc.go Sets RpcName field from command line flag
tools/goctl/rpc/cli/cli.go Declares VarStringRpcName variable and sets it in RPCNew function
tools/goctl/rpc/README.md Documents the new --rpc_name flag with usage examples
tools/goctl/internal/flags/default_en.json Adds help text for the rpc_name flag

VarStringStyle string
// VarStringZRPCOut describes the zRPC output.
VarStringZRPCOut string
// VarStringRpcName describe the rpc name
Copy link

Copilot AI Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has a grammatical error. It should be "VarStringRpcName describes the rpc name" (missing 's' in 'describe').

Suggested change
// VarStringRpcName describe the rpc name
// VarStringRpcName describes the rpc name

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented Aug 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

"verbose": "Enable log output",
"client": "Whether to generate rpc client"
"client": "Whether to generate rpc client",
"rpc_name": "Rpc service name. Setting the rpc service name prevents it from defaulting to the proto file name. This enables the use of multiple proto files within the same service for code generation"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use name instead of rpc_name?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

gszw90 added 3 commits August 19, 2025 20:30
- Add --rpc_name flag to set the RPC service name
- Update configuration file and main file generation to use the specified service name
- Modify README to include new flag description and usage examples
- Enhance support for generating code from multiple proto files within the same service
@kevwan kevwan force-pushed the feat-add-rpc-name branch from 537d12d to 312fda3 Compare August 19, 2025 12:30
gszw90 added 4 commits August 21, 2025 22:01
…at-add-rpc-name

# Conflicts:
#	tools/goctl/internal/flags/default_en.json
#	tools/goctl/rpc/README.md
#	tools/goctl/rpc/cli/cli.go
#	tools/goctl/rpc/cli/zrpc.go
#	tools/goctl/rpc/cmd.go
#	tools/goctl/rpc/generator/gen.go
#	tools/goctl/rpc/generator/genetc.go
#	tools/goctl/rpc/generator/genmain.go
- Change --rpc_name to --name in the goctl rpc command description
@gszw90 gszw90 requested a review from kesonan August 22, 2025 03:48
gszw90 and others added 2 commits August 27, 2025 11:32
# Conflicts:
#	tools/goctl/rpc/cli/cli.go
#	tools/goctl/rpc/cli/zrpc.go
#	tools/goctl/rpc/cmd.go
@kesonan
Copy link
Collaborator

kesonan commented Sep 6, 2025

@gszw90 Can you please resolve the conflict and AI comment's?

gszw90 and others added 2 commits September 10, 2025 17:03
…at-add-rpc-name

# Conflicts:
#	tools/goctl/rpc/cli/cli.go
#	tools/goctl/rpc/cli/zrpc.go
#	tools/goctl/rpc/cmd.go
@gszw90
Copy link
Author

gszw90 commented Sep 10, 2025

done @kesonan

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

Successfully merging this pull request may close these issues.

2 participants