MoChengqian opened a new pull request, #3277:
URL: https://github.com/apache/dubbo-go/pull/3277

   ### Description
   本PR解决issue (#3162),优雅解决了Go与Java互通时方法名大小写问题.
        
   此issue的临时方案:PR #3154 是通过在 ServiceInfo.Methods 里额外追加一个 SwapCaseFirstRune 
的别名方法副本,让同一个 RPC 同时注册原始 path 和大小写变体 path,从而绕过 http.ServeMux 的精确匹配限制。但是该方案不够优雅.
   
   于是本次PR新建了一个内部路由 methodRouteMux,  它的目的,是把大小写兼容从上层元数据/双注册,收敛到 Triple 
传输层内部处理,一切大小写兼容交给新 mux 处理.
   
   mux的逻辑详见 protocol/triple/triple_protocol/method_route_mux.go
        这是一个包内的路由组件,用来替代原来的 http.ServeMux。
        它先走精确匹配,精确不命中时,按首字母小写降级查找 
        例如:
         - /Svc/SayHello
         - /Svc/sayHello
           会路由到同一个 handler。
   还删掉了上层显式注册 alias 路由的做法,也就是不再在 protocol/triple/server.go 
里把一个方法注册两遍(原名一遍,swap-case 一遍),而是只注册 canonical path,一切大小写兼容交给新 mux 处理。
   
   本次PR优雅点在于,它没有再去“伪造一批新方法”或污染 ServiceInfo,而是只在 Triple 传输层包了一层 
methodRouteMux:先按原始 path 精确匹配,精确不命中时再仅对最后一个方法段做首字母大小写 fallback,把 SayHello/
     sayHello 路由到同一个 handler,同时 registry、reflection、方法元数据里仍然只保留一份 canonical 方法。
   
   此外,之前的PR #3154 存在问题 : 在元数据层解决了传输层的问题. 他在 enhanceServiceInfo 里给 
ServiceInfo.Methods 追加了首字母互换的方法副本。虽然路由通了,但 ServiceInfo 是全局元数据模型,注册中心和 gRPC 
reflection 都会看到重复方法。本次PR把大小写兼容逻辑从 ServiceInfo(元数据层)下沉到 Triple 协议的 HTTP 
路由层,已经修复了问题.
   ### Checklist
    [✔] I confirm the target branch is `develop`
    [ ✔] Code has passed local testing
    [ ✔] I have added tests that prove my fix is effective or that my feature 
works
   


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