Tsukikage7 commented on code in PR #3154:
URL: https://github.com/apache/dubbo-go/pull/3154#discussion_r2692933309
##########
protocol/triple/server.go:
##########
@@ -503,51 +503,101 @@ func createServiceInfoWithReflection(svc
common.RPCService) *common.ServiceInfo
if methodType.Name == "Reference" {
continue
}
- paramsNum := methodType.Type.NumIn()
- // the first param is receiver itself, the second param is ctx
- // just ignore them
- if paramsNum < 2 {
- logger.Fatalf("TRIPLE does not support %s method that
does not have any parameter", methodType.Name)
- continue
- }
- paramsTypes := make([]reflect.Type, paramsNum-2)
- for j := 2; j < paramsNum; j++ {
- paramsTypes[j-2] = methodType.Type.In(j)
- }
- methodInfo := common.MethodInfo{
- Name: methodType.Name,
- // only support Unary invocation now
- Type: constant.CallUnary,
- ReqInitFunc: func() any {
- params := make([]any, len(paramsTypes))
- for k, paramType := range paramsTypes {
- params[k] =
reflect.New(paramType).Interface()
- }
- return params
- },
+ methodInfo := buildMethodInfoWithReflection(methodType)
+ if methodInfo != nil {
+ methodInfos = append(methodInfos, *methodInfo)
}
- methodInfos = append(methodInfos, methodInfo)
}
- // only support no-idl mod call unary
- genericMethodInfo := common.MethodInfo{
- Name: "$invoke",
- Type: constant.CallUnary,
+ // Add $invoke method for generic call support
+ methodInfos = append(methodInfos, buildGenericMethodInfo())
Review Comment:
Yeah, that's on purpose. Inside the loop we're adding all the regular
service methods, then after the loop we add $invoke once for generic call
support. Makes sure we don't accidentally register it multiple times.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]