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

cmd/protoc-gen-go-grpc: allow hooks to modify client structs and service handlers #5240

Merged
merged 5 commits into from
Apr 6, 2022

Conversation

ZhouyihaiDing
Copy link
Contributor

@ZhouyihaiDing ZhouyihaiDing commented Mar 14, 2022

We are supporting the service renaming by using a global variables which will cause issues in some scenarios.

This change allows us to modify the ClientConn interface and handlers, which allows us to store the renamed service name by each clientconn. This matches how the internal service renaming is implemented.

RELEASE NOTES: n/a

@@ -36,9 +36,11 @@ const (

type serviceGenerateHelperInterface interface {
formatFullMethodName(service *protogen.Service, method *protogen.Method) string
generateNewClientConnInterface(g *protogen.GeneratedFile, clientName string)
Copy link
Member

Choose a reason for hiding this comment

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

Why "New"?

And it's generating a client struct, not the ClientConn interface, isn't it? So generateClientStruct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@dfawley dfawley assigned ZhouyihaiDing and unassigned dfawley Mar 29, 2022
@dfawley dfawley added the Type: Internal Cleanup Refactors, etc label Mar 29, 2022
@dfawley dfawley added this to the 1.46 Release milestone Mar 29, 2022
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

LGTM; @menghanl any concerns?

generateNewClientDefinitions(g *protogen.GeneratedFile, service *protogen.Service, clientName string)
generateUnimplementedServerType(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service)
generateServerFunctions(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service, serverType string, serviceDescVar string)
generateServerFunctions(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service, serverType string, serviceDescVar string) []string
Copy link
Contributor

Choose a reason for hiding this comment

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

How will the return value be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed.

handlerNames = append(handlerNames, hname)
}
genServiceDesc(file, g, serviceDescVar, serverType, service, handlerNames)
return handlerNames
Copy link
Contributor

Choose a reason for hiding this comment

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

Compiling error.
Delete this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed

@menghanl menghanl assigned ZhouyihaiDing and unassigned menghanl Apr 5, 2022
@dfawley dfawley changed the title cmd/protoc-gen-go-grpc: allow hooks to modify ClientConn interface and handlers cmd/protoc-gen-go-grpc: allow hooks to modify client structs and service handlers Apr 6, 2022
@dfawley dfawley merged commit 18fdf54 into grpc:master Apr 6, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants