-
Notifications
You must be signed in to change notification settings - Fork 917
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
Call RedirectionInterceptor only for WorkflowHandler #3924
Call RedirectionInterceptor only for WorkflowHandler #3924
Conversation
if _, isWorkflowHandler := info.Server.(*WorkflowHandler); !isWorkflowHandler { | ||
return handler(ctx, req) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actual fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? All requests will have this extra check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is very cheap check. The other option is to compare strings: first return value from SplitMethodName
with hardcoded string temporal.api.workflowservice.v1.WorkflowService
but I believe checking type is better and faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no strong opinion. however, admin and operator are mostly manual trigger requests. most of the requests are workflow service requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget health check. I see tons of unknown API: Check
warning logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion between this type check and string check either. but I agree we should do one since the redirection logic only applies to workflowservice
info *grpc.UnaryServerInfo, | ||
handler grpc.UnaryHandler, | ||
methodName string, | ||
respAllocFn func() interface{}, | ||
respCtorFn responseConstructorFn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is Ctor? constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reflection of my nostalgic memories from the past years: https://stackoverflow.com/questions/4614099/what-is-the-meaning-of-ctor.
@@ -45,75 +45,75 @@ import ( | |||
var ( | |||
dcRedirectionMetricsPrefix = "DCRedirection" | |||
|
|||
localAPIResults = map[string]respAllocFn{ | |||
localAPIResponses = map[string]responseConstructorFn{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that I'm looking at this, have we benchmarked this against the equivalent reflection-based code? I see we need the maps anyway but they could just be sets and use reflection to construct the response. I'm curious about code bloat effects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought about it. I even have a func for it:
func newOfSameType(val reflect.Value) reflect.Value {
valType := val.Type().Elem()
newValue := reflect.New(valType)
val.Set(newValue)
return newValue
}
but as soon as map is needed anyway, I am in doubt. Best thing, I guess, is code-gen the map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not quite that easy, you have to go from grpc method name to first return value of that method on WorkflowService. but only like 3-4 more lines.
we can't just code-gen, the maps hold the semantics about which calls need to be forwarded. but they could be map[string]struct{}, and then use reflection to make the response values
if _, isWorkflowHandler := info.Server.(*WorkflowHandler); !isWorkflowHandler { | ||
return handler(ctx, req) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion between this type check and string check either. but I agree we should do one since the redirection logic only applies to workflowservice
What changed?
Call
RedirectionInterceptor
only forWorkflowHandler
.Why?
RedirectionInterceptor
is not intended to be used by other thanWorkflowHandler
handler.How did you test it?
Existing tests.
Potential risks
No risks.
Is hotfix candidate?
No.