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

Reimplement DC redirection handler #3887

Merged
merged 3 commits into from
Feb 4, 2023
Merged

Reimplement DC redirection handler #3887

merged 3 commits into from
Feb 4, 2023

Conversation

wxing1292
Copy link
Contributor

What changed?

  • Implement generic DC redirection interceptor & UT

Why?
Reduce repetitive logic

How did you test it?
UT

Potential risks
N/A

Is hotfix candidate?
N/A

* Implement generic DC redirection interceptor & UT
@wxing1292 wxing1292 marked this pull request as ready for review February 2, 2023 19:20
@wxing1292 wxing1292 requested a review from a team as a code owner February 2, 2023 19:20
@@ -26,9 +26,9 @@ package interceptor

import "strings"

func splitMethodName(
func SplitMethodName(
Copy link
Contributor

Choose a reason for hiding this comment

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

Seem like this is just AbstractMethodName? Only the second result is 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.

we only use the second half for now

Comment on lines +181 to +182
i.logger.Warn(fmt.Sprintf("RedirectionInterceptor encountered unknown API: %v", methodName))
return handler(ctx, req)
Copy link
Contributor

Choose a reason for hiding this comment

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

could it assume there are only two sets of APIs? can it do return i.handleLocalAPIInvocation(ctx, req, handler, methodName)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it can but will looks weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

handler grpc.UnaryHandler,
methodName string,
) (_ interface{}, retError error) {
scope, startTime := i.beforeCall(dcRedirectionMetricsPrefix + methodName)
Copy link
Contributor

Choose a reason for hiding this comment

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

only method name if it is local invocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean?

@@ -81,7 +84,7 @@ func NewClientBean(factory Factory, clusterMetadata cluster.Metadata) (Bean, err
}

adminClients := map[string]adminservice.AdminServiceClient{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we never need to do redirection for admin service calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i do not believe there is such need.

methodName string,
respAllocFn func() interface{},
namespaceName namespace.Name,
) (_ interface{}, retError error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need/want to avoid multiple redirects? e.g. to prevent a request from bouncing between cells.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

request will only bounce between clusters if namespace flip flop

@yycptt yycptt merged commit ca5be29 into temporalio:master Feb 4, 2023
@wxing1292 wxing1292 deleted the redirect branch February 23, 2023 20:47
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.

4 participants