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

grpc/service: Refactor middleware #8849

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

okJiang
Copy link
Member

@okJiang okJiang commented Nov 25, 2024

What problem does this PR solve?

Issue Number: Close #8850

What is changed and how does it work?

Organize the middleware code and handle them centrally.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. labels Nov 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Nov 25, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cabinfeverb for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Nov 25, 2024
@okJiang okJiang marked this pull request as draft November 25, 2024 09:22
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 25, 2024

type forwardFn func(ctx context.Context, client *grpc.ClientConn, request any) (any, error)

var forwardFns = map[string]forwardFn{
Copy link
Member

Choose a reason for hiding this comment

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

I think it's more complicated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't it easier to manage after the modifications compared to the previous definition scattered across each function? Could you elaborate on your viewpoint?

Copy link
Member

Choose a reason for hiding this comment

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

There are too many hardcode things and you still need to add them one by one.

Copy link
Member Author

@okJiang okJiang Nov 26, 2024

Choose a reason for hiding this comment

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

From the current implementation, it seems that hardcoding cannot be avoided. But this has nothing to do with this PR (it was hardcoded before as well). Based on the existing changes, where do you think it has become more complex?

Copy link
Member

Choose a reason for hiding this comment

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

We don't need to care about the function name for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we need to maintain it, we have to pay attention to the function names, right? I think we should know which functions support a certain middleware and which do not.

don't need to care about the function name

Or do you mean that all functions should support the forward middleware, so we don't need to worry about the function names? If that's the case, I don't think the impact is significant; placing a map here doesn't imply that we need to be overly concerned about function names, and it doesn't add much burden. If we didn't have this map, we would still need to define a forwardFn inside the function when adding new functions, which makes no difference.

If we still hold different views, perhaps we should listen to the opinions of other members. cc @JmPotato @nolouch @lhy1024

@okJiang
Copy link
Member Author

okJiang commented Nov 28, 2024

I will fix the problem from ci after discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The scattered gRPC middleware makes it inconvenient to add new middleware
2 participants