You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "jasondeng1997 (via GitHub)" <gi...@apache.org> on 2023/05/31 09:05:51 UTC

[GitHub] [dubbo-go] jasondeng1997 opened a new issue, #2326: Design and Implementation of dubbogo-contrib

jasondeng1997 opened a new issue, #2326:
URL: https://github.com/apache/dubbo-go/issues/2326

   This is a place for various extensions in the dubbogo ecosystem that aren't part of the dubbogo core.
   目前现状:
   1.dubbogo中各个扩展都在一个包内,导致dubbogo目前主仓库臃肿
   2.各个扩展麻烦,不易维护
   3.对于dubbogo来说,这是一次极大的优化,无论是在性能和用户体验
   1.设计方案
          dubbogo已经通过社区开发者的支持,完成了 ETCD、ZooKeeper、Eureka、Consul、Nacos、Polaris 多种服务发现模式,当然也支持注册中心模式,建立起了强大且完备的社区生态,供用户按需灵活选用。
   
         更多服务发现组件参看扩展仓库:dubbogoContrib-nacos。
          现在本身就可以插件化,dubbo-go可能要先单独设计出来一个 dubbogo-spi,dubbo插件的 interface 定义,单独拎出来 dubbogo 依赖 dubbo-spi,插件依赖 dubbo-spi,用户引入对应插件 go.mod 即可自动启用 ,以不调整用户的使用方式为最小代价实现。
         除了组件和仓库。dubbogo启动流程也可以考虑精简,做到最小可运行集合足够小,就一个rpc,其他微服务和配置可插拔。
   具体实现:
   1.设想一个经典的dubbo-go示例就是这个最小集合的rpc使用方式,纯api。
   
   2.微服务、治理、配置组装、多协议和各种能力和示例
   
   使用方式
   以 原有的注册为例
   
   
   import (
           "github.com/dubbogo/gost/log/logger"
   
           perrors "github.com/pkg/errors"
   
           api "github.com/polarismesh/polaris-go"
           "github.com/polarismesh/polaris-go/pkg/model"
   )
   
   import (
           "dubbo.apache.org/dubbo-go/v3/common"
           "dubbo.apache.org/dubbo-go/v3/common/constant"
           "dubbo.apache.org/dubbo-go/v3/common/extension"
           "dubbo.apache.org/dubbo-go/v3/registry"
           "dubbo.apache.org/dubbo-go/v3/remoting"
           "dubbo.apache.org/dubbo-go/v3/remoting/polaris"
   )
   
   const (
           RegistryConnDelay           = 3
           defaultHeartbeatIntervalSec = 5
   )
   
   func init() {
           extension.SetRegistry(constant.PolarisKey, newPolarisRegistry)
   }
   
   // newPolarisRegistry will create new instance
   func newPolarisRegistry(url *common.URL) (registry.Registry, error) {
           if err := polaris.InitSDKContext(url); err != nil {
                   return &polarisRegistry{}, err
           }
   
           providerApi, err := polaris.GetProviderAPI()
           if err != nil {
                   return nil, err
           }
   
           consumerApi, err := polaris.GetConsumerAPI()
           if err != nil {
                   return nil, err
           }
   
           pRegistry := &polarisRegistry{
                   url:          url,
                   namespace:    url.GetParam(constant.RegistryNamespaceKey, constant.PolarisDefaultNamespace),
                   provider:     providerApi,
                   consumer:     consumerApi,
                   registryUrls: make([]*common.URL, 0, 4),
                   watchers:     map[string]*PolarisServiceWatcher{},
           }
   
           return pRegistry, nil
   }
   
   type polarisRegistry struct {
           namespace    string
           url          *common.URL
           consumer     api.ConsumerAPI
           provider     api.ProviderAPI
           lock         sync.RWMutex
           registryUrls []*common.URL
           listenerLock sync.RWMutex
           watchers     map[string]*PolarisServiceWatcher
   }
   
   // Register will register the service @url to its polaris registry center.
   func (pr *polarisRegistry) Register(url *common.URL) error {
           if getCategory(url) != "providers" {
                   return nil
           }
   
           serviceName := url.Interface()
           request := createRegisterParam(url, serviceName)
           request.Namespace = pr.namespace
           resp, err := pr.provider.RegisterInstance(request)
           if err != nil {
                   return err
           }
   
           if resp.Existed {
                   logger.Warnf("instance already regist, namespace:%+v, service:%+v, host:%+v, port:%+v",
                           request.Namespace, request.Service, request.Host, request.Port)
           }
           url.SetParam(constant.PolarisInstanceID, resp.InstanceID)
   
           pr.lock.Lock()
           pr.registryUrls = append(pr.registryUrls, url)
           pr.lock.Unlock()
   
           return nil
   }
   
   dubbogo框架提供服务注册与发现的扩展,目前已经支持与业界主流注册中心对接。
   dubbogo完成了 ETCD、ZooKeeper、Eureka、Consul、Nacos、Polaris 多种服务发现模式,当然也支持 DNS 解析以及 Static IP 直连访问模式,建立起了强大且完备的社区生态,供用户按需灵活选用。
   更多服务发现组件参看扩展仓库:dubbogo-contrib/registry-nacos
   
   
   以 DNS Resolver 为例
   import (...
       dns "github.com/dubbogo-contrib/resolver-dns"
   )
       func main() {...
       client, err := echo.NewClient("echo", client.WithResolver(dns.NewDNSResolver()))
       if err != nil {
                   log.Fatal(err)}
                   ...}
   
   
   import (
           "github.com/dubbogo/gost/log/logger"
   
           perrors "github.com/pkg/errors"
   
           api "github.com/dubbogoContrib-polaris/polaris-go"
           "github.com/polarismesh/polaris-go/pkg/model"
   )
   
   import (
           "dubbo.apache.org/dubbo-go/v3/common"
           "dubbo.apache.org/dubbo-go/v3/common/constant"
           "dubbo.apache.org/dubbo-go/v3/common/extension"
           "dubbo.apache.org/dubbo-go/v3/registry"
           "dubbo.apache.org/dubbo-go/v3/remoting"
           "dubbo.apache.org/dubbo-go/v3/remoting/polaris"
   )
   Copy
   具体实现:以polaris为例,设计出以polaris为例的dubbogoContrib-polaris扩展,目前打算先实现dubbogoContrib-polaris扩展后,继续其他扩展。


-- 
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: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] mark4z commented on issue #2326: [Enhancement] Design and Implementation of dubbogo-contrib

Posted by "mark4z (via GitHub)" <gi...@apache.org>.
mark4z commented on issue #2326:
URL: https://github.com/apache/dubbo-go/issues/2326#issuecomment-1569806650

   听起来不错,不过协议层做扩展形式可能会有些困难,尤其是triple协议


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] chickenlj commented on issue #2326: [Enhancement] Design and Implementation of dubbogo-contrib

Posted by "chickenlj (via GitHub)" <gi...@apache.org>.
chickenlj commented on issue #2326:
URL: https://github.com/apache/dubbo-go/issues/2326#issuecomment-1569838655

   > 
   
   我也觉得这个模式不错,可以先往这个方向探索


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] chuntaojun commented on issue #2326: [Enhancement] Design and Implementation of dubbogo-contrib

Posted by "chuntaojun (via GitHub)" <gi...@apache.org>.
chuntaojun commented on issue #2326:
URL: https://github.com/apache/dubbo-go/issues/2326#issuecomment-1569813712

   1、能不能在不破坏现有用户的使用方式的情况下,把 dubbogo 的所有扩展点定义单独抽出来成为一个单独的 dubbogo-extensions,所有的插件实现依赖 dubbogo-extensions
   2、用户引入插件的方式就和引入 mysql 依赖一样, import _ "xxx" 即可自动启用插件,然后配置文件那一块还是一样走现在的配置


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] chickenlj commented on issue #2326: [Enhancement] Design and Implementation of dubbogo-contrib

Posted by "chickenlj (via GitHub)" <gi...@apache.org>.
chickenlj commented on issue #2326:
URL: https://github.com/apache/dubbo-go/issues/2326#issuecomment-1569846933

   @chuntaojun @jasondeng1997 @mark4z 这个 issue 还是专注在仓库组织的讨论,中间可能涉及一些插件设计机制。
   
   另外一块非常重要的,是关于 dubbo-go 启动加载流程这一块,需要分析出启动过程依赖哪些组件、详细的工作流程,咱们需要那块也同步的做起来,争取能真正在运行层面实现 dubbo-go 的轻量化,可以再起一个 issue 来单独跟进。


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org