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

   ### Description
   #3598 - Task 17
   
   Improve the documentation for `ServiceInfo` metadata conversion:
   
   - Explain how `NewServiceInfoWithURL` projects an exported provider URL into 
service-level metadata.
   - Document parameter filtering and the compact representation of 
method-level parameters.
   - Clarify how `GetMethods` decodes the serialized method list.
   - Explain how `GetParams` restores method parameters for consumer URL 
reconstruction.
   - Document that the original URL is retained only as a local runtime 
reference and is excluded from serialization.
   
   This change only improves code comments and does not alter runtime behavior.
   
   ---
   
   Why
   
   <details>
   <summary>中文说明</summary>
   
   ### 变更说明
   
   完善 `ServiceInfo` 元数据转换相关注释:
   
   - 说明 `NewServiceInfoWithURL` 如何将 Provider URL 转换为服务级元数据。
   - 解释服务参数筛选和方法级参数的紧凑存储格式。
   - 说明 `GetMethods` 如何恢复方法列表。
   - 说明 `GetParams` 如何还原消费者 URL 所需的方法参数。
   - 明确原始 URL 仅作为本地运行时引用,不参与序列化。
   
   本次变更仅补充代码注释,不改变运行时行为。
   
   ---
   
   ### 回答: 为什么 URL 需要被抽取?
   
   这里抽取的是 MetadataService URL 的参数,不是普通业务服务 URL。
   
   核心原因是解决一个“启动信息从哪里来”的问题:
   
   ```text
   消费者需要 MetadataInfo,才能知道应用提供哪些业务服务
   消费者需要调用 MetadataService,才能拿到 MetadataInfo
   消费者需要 MetadataService URL,才能调用 MetadataService
   ```
   
   因此不能把 MetadataService URL 只放在 `MetadataInfo` 里面,否则消费者必须先拿到 metadata,才能知道去哪里拿 
metadata,形成循环依赖。
   
   解决方式就是把调用 MetadataService 所需的最小信息,直接写进注册中心的 `ServiceInstance.Metadata`。
   
   **Provider 侧**
   
   Provider 除了暴露业务接口 也会暴露框架内置接口
   假设 Provider 导出的 MetadataService URL 是:
   
   ```text
   tri://10.0.0.8:20880/org.apache.dubbo.metadata.MetadataService
       ?serialization=hessian2
       &version=1.0.0
       &application=demo-provider
       &timestamp=1786000000
   ```
   
   注册中心里的服务实例已经包含:
   
   ```text
   ServiceName = demo-provider
   Host        = 10.0.0.8
   ```
   
   所以 customizer 只需要额外发布类似:
   
   ```json
   {
     "protocol": "tri",
     "port": "20880",
     "serialization": "hessian2",
     "version": "1.0.0"
   }
   ```
   
   并存入:
   
   ```text
   dubbo.metadata-service.url-params
   ```
   
   
   **Consumer 侧**
   
   消费者从 `ServiceInstance` 获得:
   
   ```text
   Host        = 10.0.0.8
   ServiceName = demo-provider
   URL Params  = protocol、port、serialization、version
   ```
   
   </details>
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] Code has passed local testing
   - [x] 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