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

   ## What this PR does
   
   A single dubbo-go application using registry, config-center, and 
metadata-report against the **same** ZooKeeper/Nacos cluster previously opened 
separate backend client sessions for each role.
   
   The gost client pool is reference-counted and keyed by client name. However, 
each role used a different key, so the clients were never actually shared.
   
   This PR aligns the pool keys so clients targeting the same backend 
connection can be reused.
   
   ### ZooKeeper: 3 sessions → 1
   
   `metadata/report/zookeeper/report.go` previously created its client with:
   
   * a fixed name: `"zookeeperMetadataReport"`
   * `share=false`
   
   Registry and config-center already share a ZooKeeper client through 
`ValidateZookeeperClient` using:
   
   * `name=url.Location`
   * `share=true`
   
   The metadata report now follows the same convention and joins the shared 
pool under `url.Location`.
   
   Sharing is safe because the gost pool is reference-counted: `Close` only 
disconnects the underlying client when the last user releases it. The client 
also auto-reconnects, and watchers belonging to different consumers remain 
independent.
   
   ### Nacos: 3 clients → 2
   
   All three roles already used `share=true`, but each role assigned a 
different role-scoped client name:
   
   * `dubbo.registries-...`
   * `dubbo.config-center-...`
   * `dubbo.metadata-report-...`
   
   Because the client name is used as the pool key, these clients never matched 
in the pool.
   
   This PR introduces `nacosClientPoolKey()`, which derives the pool key from 
the actual **connection identity**:
   
   * endpoint
   * address
   * namespace
   * username
   * accessKey
   
   As a result, config-center and metadata-report targeting the same Nacos 
cluster now share one `NacosConfigClient`.
   
   The registry still uses a separate naming client because it is a different 
Nacos SDK client type, so the total number of clients goes from 3 to 2.
   
   The previous behavior of appending the namespace to the naming client name 
is now covered by the namespace field in the pool key.
   
   ### etcd: unchanged, follow-up
   
   gost currently has no client pool for etcd, and all consumers hold the 
concrete `*gxetcd.Client` type.
   
   Sharing etcd clients therefore requires pool support to be added to gost 
first and is left as a follow-up.
   
   ## Behavior note for reviewers
   
   For a shared pool entry, the first creator's configuration—for example, 
timeout settings—wins. Later clients using the same pool key but different 
configuration values reuse the existing client, so those later values are 
ignored.
   
   This is consistent with the existing ZooKeeper registry/config-center 
sharing behavior.
   
   ## Verification
   
   * Added unit tests covering:
   
     * ZooKeeper metadata-report uses the same pool-key convention as 
registry/config-center.
     * Nacos roles targeting the same cluster resolve to the same pool key.
     * Different Nacos namespaces resolve to different pool keys.
     * Nacos naming-client and config-client pool keys cannot collide.
   
   * `go test -race` passes for all 7 affected packages:
   
     * `metadata/report/zookeeper`
     * `metadata/report/nacos`
     * `remoting/nacos`
     * `registry/zookeeper`
     * `registry/nacos`
     * `config_center/zookeeper`
     * `config_center/nacos`
   
   * Full `make test` passes.
   
   * dubbo-go-samples E2E tests against this branch via `go mod replace` all 
pass:
   
     * `registry/zookeeper`
     * `registry/nacos`
     * `registry/etcd`
     * `config_center/zookeeper`
     * `config_center/nacos`
     * `rpc/triple/registry`
   
   * In the ZooKeeper scenarios, the client log confirms that the shared pool 
key is in effect:
   
     `new zookeeper client, name=127.0.0.1:2181`
   
     i.e. the client is keyed by `url.Location`.
   
   ### E2E screenshots
   
   <table>
     <tr>
       <td width="50%" align="center">
         <img 
src="https://github.com/user-attachments/assets/1252b698-15f6-45cf-89ff-c3952faacd42";
 width="100%" />
       </td>
       <td width="50%" align="center">
         <img 
src="https://github.com/user-attachments/assets/3118a064-fe7b-44da-92a3-03c87e77fac1";
 width="100%" />
       </td>
     </tr>
     <tr>
       <td width="50%" align="center">
         <img 
src="https://github.com/user-attachments/assets/59abff37-9e2a-48fe-ae26-024a1b00cde5";
 width="100%" />
       </td>
       <td width="50%" align="center">
         <img 
src="https://github.com/user-attachments/assets/8cf4bddf-951e-4666-8b71-bf41b1b370b3";
 width="100%" />
       </td>
     </tr>
     <tr>
       <td width="50%" align="center">
         <img 
src="https://github.com/user-attachments/assets/9160f0a7-3d3c-4402-8165-bc101faed4ba";
 width="100%" />
       </td>
       <td width="50%" align="center">
         <img 
src="https://github.com/user-attachments/assets/a81b6d69-7750-47da-bc5f-3aa5607b5586";
 width="100%" />
       </td>
     </tr>
   </table>
   
   Fixes #3573


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