AlexStocks commented on code in PR #862:
URL: https://github.com/apache/dubbo-go-pixiu/pull/862#discussion_r3143208773


##########
pkg/client/dubbo/dubbo.go:
##########
@@ -172,106 +196,157 @@ func (dc *Client) Close() error {
        return nil
 }
 
-// Call invoke service
-func (dc *Client) Call(req *client.Request) (res any, err error) {
-       // if GET with no args, values would be nil
-       values, err := dc.genericArgs(req)
+// Call invoke service.
+func (dc *Client) Call(ctx context.Context, req *DubboOutboundRequest) (any, 
error) {
+       if req == nil {
+               return nil, errors.New("dubbo outbound request is nil")
+       }
+
+       spec := dc.resolveFromOutbound(req)
+       types, vals, finalValues, err := dc.preparePayload(req)
        if err != nil {
                return nil, err
        }
-       target, ok := values.(*dubboTarget)
-       if !ok {
-               return nil, errors.New("map parameters failed")
-       }
 
-       dm := req.API.IntegrationRequest
-       method := dm.Method
-       types := []string{}
-       vals := []hessian.Object{}
-       finalValues := []byte{}
+       gs, err := dc.Get(spec)
+       if err != nil {
+               return nil, err
+       }
+       if gs == nil {
+               return nil, errors.New("dubbo generic service is nil")
+       }
 
-       if target != nil {
-               logger.Debugf("[dubbo-go-pixiu] dubbo invoke, method:%s, 
types:%s, reqData:%v", method, target.Types, target.Values)
-               types = target.Types
-               vals = make([]hessian.Object, len(target.Values))
-               for i, v := range target.Values {
-                       vals[i] = v
-               }
-               if len(types) == 0 {
-                       types = javaClassNameElem(vals)
-               }
-               var err error
-               finalValues, err = json.Marshal(vals)
-               if err != nil {
-                       logger.Warnf("[dubbo-go-pixiu] reqData convert to 
string failed: %v", err)
-               }
-       } else {
-               logger.Debugf("[dubbo-go-pixiu] dubbo invoke, method:%s, 
types:%s, reqData:%v", method, nil, nil)
+       invokeCtx, cancel := prepareInvokeContext(ctx, req.Timeout)
+       if cancel != nil {
+               defer cancel()
        }
 
-       gs := dc.Get(dm)
-       tr := otel.Tracer(traceNameDubbogoClient)
-       ctx, span := tr.Start(req.Context, spanNameDubbogoClient)
-       trace.SpanFromContext(req.Context).SpanContext()
-       span.SetAttributes(attribute.Key(spanTagMethod).String(method))
-       span.SetAttributes(attribute.Key(spanTagType).StringSlice(types))
-       
span.SetAttributes(attribute.Key(spanTagValues).String(string(finalValues)))
+       spanCtx, span := otel.Tracer(traceNameDubbogoClient).Start(invokeCtx, 
spanNameDubbogoClient)
        defer span.End()
-
-       // tracing inject manually;
-       carrier := propagation.MapCarrier{}
-       otel.GetTextMapPropagator().Inject(ctx, carrier)
-       ctxWithAttachment := context.WithValue(ctx, constant.AttachmentKey, 
map[string]string(carrier))
-
-       rst, err := gs.Invoke(ctxWithAttachment, method, types, vals)
+       span.SetAttributes(
+               attribute.String(spanTagMethod, req.Method),
+               attribute.StringSlice(spanTagType, types),
+               attribute.String(spanTagValues, string(finalValues)),
+       )
+
+       spanCtx = context.WithValue(spanCtx, constant.AttachmentKey, 
mergeOutboundAttachments(spanCtx, req.Attachments))
+       ctxWithAttachment := withAttachments(spanCtx)
+       rst, err := gs.Invoke(ctxWithAttachment, req.Method, types, vals)
        if err != nil {
-               // TODO statusCode I don’t know what dubbo will return when it 
times out, so I will return it directly. I will judge it when I call it.
                span.RecordError(err)
                return nil, err
        }
 
-       logger.Debugf("[dubbo-go-pixiu] dubbo client resp:%v", rst)
-
+       logger.Debugf("[dubbo-go-pixiu] dubbo invoke result:%v", rst)
        return rst, nil
 }
 
-func (dc *Client) genericArgs(req *client.Request) (any, error) {
-       values, err := dc.MapParams(req)
-       if err != nil {
-               return nil, err
+func (dc *Client) resolveFromOutbound(req *DubboOutboundRequest) 
resolvedReferSpec {
+       spec := resolvedReferSpec{
+               Interface:              req.Service,
+               Group:                  req.Group,
+               Version:                req.Version,
+               EffectiveProtocol:      req.Protocol,
+               EffectiveSerialization: req.Serialization,
+               ConsumerDefaults:       dc.resolveGlobalConsumerDefaults(),
+       }
+
+       if strings.TrimSpace(req.Address) != "" {
+               spec.Mode = "direct"
+               spec.URL = req.Protocol + "://" + req.Address
+               return spec
        }
 
-       return values, nil
+       registryIDs := make([]string, 0, len(dc.registries))
+       useNacosWarmup := false
+       for id, registry := range dc.registries {
+               registryIDs = append(registryIDs, id)
+               if registry != nil && registry.Protocol == "nacos" {
+                       useNacosWarmup = true
+               }
+       }
+       sort.Strings(registryIDs)
+
+       spec.Mode = "registry"
+       spec.RegistryIDs = registryIDs
+       spec.UseNacosWarmup = useNacosWarmup
+       return spec
 }
 
-// MapParams params mapping to api.
-func (dc *Client) MapParams(req *client.Request) (any, error) {
-       r := req.API.IntegrationRequest
-       values := newDubboTarget(r.MappingParams)
-       if dc.dubboProxyConfig != nil && dc.dubboProxyConfig.IsDefaultMap {
-               values = newDubboTarget(defaultMappingParams)
-       }
-       for _, mappingParam := range r.MappingParams {
-               source, _, err := client.ParseMapSource(mappingParam.Name)
-               if err != nil {
-                       return nil, err
+func (dc *Client) resolveGlobalConsumerDefaults() resolvedConsumerDefaults {
+       defaults := resolvedConsumerDefaults{
+               Cluster:        "failover",
+               Retries:        "3",
+               RequestTimeout: cst.DefaultReqTimeout,
+       }
+
+       if dc.dubboProxyConfig == nil {
+               return defaults
+       }
+
+       defaults.LoadBalance = dc.dubboProxyConfig.LoadBalance
+       if strings.TrimSpace(dc.dubboProxyConfig.Retries) != "" {

Review Comment:
   [P1] 这里把 retry 来源收窄成全局 DubboProxyConfig.Retries,但 
IntegrationRequest.DubboBackendConfig.Retries 字段仍保留,现有示例 
docs/sample/dubbo/dubbo-multi.md 还在按单个 API 配置 retries。旧实现会在全局 retries 为空时回退到 
irequest.Retries;现在 DubboHandler 没有把 ir.Retries 放进 
DubboOutboundRequest,resolvedReferSpec 也没有这个字段,最终 WithRetries 
只能拿到全局默认值或全局配置。结果是按 API 配的 retries 静默失效。需要把 per-route retries 传到 outbound/spec 
并在 buildReferenceOptions 中按旧优先级处理,或删除字段和文档并在配置阶段显式拒绝该配置。



##########
pkg/filter/http/remote/call.go:
##########
@@ -145,25 +131,27 @@ func (f *Filter) Decode(c *contexthttp.HttpContext) 
filter.FilterStatus {
        }
 
        typ := api.IntegrationRequest.RequestType
+       switch strings.ToLower(typ) {

Review Comment:
   [P1] 这里直接进入静态 API 的 requestType 分发,PR 同时删除了 DubboProxyConfig.AutoResolve 和 
resolver 逻辑。已有配置如果设置 auto_resolve: true,当前结构体不再接收该字段,运行时也不会再按请求路径动态解析 
application/interface/method,而是只使用已匹配的静态 
API。这个外部配置兼容性破坏没有迁移或显式报错,旧配置会静默变成另一套路由行为。需要保留兼容路径,或在配置加载阶段检测并拒绝 
auto_resolve,同时补充迁移文档和测试。



-- 
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]

Reply via email to