Alanxtl commented on PR #3364:
URL: https://github.com/apache/dubbo-go/pull/3364#issuecomment-4601531507

   
   Thanks for working on this, but I think we should not fix this by improving 
the error message.
   
   The issue is not that the error is unclear. The issue is that REST 
application-level service discovery leaks an internal metadata transport 
dependency to user code.
   
   For a REST consumer, users configure and import REST-related components:
   
   ```go
   _ "dubbo.apache.org/dubbo-go/v3/protocol/rest"
   _ "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery"
   ```
   
   But application-level discovery internally fetches metadata through:
   
   ```text
   dubbo://.../org.apache.dubbo.metadata.MetadataService
   ```
   
   So today the consumer also has to manually import:
   
   ```go
   _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
   ```
   
   That should not be required. The Dubbo protocol here is an internal 
metadata-service transport detail.
   
   I suggest changing the fix direction:
   
   1. Revert the new `GetProtocolWithError` / metadata-specific import hint 
change.
   2. Make application-level service discovery register its internal metadata 
transport dependency automatically.
   3. Add a test proving that a REST consumer using service discovery works 
without importing `protocol/dubbo`.
   
   A minimal fix may be to add a side-effect import in the service discovery 
package:
   
   ```go
   import (
       _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
   )
   ```
   
   Probably `registry/servicediscovery` is a reasonable place, because that is 
the feature path that calls `metadata.GetMetadataFromRpc(...)` and requires the 
default Dubbo metadata protocol.
   
   The expected test should cover:
   
   - provider protocol: REST;
   - registry type: application-level service discovery;
   - consumer imports REST protocol and service discovery packages;
   - consumer does **not** import `dubbo.apache.org/dubbo-go/v3/protocol/dubbo`;
   - metadata is still fetched and the REST provider URL is reconstructed 
successfully.
   
   So I would prefer fixing the dependency registration instead of returning a 
clearer error that still asks REST users to import Dubbo manually.


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