No-SilverBullet commented on code in PR #3092:
URL: https://github.com/apache/dubbo-go/pull/3092#discussion_r2611244984
##########
metadata/client.go:
##########
@@ -134,34 +134,93 @@ func generateInvocation(u *common.URL, methodName string,
req any, resp any, cal
rV := reflect.ValueOf(req)
inv = invocation.NewRPCInvocationWithOptions(
invocation.WithMethodName(methodName),
- invocation.WithArguments([]any{rV.Interface()}),
+ invocation.WithArguments([]interface{}{rV.Interface()}),
invocation.WithReply(resp),
-
invocation.WithAttachments(map[string]any{constant.AsyncKey: "false"}),
+
invocation.WithAttachments(map[string]interface{}{constant.AsyncKey: "false"}),
invocation.WithParameterValues([]reflect.Value{rV}))
}
return inv, nil
}
type remoteMetadataServiceV1 struct {
- invoker base.Invoker
+ invoker protocol.Invoker
}
func (m *remoteMetadataServiceV1) getMetadataInfo(ctx context.Context,
revision string) (*info.MetadataInfo, error) {
const methodName = "getMetadataInfo"
- metadataInfo := &info.MetadataInfo{}
- inv, _ := generateInvocation(m.invoker.GetURL(), methodName, revision,
metadataInfo, constant.CallUnary)
+ // Use interface{} as reply parameter to accept any type (MetadataInfo
or string)
+ // This avoids panic when Java returns String instead of MetadataInfo
+ var rawResult interface{}
+ inv, _ := generateInvocation(m.invoker.GetURL(), methodName, revision,
&rawResult, constant.CallUnary)
+
+ logger.Debugf("[MetadataRPC] Calling %s on provider %s, revision: %s",
methodName, m.invoker.GetURL().Location, revision)
+
res := m.invoker.Invoke(context.Background(), inv)
if res.Error() != nil {
- logger.Errorf("could not get the metadata info from remote
provider: %v", res.Error())
+ logger.Errorf("[MetadataRPC] RPC call failed to %s: %v",
m.invoker.GetURL().Location, res.Error())
return nil, res.Error()
}
- if metadataInfo.Services == nil {
- metadataInfo = res.Result().(*info.MetadataInfo)
+
+ logger.Debugf("[MetadataRPC] RPC call succeeded to %s, checking result
type", m.invoker.GetURL().Location)
+
+ // rawResult now contains the deserialized value - could be
*MetadataInfo, string, or nil
+ logger.Debugf("[MetadataRPC] Result type: %T, result value: %+v",
rawResult, rawResult)
Review Comment:
just a suggestion, i think could reduce the number of these similar
info-level logs.
--
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]