You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2023/09/01 08:14:05 UTC

[dubbo-go] branch feature-triple updated: feat: add global dubbo instance conception (#2406)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch feature-triple
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/feature-triple by this push:
     new 4ceaaa9f0 feat: add global dubbo instance conception (#2406)
4ceaaa9f0 is described below

commit 4ceaaa9f05f559385e3947ad161a586e007733e3
Author: Scout Wang <33...@users.noreply.github.com>
AuthorDate: Fri Sep 1 16:13:59 2023 +0800

    feat: add global dubbo instance conception (#2406)
---
 client/compat.go                                   |   4 +-
 client/options.go                                  |   4 +-
 client/reference_config.go                         |   3 +-
 compat.go                                          | 249 +++++++++++++++++++++
 config_center/config_center_config.go              | 112 +++++++++
 dubbo.go                                           |  79 +++++++
 .../application.go => global/application_config.go |  27 ++-
 global/consumer_config.go                          | 109 +++++++++
 global/custom_config.go                            |  34 +++
 global/logger_config.go                            | 134 +++++++++++
 global/profiles_config.go                          |  35 +++
 global/provider_config.go                          | 109 +++++++++
 global/shutdown_config.go                          | 113 ++++++++++
 global/tls_config.go                               |  56 +++++
 global/tracing_config.go                           |  52 +++++
 metadata/report/metadata_report_config.go          |  80 +++++++
 metrics/metric_config.go                           |  85 +++++++
 options.go                                         | 245 ++++++++++++++++++++
 protocol/protocol_config.go                        |  70 ++++++
 registry/registry_config.go                        |  98 ++++++++
 20 files changed, 1681 insertions(+), 17 deletions(-)

diff --git a/client/compat.go b/client/compat.go
index f03592c34..f09ddb61d 100644
--- a/client/compat.go
+++ b/client/compat.go
@@ -18,15 +18,15 @@
 package client
 
 import (
-	commonCfg "dubbo.apache.org/dubbo-go/v3/common/config"
 	"dubbo.apache.org/dubbo-go/v3/config"
+	"dubbo.apache.org/dubbo-go/v3/global"
 	"dubbo.apache.org/dubbo-go/v3/registry"
 )
 
 // these functions are used to resolve circular dependencies temporarily.
 // please refer to issue(https://github.com/apache/dubbo-go/issues/2377)
 // todo(DMwangnima): remove these functions when refactoring dubbo-go
-func compatApplicationConfig(c *commonCfg.ApplicationConfig) *config.ApplicationConfig {
+func compatApplicationConfig(c *global.ApplicationConfig) *config.ApplicationConfig {
 	return &config.ApplicationConfig{
 		Organization: c.Organization,
 		Name:         c.Name,
diff --git a/client/options.go b/client/options.go
index aac320272..19063e8c7 100644
--- a/client/options.go
+++ b/client/options.go
@@ -18,11 +18,11 @@
 package client
 
 import (
+	"dubbo.apache.org/dubbo-go/v3/global"
 	"strconv"
 )
 
 import (
-	commonCfg "dubbo.apache.org/dubbo-go/v3/common/config"
 	"dubbo.apache.org/dubbo-go/v3/registry"
 )
 
@@ -190,7 +190,7 @@ func WithMeshProviderPort(port int) ReferenceOption {
 
 // ----------From ApplicationConfig----------
 
-func WithApplication(application *commonCfg.ApplicationConfig) ReferenceOption {
+func WithApplication(application *global.ApplicationConfig) ReferenceOption {
 	return func(cfg *ReferenceConfig) {
 		cfg.application = application
 	}
diff --git a/client/reference_config.go b/client/reference_config.go
index 6e52dae2b..2d53ff556 100644
--- a/client/reference_config.go
+++ b/client/reference_config.go
@@ -18,6 +18,7 @@
 package client
 
 import (
+	"dubbo.apache.org/dubbo-go/v3/global"
 	"fmt"
 	"net/url"
 	"os"
@@ -85,7 +86,7 @@ type ReferenceConfig struct {
 	adaptiveService bool
 	proxyFactory    string
 
-	application       *commonCfg.ApplicationConfig
+	application       *global.ApplicationConfig
 	applicationCompat *config.ApplicationConfig
 
 	registries       map[string]*registry.RegistryConfig
diff --git a/compat.go b/compat.go
new file mode 100644
index 000000000..30bca719b
--- /dev/null
+++ b/compat.go
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dubbo
+
+import (
+	"dubbo.apache.org/dubbo-go/v3/config"
+	"dubbo.apache.org/dubbo-go/v3/config_center"
+	"dubbo.apache.org/dubbo-go/v3/global"
+	"dubbo.apache.org/dubbo-go/v3/metadata/report"
+	"dubbo.apache.org/dubbo-go/v3/metrics"
+	"dubbo.apache.org/dubbo-go/v3/protocol"
+	"dubbo.apache.org/dubbo-go/v3/registry"
+	"go.uber.org/atomic"
+)
+
+func compatRootConfig(c *RootConfig) *config.RootConfig {
+	proCompat := make(map[string]*config.ProtocolConfig)
+	for k, v := range c.Protocols {
+		proCompat[k] = compatProtocolConfig(v)
+	}
+
+	regCompat := make(map[string]*config.RegistryConfig)
+	for k, v := range c.Registries {
+		regCompat[k] = compatRegistryConfig(v)
+	}
+
+	traCompat := make(map[string]*config.TracingConfig)
+	for k, v := range c.Tracing {
+		traCompat[k] = compatTracingConfig(v)
+	}
+
+	return &config.RootConfig{
+		Application:         compatApplicationConfig(c.Application),
+		Protocols:           proCompat,
+		Registries:          regCompat,
+		ConfigCenter:        compatCenterConfig(c.ConfigCenter),
+		MetadataReport:      compatMetadataReportConfig(c.MetadataReport),
+		Provider:            compatProviderConfig(c.Provider),
+		Consumer:            compatConsumerConfig(c.Consumer),
+		Metric:              compatMetricConfig(c.Metric),
+		Tracing:             traCompat,
+		Logger:              compatLoggerConfig(c.Logger),
+		Shutdown:            compatShutdownConfig(c.Shutdown),
+		EventDispatcherType: c.EventDispatcherType,
+		CacheFile:           c.CacheFile,
+		Custom:              compatCustomConfig(c.Custom),
+		Profiles:            compatProfilesConfig(c.Profiles),
+		TLSConfig:           compatTLSConfig(c.TLSConfig),
+	}
+}
+
+func compatApplicationConfig(c *global.ApplicationConfig) *config.ApplicationConfig {
+	return &config.ApplicationConfig{
+		Organization: c.Organization,
+		Name:         c.Name,
+		Module:       c.Module,
+		Group:        c.Group,
+		Version:      c.Version,
+		Owner:        c.Owner,
+		Environment:  c.Environment,
+		MetadataType: c.MetadataType,
+		Tag:          c.Tag,
+	}
+}
+
+func compatProtocolConfig(c *protocol.ProtocolConfig) *config.ProtocolConfig {
+	return &config.ProtocolConfig{
+		Name:                 c.Name,
+		Ip:                   c.Ip,
+		Port:                 c.Port,
+		Params:               c.Params,
+		MaxServerSendMsgSize: c.MaxServerSendMsgSize,
+		MaxServerRecvMsgSize: c.MaxServerRecvMsgSize,
+	}
+}
+
+func compatRegistryConfig(c *registry.RegistryConfig) *config.RegistryConfig {
+	return &config.RegistryConfig{
+		Protocol:          c.Protocol,
+		Timeout:           c.Timeout,
+		Group:             c.Group,
+		Namespace:         c.Namespace,
+		TTL:               c.TTL,
+		Address:           c.Address,
+		Username:          c.Username,
+		Password:          c.Password,
+		Simplified:        c.Simplified,
+		Preferred:         c.Preferred,
+		Zone:              c.Zone,
+		Weight:            c.Weight,
+		Params:            c.Params,
+		RegistryType:      c.RegistryType,
+		UseAsMetaReport:   c.UseAsMetaReport,
+		UseAsConfigCenter: c.UseAsConfigCenter,
+	}
+}
+
+func compatCenterConfig(c *config_center.CenterConfig) *config.CenterConfig {
+	return &config.CenterConfig{
+		Protocol:      c.Protocol,
+		Address:       c.Address,
+		DataId:        c.DataId,
+		Cluster:       c.Cluster,
+		Group:         c.Group,
+		Username:      c.Username,
+		Password:      c.Password,
+		Namespace:     c.Namespace,
+		AppID:         c.AppID,
+		Timeout:       c.Timeout,
+		Params:        c.Params,
+		FileExtension: c.FileExtension,
+	}
+}
+
+func compatMetadataReportConfig(c *report.MetadataReportConfig) *config.MetadataReportConfig {
+	return &config.MetadataReportConfig{
+		Protocol:  c.Protocol,
+		Address:   c.Address,
+		Username:  c.Username,
+		Password:  c.Password,
+		Timeout:   c.Timeout,
+		Group:     c.Group,
+		Namespace: c.Namespace,
+	}
+}
+
+func compatProviderConfig(c *global.ProviderConfig) *config.ProviderConfig {
+	return &config.ProviderConfig{
+		Filter:                 c.Filter,
+		Register:               c.Register,
+		RegistryIDs:            c.RegistryIDs,
+		ProtocolIDs:            c.ProtocolIDs,
+		TracingKey:             c.TracingKey,
+		ProxyFactory:           c.ProxyFactory,
+		FilterConf:             c.FilterConf,
+		ConfigType:             c.ConfigType,
+		AdaptiveService:        c.AdaptiveService,
+		AdaptiveServiceVerbose: c.AdaptiveServiceVerbose,
+	}
+}
+
+func compatConsumerConfig(c *global.ConsumerConfig) *config.ConsumerConfig {
+	return &config.ConsumerConfig{
+		Filter:          c.Filter,
+		RegistryIDs:     c.RegistryIDs,
+		Protocol:        c.Protocol,
+		RequestTimeout:  c.RequestTimeout,
+		ProxyFactory:    c.ProxyFactory,
+		Check:           c.Check,
+		AdaptiveService: c.AdaptiveService,
+		TracingKey:                     c.TracingKey,
+		FilterConf:                     c.FilterConf,
+		MaxWaitTimeForServiceDiscovery: c.MaxWaitTimeForServiceDiscovery,
+		MeshEnabled:                    c.MeshEnabled,
+	}
+}
+
+func compatMetricConfig(c *metrics.MetricConfig) *config.MetricConfig {
+	return &config.MetricConfig{
+		Mode:               c.Mode,
+		Namespace:          c.Namespace,
+		Enable:             c.Enable,
+		Port:               c.Port,
+		Path:               c.Path,
+		PushGatewayAddress: c.PushGatewayAddress,
+		SummaryMaxAge:      c.SummaryMaxAge,
+		Protocol:           c.Protocol,
+	}
+}
+
+func compatTracingConfig(c *global.TracingConfig) *config.TracingConfig {
+	return &config.TracingConfig{
+		Name:        c.Name,
+		ServiceName: c.ServiceName,
+		Address:     c.Address,
+		UseAgent:    c.UseAgent,
+	}
+}
+
+func compatLoggerConfig(c *global.LoggerConfig) *config.LoggerConfig {
+	return &config.LoggerConfig{
+		Driver:   c.Driver,
+		Level:    c.Level,
+		Format:   c.Format,
+		Appender: c.Appender,
+		File:     compatFile(c.File),
+	}
+}
+
+func compatFile(c *global.File) *config.File {
+	return &config.File{
+		Name:       c.Name,
+		MaxSize:    c.MaxSize,
+		MaxBackups: c.MaxBackups,
+		MaxAge:     c.MaxAge,
+		Compress:   c.Compress,
+	}
+}
+
+func compatShutdownConfig(c *global.ShutdownConfig) *config.ShutdownConfig {
+	cfg := &config.ShutdownConfig{
+		Timeout:                     c.Timeout,
+		StepTimeout:                 c.StepTimeout,
+		ConsumerUpdateWaitTime:      c.ConsumerUpdateWaitTime,
+		RejectRequestHandler:        c.RejectRequestHandler,
+		InternalSignal:              c.InternalSignal,
+		OfflineRequestWindowTimeout: c.OfflineRequestWindowTimeout,
+		RejectRequest:               atomic.Bool{},
+	}
+	cfg.RejectRequest.Store(c.RejectRequest.Load())
+
+	return cfg
+}
+
+func compatCustomConfig(c *global.CustomConfig) *config.CustomConfig {
+	return &config.CustomConfig{
+		ConfigMap: c.ConfigMap,
+	}
+}
+
+func compatProfilesConfig(c *global.ProfilesConfig) *config.ProfilesConfig {
+	return &config.ProfilesConfig{
+		Active: c.Active,
+	}
+}
+
+func compatTLSConfig(c *global.TLSConfig) *config.TLSConfig {
+	return &config.TLSConfig{
+		CACertFile:    c.CACertFile,
+		TLSCertFile:   c.TLSCertFile,
+		TLSKeyFile:    c.TLSKeyFile,
+		TLSServerName: c.TLSServerName,
+	}
+}
diff --git a/config_center/config_center_config.go b/config_center/config_center_config.go
new file mode 100644
index 000000000..8d5ee82f5
--- /dev/null
+++ b/config_center/config_center_config.go
@@ -0,0 +1,112 @@
+package config_center
+
+// CenterConfig is configuration for config center
+//
+// ConfigCenter also introduced concepts of namespace and group to better manage Key-Value pairs by group,
+// those configs are already built-in in many professional third-party configuration centers.
+// In most cases, namespace is used to isolate different tenants, while group is used to divide the key set from one tenant into groups.
+//
+// CenterConfig has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo
+type CenterConfig struct {
+	Protocol  string            `validate:"required" yaml:"protocol"  json:"protocol,omitempty"`
+	Address   string            `validate:"required" yaml:"address" json:"address,omitempty"`
+	DataId    string            `yaml:"data-id" json:"data-id,omitempty"`
+	Cluster   string            `yaml:"cluster" json:"cluster,omitempty"`
+	Group     string            `yaml:"group" json:"group,omitempty"`
+	Username  string            `yaml:"username" json:"username,omitempty"`
+	Password  string            `yaml:"password" json:"password,omitempty"`
+	Namespace string            `yaml:"namespace"  json:"namespace,omitempty"`
+	AppID     string            `default:"dubbo" yaml:"app-id"  json:"app-id,omitempty"`
+	Timeout   string            `default:"10s" yaml:"timeout"  json:"timeout,omitempty"`
+	Params    map[string]string `yaml:"params"  json:"parameters,omitempty"`
+
+	//FileExtension the suffix of config dataId, also the file extension of config content
+	FileExtension string `default:"yaml" yaml:"file-extension" json:"file-extension" `
+}
+
+func DefaultCenterConfig() *CenterConfig {
+	return &CenterConfig{
+		Params: make(map[string]string),
+	}
+}
+
+type CenterOption func(*CenterConfig)
+
+func WithProtocol(protocol string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Protocol = protocol
+	}
+}
+
+func WithAddress(address string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Address = address
+	}
+}
+
+func WithDataID(id string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.DataId = id
+	}
+}
+
+func WithCluster(cluster string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Cluster = cluster
+	}
+}
+
+// todo: think about changing the name of another WithGroup in this package
+func WithGroup_(group string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Group = group
+	}
+}
+
+func WithUsername(name string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Username = name
+	}
+}
+
+func WithPassword(password string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Password = password
+	}
+}
+
+func WithNamespace(namespace string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Namespace = namespace
+	}
+}
+
+func WithAppID(id string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.AppID = id
+	}
+}
+
+// todo: think about changing the name of another WithTimeout in this package
+func WithTimeout_(timeout string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.Timeout = timeout
+	}
+}
+
+func WithParams(params map[string]string) CenterOption {
+	return func(cfg *CenterConfig) {
+		if cfg.Params == nil {
+			cfg.Params = make(map[string]string)
+		}
+		for k, v := range params {
+			cfg.Params[k] = v
+		}
+	}
+}
+
+func WithFileExtension(extension string) CenterOption {
+	return func(cfg *CenterConfig) {
+		cfg.FileExtension = extension
+	}
+}
diff --git a/dubbo.go b/dubbo.go
new file mode 100644
index 000000000..3b827fea8
--- /dev/null
+++ b/dubbo.go
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dubbo
+
+import (
+	"dubbo.apache.org/dubbo-go/v3/client"
+	"github.com/pkg/errors"
+)
+
+// Instance is the highest layer conception that user could touch. It is mapped from RootConfig.
+// When users want to inject global configurations and configure common modules for client layer
+// and server layer, user-side code would be like this:
+//
+// ins, err := NewInstance()
+// cli, err := ins.NewClient()
+type Instance struct {
+	rootCfg *RootConfig
+}
+
+// NewInstance receives RootOption and initializes RootConfig. There are some processing
+// tasks during initialization.
+func NewInstance(opts ...RootOption) (*Instance, error) {
+	rootCfg := defaultRootConfig()
+	if err := rootCfg.Init(opts...); err != nil {
+		return nil, err
+	}
+
+	return &Instance{rootCfg: rootCfg}, nil
+}
+
+// NewClient is like client.NewClient, but inject configurations from RootConfig and
+// ConsumerConfig
+func (ins *Instance) NewClient(opts ...client.ReferenceOption) (*client.Client, error) {
+	if ins == nil || ins.rootCfg == nil {
+		return nil, errors.New("Instance has not been initialized")
+	}
+
+	var refOpts []client.ReferenceOption
+	conCfg := ins.rootCfg.Consumer
+	if conCfg != nil {
+		// these options come from Consumer and Root.
+		// for dubbo-go developers, referring config/ConsumerConfig.Init and config/ReferenceConfig
+		refOpts = append(refOpts,
+			client.WithFilter(conCfg.Filter),
+			client.WithRegistryIDs(conCfg.RegistryIDs),
+			client.WithProtocol(conCfg.Protocol),
+			client.WithTracingKey(conCfg.TracingKey),
+			client.WithCheck(conCfg.Check),
+			client.WithMeshEnabled(conCfg.MeshEnabled),
+			client.WithAdaptiveService(conCfg.AdaptiveService),
+			client.WithProxyFactory(conCfg.ProxyFactory),
+			client.WithApplication(ins.rootCfg.Application),
+			client.WithRegistries(ins.rootCfg.Registries),
+		)
+	}
+	refOpts = append(refOpts, opts...)
+
+	cli, err := client.NewClient(refOpts...)
+	if err != nil {
+		return nil, err
+	}
+
+	return cli, nil
+}
diff --git a/common/config/application.go b/global/application_config.go
similarity index 76%
rename from common/config/application.go
rename to global/application_config.go
index eaebd65fb..9a197e7d2 100644
--- a/common/config/application.go
+++ b/global/application_config.go
@@ -15,9 +15,7 @@
  * limitations under the License.
  */
 
-package config
-
-// todo(DMwangnima): think about the location of this type of configuration.
+package global
 
 // ApplicationConfig is a configuration for current applicationConfig, whether the applicationConfig is a provider or a consumer
 type ApplicationConfig struct {
@@ -33,57 +31,62 @@ type ApplicationConfig struct {
 	Tag          string `yaml:"tag" json:"tag,omitempty" property:"tag"`
 }
 
+func DefaultApplicationConfig() *ApplicationConfig {
+	// return a new config without setting any field means there is not any default value for initialization
+	return &ApplicationConfig{}
+}
+
 type ApplicationOption func(*ApplicationConfig)
 
-func WithOrganization(organization string) ApplicationOption {
+func WithApplication_Organization(organization string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Organization = organization
 	}
 }
 
-func WithName(name string) ApplicationOption {
+func WithApplication_Name(name string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Name = name
 	}
 }
 
-func WithModule(module string) ApplicationOption {
+func WithApplication_Module(module string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Module = module
 	}
 }
 
-func WithGroup(group string) ApplicationOption {
+func WithApplication_Group(group string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Group = group
 	}
 }
 
-func WithVersion(version string) ApplicationOption {
+func WithApplication_Version(version string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Version = version
 	}
 }
 
-func WithOwner(owner string) ApplicationOption {
+func WithApplication_Owner(owner string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Owner = owner
 	}
 }
 
-func WithEnvironment(environment string) ApplicationOption {
+func WithApplication_Environment(environment string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Environment = environment
 	}
 }
 
-func WithMetadataType(metadataType string) ApplicationOption {
+func WithApplication_MetadataType(metadataType string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.MetadataType = metadataType
 	}
 }
 
-func WithTag(tag string) ApplicationOption {
+func WithApplication_Tag(tag string) ApplicationOption {
 	return func(cfg *ApplicationConfig) {
 		cfg.Tag = tag
 	}
diff --git a/global/consumer_config.go b/global/consumer_config.go
new file mode 100644
index 000000000..d866e5d4f
--- /dev/null
+++ b/global/consumer_config.go
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+type ConsumerConfig struct {
+	Filter          string   `yaml:"filter" json:"filter,omitempty" property:"filter"`
+	RegistryIDs     []string `yaml:"registry-ids" json:"registry-ids,omitempty" property:"registry-ids"`
+	Protocol        string   `yaml:"protocol" json:"protocol,omitempty" property:"protocol"`
+	RequestTimeout  string   `default:"3s" yaml:"request-timeout" json:"request-timeout,omitempty" property:"request-timeout"`
+	ProxyFactory    string   `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"`
+	Check           bool     `yaml:"check" json:"check,omitempty" property:"check"`
+	AdaptiveService bool     `default:"false" yaml:"adaptive-service" json:"adaptive-service" property:"adaptive-service"`
+	// there is no need to configure References, it will be replaced by instance.NewClient
+	//References                     map[string]*client.ReferenceConfig `yaml:"references" json:"references,omitempty" property:"references"`
+	TracingKey                     string      `yaml:"tracing-key" json:"tracing-key" property:"tracing-key"`
+	FilterConf                     interface{} `yaml:"filter-conf" json:"filter-conf,omitempty" property:"filter-conf"`
+	MaxWaitTimeForServiceDiscovery string      `default:"3s" yaml:"max-wait-time-for-service-discovery" json:"max-wait-time-for-service-discovery,omitempty" property:"max-wait-time-for-service-discovery"`
+	MeshEnabled                    bool        `yaml:"mesh-enabled" json:"mesh-enabled,omitempty" property:"mesh-enabled"`
+}
+
+func DefaultConsumerConfig() *ConsumerConfig {
+	return &ConsumerConfig{
+		RequestTimeout: "3s",
+		Check:          true,
+	}
+}
+
+type ConsumerOption func(*ConsumerConfig)
+
+func WithConsumer_Filter(filter string) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.Filter = filter
+	}
+}
+
+func WithConsumer_RegistryIDs(ids []string) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.RegistryIDs = ids
+	}
+}
+
+func WithConsumer_Protocol(protocol string) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.Protocol = protocol
+	}
+}
+
+func WithConsumer_RequestTimeout(timeout string) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.RequestTimeout = timeout
+	}
+}
+
+func WithConsumer_ProxyFactory(factory string) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.ProxyFactory = factory
+	}
+}
+
+func WithConsumer_Check(flag bool) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.Check = flag
+	}
+}
+
+func WithConsumer_AdaptiveService(flag bool) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.AdaptiveService = flag
+	}
+}
+
+func WithConsumer_TracingKey(key string) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.TracingKey = key
+	}
+}
+
+func WithConsumer_FilterConf(conf interface{}) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.FilterConf = conf
+	}
+}
+
+func WithConsumer_MaxWaitTimeForServiceDiscovery(time string) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.MaxWaitTimeForServiceDiscovery = time
+	}
+}
+
+func WithConsumer_MeshEnabled(flag bool) ConsumerOption {
+	return func(cfg *ConsumerConfig) {
+		cfg.MeshEnabled = flag
+	}
+}
diff --git a/global/custom_config.go b/global/custom_config.go
new file mode 100644
index 000000000..e35e4067a
--- /dev/null
+++ b/global/custom_config.go
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+type CustomConfig struct {
+	ConfigMap map[string]interface{} `yaml:"config-map" json:"config-map,omitempty" property:"config-map"`
+}
+
+func DefaultCustomConfig() *CustomConfig {
+	return &CustomConfig{}
+}
+
+type CustomOption func(*CustomConfig)
+
+func WithCustom_ConfigMap(cfgMap map[string]interface{}) CustomOption {
+	return func(cfg *CustomConfig) {
+		cfg.ConfigMap = cfgMap
+	}
+}
diff --git a/global/logger_config.go b/global/logger_config.go
new file mode 100644
index 000000000..b16b8f7b6
--- /dev/null
+++ b/global/logger_config.go
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+import "github.com/creasty/defaults"
+
+type LoggerConfig struct {
+	// logger driver default zap
+	Driver string `default:"zap" yaml:"driver"`
+
+	// logger level
+	Level string `default:"info" yaml:"level"`
+
+	// logger formatter default text
+	Format string `default:"text" yaml:"format"`
+
+	// supports simultaneous file and console eg: console,file default console
+	Appender string `default:"console" yaml:"appender"`
+
+	// logger file
+	File *File `yaml:"file"`
+}
+
+type File struct {
+	// log file name default dubbo.log
+	Name string `default:"dubbo.log" yaml:"name"`
+
+	// log max size default 100Mb
+	MaxSize int `default:"100" yaml:"max-size"`
+
+	// log max backups default 5
+	MaxBackups int `default:"5" yaml:"max-backups"`
+
+	// log file max age default 3 day
+	MaxAge int `default:"3" yaml:"max-age"`
+
+	Compress *bool `default:"true" yaml:"compress"`
+}
+
+func DefaultLoggerConfig() *LoggerConfig {
+	// this logic is same as /config/logger_config.go/LoggerConfigBuilder.Build
+	cfg := &LoggerConfig{
+		File: &File{},
+	}
+	defaults.MustSet(cfg)
+
+	return cfg
+}
+
+type LoggerOption func(*LoggerConfig)
+
+func WithLogger_Driver(driver string) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		cfg.Driver = driver
+	}
+}
+
+func WithLogger_Level(level string) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		cfg.Level = level
+	}
+}
+
+func WithLogger_Format(format string) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		cfg.Format = format
+	}
+}
+
+func WithLogger_Appender(appender string) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		cfg.Appender = appender
+	}
+}
+
+func WithLogger_File_Name(name string) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		if cfg.File == nil {
+			cfg.File = new(File)
+		}
+		cfg.File.Name = name
+	}
+}
+
+func WithLogger_File_MaxSize(size int) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		if cfg.File == nil {
+			cfg.File = new(File)
+		}
+		cfg.File.MaxSize = size
+	}
+}
+
+func WithLogger_File_MaxBackups(backups int) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		if cfg.File == nil {
+			cfg.File = new(File)
+		}
+		cfg.File.MaxBackups = backups
+	}
+}
+
+func WithLogger_File_MaxAge(age int) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		if cfg.File == nil {
+			cfg.File = new(File)
+		}
+		cfg.File.MaxAge = age
+	}
+}
+
+func WithLogger_File_Compress(flag bool) LoggerOption {
+	return func(cfg *LoggerConfig) {
+		if cfg.File == nil {
+			cfg.File = new(File)
+		}
+		cfg.File.Compress = &flag
+	}
+}
diff --git a/global/profiles_config.go b/global/profiles_config.go
new file mode 100644
index 000000000..eb7185409
--- /dev/null
+++ b/global/profiles_config.go
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+type ProfilesConfig struct {
+	// active profiles
+	Active string
+}
+
+func DefaultProfilesConfig() *ProfilesConfig {
+	return nil
+}
+
+type ProfilesOption func(*ProfilesConfig)
+
+func WithProfiles_Active(active string) ProfilesOption {
+	return func(cfg *ProfilesConfig) {
+		cfg.Active = active
+	}
+}
diff --git a/global/provider_config.go b/global/provider_config.go
new file mode 100644
index 000000000..3edc5e054
--- /dev/null
+++ b/global/provider_config.go
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+// ProviderConfig is the default configuration of service provider
+type ProviderConfig struct {
+	Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
+	// Deprecated Register whether registration is required
+	Register bool `yaml:"register" json:"register" property:"register"`
+	// RegistryIDs is registry ids list
+	RegistryIDs []string `yaml:"registry-ids" json:"registry-ids" property:"registry-ids"`
+	// protocol
+	ProtocolIDs []string `yaml:"protocol-ids" json:"protocol-ids" property:"protocol-ids"`
+	// TracingKey is tracing ids list
+	TracingKey string `yaml:"tracing-key" json:"tracing-key" property:"tracing-key"`
+	// there is no need to configure Services
+	//// Services services
+	//Services     map[string]*server.ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"`
+	ProxyFactory string            `default:"default" yaml:"proxy" json:"proxy,omitempty" property:"proxy"`
+	FilterConf   interface{}       `yaml:"filter_conf" json:"filter_conf,omitempty" property:"filter_conf"`
+	ConfigType   map[string]string `yaml:"config_type" json:"config_type,omitempty" property:"config_type"`
+	// adaptive service
+	AdaptiveService        bool `yaml:"adaptive-service" json:"adaptive-service" property:"adaptive-service"`
+	AdaptiveServiceVerbose bool `yaml:"adaptive-service-verbose" json:"adaptive-service-verbose" property:"adaptive-service-verbose"`
+}
+
+func DefaultProviderConfig() *ProviderConfig {
+	return &ProviderConfig{
+		RegistryIDs: make([]string, 8),
+		ProtocolIDs: make([]string, 8),
+	}
+}
+
+type ProviderOption func(*ProviderConfig)
+
+func WithProvider_Filter(filter string) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.Filter = filter
+	}
+}
+
+func WithProvider_Register(flag bool) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.Register = flag
+	}
+}
+
+func WithProvider_RegistryIDs(ids []string) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.RegistryIDs = ids
+	}
+}
+
+func WithProvider_ProtocolIDs(ids []string) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.ProtocolIDs = ids
+	}
+}
+
+func WithProvider_TracingKey(key string) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.TracingKey = key
+	}
+}
+
+func WithProvider_ProxyFactory(factory string) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.ProxyFactory = factory
+	}
+}
+
+func WithProvider_FilterConf(conf []interface{}) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.FilterConf = conf
+	}
+}
+
+func WithProvider_ConfigType(typ map[string]string) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.ConfigType = typ
+	}
+}
+
+func WithProvider_AdaptiveService(flag bool) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.AdaptiveService = flag
+	}
+}
+
+func WithProvider_AdaptiveServiceVerbose(flag bool) ProviderOption {
+	return func(cfg *ProviderConfig) {
+		cfg.AdaptiveServiceVerbose = flag
+	}
+}
diff --git a/global/shutdown_config.go b/global/shutdown_config.go
new file mode 100644
index 000000000..bff990b78
--- /dev/null
+++ b/global/shutdown_config.go
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+import (
+	"github.com/creasty/defaults"
+	"go.uber.org/atomic"
+)
+
+// ShutdownConfig is used as configuration for graceful shutdown
+type ShutdownConfig struct {
+	/*
+	 * Total timeout. Even though we don't release all resources,
+	 * the applicationConfig will shutdown if the costing time is over this configuration. The unit is ms.
+	 * default value is 60 * 1000 ms = 1 minutes
+	 * In general, it should be bigger than 3 * StepTimeout.
+	 */
+	Timeout string `default:"60s" yaml:"timeout" json:"timeout,omitempty" property:"timeout"`
+	/*
+	 * the timeout on each step. You should evaluate the response time of request
+	 * and the time that client noticed that server shutdown.
+	 * For example, if your client will received the notification within 10s when you start to close server,
+	 * and the 99.9% requests will return response in 2s, so the StepTimeout will be bigger than(10+2) * 1000ms,
+	 * maybe (10 + 2*3) * 1000ms is a good choice.
+	 */
+	StepTimeout string `default:"3s" yaml:"step-timeout" json:"step.timeout,omitempty" property:"step.timeout"`
+
+	/*
+	 * ConsumerUpdateWaitTime means when provider is shutting down, after the unregister, time to wait for client to
+	 * update invokers. During this time, incoming invocation can be treated normally.
+	 */
+	ConsumerUpdateWaitTime string `default:"3s" yaml:"consumer-update-wait-time" json:"consumerUpdate.waitTIme,omitempty" property:"consumerUpdate.waitTIme"`
+	// when we try to shutdown the applicationConfig, we will reject the new requests. In most cases, you don't need to configure this.
+	RejectRequestHandler string `yaml:"reject-handler" json:"reject-handler,omitempty" property:"reject_handler"`
+	// internal listen kill signal,the default is true.
+	InternalSignal *bool `default:"true" yaml:"internal-signal" json:"internal.signal,omitempty" property:"internal.signal"`
+	// offline request window length
+	OfflineRequestWindowTimeout string `yaml:"offline-request-window-timeout" json:"offlineRequestWindowTimeout,omitempty" property:"offlineRequestWindowTimeout"`
+	// true -> new request will be rejected.
+	RejectRequest atomic.Bool
+	// active invocation
+	ConsumerActiveCount atomic.Int32
+	ProviderActiveCount atomic.Int32
+
+	// provider last received request timestamp
+	ProviderLastReceivedRequestTime atomic.Time
+}
+
+func DefaultShutdownConfig() *ShutdownConfig {
+	cfg := &ShutdownConfig{}
+	defaults.MustSet(cfg)
+
+	return cfg
+}
+
+type ShutdownOption func(*ShutdownConfig)
+
+func WithShutdown_Timeout(timeout string) ShutdownOption {
+	return func(cfg *ShutdownConfig) {
+		cfg.Timeout = timeout
+	}
+}
+
+func WithShutdown_StepTimeout(timeout string) ShutdownOption {
+	return func(cfg *ShutdownConfig) {
+		cfg.StepTimeout = timeout
+	}
+}
+
+func WithShutdown_ConsumerUpdateWaitTime(duration string) ShutdownOption {
+	return func(cfg *ShutdownConfig) {
+		cfg.ConsumerUpdateWaitTime = duration
+	}
+}
+
+func WithShutdown_RejectRequestHandler(handler string) ShutdownOption {
+	return func(cfg *ShutdownConfig) {
+		cfg.RejectRequestHandler = handler
+	}
+}
+
+func WithShutdown_InternalSignal(signal bool) ShutdownOption {
+	return func(cfg *ShutdownConfig) {
+		cfg.InternalSignal = &signal
+	}
+}
+
+func WithShutdown_OfflineRequestWindowTimeout(timeout string) ShutdownOption {
+	return func(cfg *ShutdownConfig) {
+		cfg.OfflineRequestWindowTimeout = timeout
+	}
+}
+
+func WithShutdown_RejectRequest(flag bool) ShutdownOption {
+	return func(cfg *ShutdownConfig) {
+		cfg.RejectRequest.Store(flag)
+	}
+}
diff --git a/global/tls_config.go b/global/tls_config.go
new file mode 100644
index 000000000..84f79bdd2
--- /dev/null
+++ b/global/tls_config.go
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+// TLSConfig tls config
+type TLSConfig struct {
+	CACertFile    string `yaml:"ca-cert-file" json:"ca-cert-file" property:"ca-cert-file"`
+	TLSCertFile   string `yaml:"tls-cert-file" json:"tls-cert-file" property:"tls-cert-file"`
+	TLSKeyFile    string `yaml:"tls-key-file" json:"tls-key-file" property:"tls-key-file"`
+	TLSServerName string `yaml:"tls-server-name" json:"tls-server-name" property:"tls-server-name"`
+}
+
+func DefaultTLSConfig() *TLSConfig {
+	return nil
+}
+
+type TLSOption func(*TLSConfig)
+
+func WithTLS_CACertFile(file string) TLSOption {
+	return func(cfg *TLSConfig) {
+		cfg.CACertFile = file
+	}
+}
+
+func WithTLS_TLSCertFile(file string) TLSOption {
+	return func(cfg *TLSConfig) {
+		cfg.TLSCertFile = file
+	}
+}
+
+func WithTLS_TLSKeyFile(file string) TLSOption {
+	return func(cfg *TLSConfig) {
+		cfg.TLSKeyFile = file
+	}
+}
+
+func WithTLS_TLSServerName(name string) TLSOption {
+	return func(cfg *TLSConfig) {
+		cfg.TLSServerName = name
+	}
+}
diff --git a/global/tracing_config.go b/global/tracing_config.go
new file mode 100644
index 000000000..d6d453ffb
--- /dev/null
+++ b/global/tracing_config.go
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package global
+
+// TracingConfig is the configuration of the tracing.
+type TracingConfig struct {
+	Name        string `default:"jaeger" yaml:"name" json:"name,omitempty" property:"name"` // jaeger or zipkin(todo)
+	ServiceName string `yaml:"serviceName" json:"serviceName,omitempty" property:"serviceName"`
+	Address     string `yaml:"address" json:"address,omitempty" property:"address"`
+	UseAgent    *bool  `default:"false" yaml:"use-agent" json:"use-agent,omitempty" property:"use-agent"`
+}
+
+type TracingOption func(*TracingConfig)
+
+func WithTracing_Name(name string) TracingOption {
+	return func(cfg *TracingConfig) {
+		cfg.Name = name
+	}
+}
+
+func WithTracing_ServiceName(name string) TracingOption {
+	return func(cfg *TracingConfig) {
+		cfg.ServiceName = name
+	}
+}
+
+func WithTracing_Address(address string) TracingOption {
+	return func(cfg *TracingConfig) {
+		cfg.Address = address
+	}
+}
+
+func WithTracing_UseAgent(flag bool) TracingOption {
+	return func(cfg *TracingConfig) {
+		cfg.UseAgent = &flag
+	}
+}
diff --git a/metadata/report/metadata_report_config.go b/metadata/report/metadata_report_config.go
new file mode 100644
index 000000000..1531605ab
--- /dev/null
+++ b/metadata/report/metadata_report_config.go
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package report
+
+// MetadataReportConfig is app level configuration
+type MetadataReportConfig struct {
+	Protocol  string `required:"true"  yaml:"protocol"  json:"protocol,omitempty"`
+	Address   string `required:"true" yaml:"address" json:"address"`
+	Username  string `yaml:"username" json:"username,omitempty"`
+	Password  string `yaml:"password" json:"password,omitempty"`
+	Timeout   string `yaml:"timeout" json:"timeout,omitempty"`
+	Group     string `yaml:"group" json:"group,omitempty"`
+	Namespace string `yaml:"namespace" json:"namespace,omitempty"`
+	// metadataType of this application is defined by application config, local or remote
+	metadataType string
+}
+
+func DefaultMetadataReportConfig() *MetadataReportConfig {
+	// return a new config without setting any field means there is not any default value for initialization
+	return &MetadataReportConfig{}
+}
+
+type MetadataReportOption func(*MetadataReportConfig)
+
+func WithProtocol(protocol string) MetadataReportOption {
+	return func(cfg *MetadataReportConfig) {
+		cfg.Protocol = protocol
+	}
+}
+
+func WithAddress(address string) MetadataReportOption {
+	return func(cfg *MetadataReportConfig) {
+		cfg.Address = address
+	}
+}
+
+func WithUsername(username string) MetadataReportOption {
+	return func(cfg *MetadataReportConfig) {
+		cfg.Username = username
+	}
+}
+
+func WithPassword(password string) MetadataReportOption {
+	return func(cfg *MetadataReportConfig) {
+		cfg.Password = password
+	}
+}
+
+func WithTimeout(timeout string) MetadataReportOption {
+	return func(cfg *MetadataReportConfig) {
+		cfg.Timeout = timeout
+	}
+}
+
+func WithGroup(group string) MetadataReportOption {
+	return func(cfg *MetadataReportConfig) {
+		cfg.Group = group
+	}
+}
+
+func WithNamespace(namespace string) MetadataReportOption {
+	return func(cfg *MetadataReportConfig) {
+		cfg.Namespace = namespace
+	}
+}
diff --git a/metrics/metric_config.go b/metrics/metric_config.go
new file mode 100644
index 000000000..03e7ff7d0
--- /dev/null
+++ b/metrics/metric_config.go
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package metrics
+
+// MetricConfig This is the config struct for all metrics implementation
+type MetricConfig struct {
+	Mode               string `default:"pull" yaml:"mode" json:"mode,omitempty" property:"mode"` // push or pull,
+	Namespace          string `default:"dubbo" yaml:"namespace" json:"namespace,omitempty" property:"namespace"`
+	Enable             *bool  `default:"false" yaml:"enable" json:"enable,omitempty" property:"enable"`
+	Port               string `default:"9090" yaml:"port" json:"port,omitempty" property:"port"`
+	Path               string `default:"/metrics" yaml:"path" json:"path,omitempty" property:"path"`
+	PushGatewayAddress string `default:"" yaml:"push-gateway-address" json:"push-gateway-address,omitempty" property:"push-gateway-address"`
+	SummaryMaxAge      int64  `default:"600000000000" yaml:"summary-max-age" json:"summary-max-age,omitempty" property:"summary-max-age"`
+	Protocol           string `default:"prometheus" yaml:"protocol" json:"protocol,omitempty" property:"protocol"`
+}
+
+func DefaultMetricConfig() *MetricConfig {
+	// return a new config without setting any field means there is not any default value for initialization
+	return &MetricConfig{}
+}
+
+type MetricOption func(*MetricConfig)
+
+func WithMode(mode string) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.Mode = mode
+	}
+}
+
+func WithNamespace(namespace string) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.Namespace = namespace
+	}
+}
+
+func WithEnable(enable bool) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.Enable = &enable
+	}
+}
+
+func WithPort(port string) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.Port = port
+	}
+}
+
+func WithPath(path string) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.Path = path
+	}
+}
+
+func WithPushGatewayAddress(address string) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.PushGatewayAddress = address
+	}
+}
+
+func WithSummaryMaxAge(age int64) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.SummaryMaxAge = age
+	}
+}
+
+func WithProtocol(protocol string) MetricOption {
+	return func(cfg *MetricConfig) {
+		cfg.Protocol = protocol
+	}
+}
diff --git a/options.go b/options.go
new file mode 100644
index 000000000..550a7c049
--- /dev/null
+++ b/options.go
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dubbo
+
+import (
+	"dubbo.apache.org/dubbo-go/v3/config_center"
+	"dubbo.apache.org/dubbo-go/v3/global"
+	"dubbo.apache.org/dubbo-go/v3/metadata/report"
+	"dubbo.apache.org/dubbo-go/v3/metrics"
+	"dubbo.apache.org/dubbo-go/v3/protocol"
+	"dubbo.apache.org/dubbo-go/v3/registry"
+)
+
+type RootConfig struct {
+	Application         *global.ApplicationConfig           `validate:"required" yaml:"application" json:"application,omitempty" property:"application"`
+	Protocols           map[string]*protocol.ProtocolConfig `validate:"required" yaml:"protocols" json:"protocols" property:"protocols"`
+	Registries          map[string]*registry.RegistryConfig `yaml:"registries" json:"registries" property:"registries"`
+	ConfigCenter        *config_center.CenterConfig         `yaml:"config-center" json:"config-center,omitempty"`
+	MetadataReport      *report.MetadataReportConfig        `yaml:"metadata-report" json:"metadata-report,omitempty" property:"metadata-report"`
+	Provider            *global.ProviderConfig              `yaml:"provider" json:"provider" property:"provider"`
+	Consumer            *global.ConsumerConfig              `yaml:"consumer" json:"consumer" property:"consumer"`
+	Metric              *metrics.MetricConfig               `yaml:"metrics" json:"metrics,omitempty" property:"metrics"`
+	Tracing             map[string]*global.TracingConfig    `yaml:"tracing" json:"tracing,omitempty" property:"tracing"`
+	Logger              *global.LoggerConfig                `yaml:"logger" json:"logger,omitempty" property:"logger"`
+	Shutdown            *global.ShutdownConfig              `yaml:"shutdown" json:"shutdown,omitempty" property:"shutdown"`
+	Router              []*RouterConfig                     `yaml:"router" json:"router,omitempty" property:"router"`
+	EventDispatcherType string                              `default:"direct" yaml:"event-dispatcher-type" json:"event-dispatcher-type,omitempty"`
+	CacheFile           string                              `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"`
+	Custom              *global.CustomConfig                `yaml:"custom" json:"custom,omitempty" property:"custom"`
+	Profiles            *global.ProfilesConfig              `yaml:"profiles" json:"profiles,omitempty" property:"profiles"`
+	TLSConfig           *global.TLSConfig                   `yaml:"tls_config" json:"tls_config,omitempty" property:"tls_config"`
+}
+
+func defaultRootConfig() *RootConfig {
+	return &RootConfig{
+		Application:    global.DefaultApplicationConfig(),
+		Protocols:      make(map[string]*protocol.ProtocolConfig),
+		Registries:     make(map[string]*registry.RegistryConfig),
+		ConfigCenter:   config_center.DefaultCenterConfig(),
+		MetadataReport: report.DefaultMetadataReportConfig(),
+		Provider:       global.DefaultProviderConfig(),
+		Consumer:       global.DefaultConsumerConfig(),
+		Metric:         metrics.DefaultMetricConfig(),
+		Tracing:        make(map[string]*global.TracingConfig),
+		Logger:         global.DefaultLoggerConfig(),
+		Shutdown:       global.DefaultShutdownConfig(),
+		Custom:         global.DefaultCustomConfig(),
+		Profiles:       global.DefaultProfilesConfig(),
+		TLSConfig:      global.DefaultTLSConfig(),
+	}
+}
+
+func (rc *RootConfig) Init(opts ...RootOption) error {
+	for _, opt := range opts {
+		opt(rc)
+	}
+
+	rcCompat := compatRootConfig(rc)
+	if err := rcCompat.Init(); err != nil {
+		return err
+	}
+
+	return nil
+}
+
+type RootOption func(*RootConfig)
+
+func WithApplication(opts ...global.ApplicationOption) RootOption {
+	appCfg := new(global.ApplicationConfig)
+	for _, opt := range opts {
+		opt(appCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.Application = appCfg
+	}
+}
+
+func WithProtocol(key string, opts ...protocol.ProtocolOption) RootOption {
+	proCfg := new(protocol.ProtocolConfig)
+	for _, opt := range opts {
+		opt(proCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		if cfg.Protocols == nil {
+			cfg.Protocols = make(map[string]*protocol.ProtocolConfig)
+		}
+		cfg.Protocols[key] = proCfg
+	}
+}
+
+func WithRegistry(key string, opts ...registry.RegistryOption) RootOption {
+	regCfg := new(registry.RegistryConfig)
+	for _, opt := range opts {
+		opt(regCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		if cfg.Registries == nil {
+			cfg.Registries = make(map[string]*registry.RegistryConfig)
+		}
+		cfg.Registries[key] = regCfg
+	}
+}
+
+func WithConfigCenter(opts ...config_center.CenterOption) RootOption {
+	ccCfg := new(config_center.CenterConfig)
+	for _, opt := range opts {
+		opt(ccCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.ConfigCenter = ccCfg
+	}
+}
+
+func WithMetadataReport(opts ...report.MetadataReportOption) RootOption {
+	mrCfg := new(report.MetadataReportConfig)
+	for _, opt := range opts {
+		opt(mrCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.MetadataReport = mrCfg
+	}
+}
+
+func WithConsumer(opts ...global.ConsumerOption) RootOption {
+	conCfg := new(global.ConsumerConfig)
+	for _, opt := range opts {
+		opt(conCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.Consumer = conCfg
+	}
+}
+
+func WithMetric(opts ...metrics.MetricOption) RootOption {
+	meCfg := new(metrics.MetricConfig)
+	for _, opt := range opts {
+		opt(meCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.Metric = meCfg
+	}
+}
+
+func WithTracing(key string, opts ...global.TracingOption) RootOption {
+	traCfg := new(global.TracingConfig)
+	for _, opt := range opts {
+		opt(traCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		if cfg.Tracing == nil {
+			cfg.Tracing = make(map[string]*global.TracingConfig)
+		}
+		cfg.Tracing[key] = traCfg
+	}
+}
+
+func WithLogger(opts ...global.LoggerOption) RootOption {
+	logCfg := new(global.LoggerConfig)
+	for _, opt := range opts {
+		opt(logCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.Logger = logCfg
+	}
+}
+
+func WithShutdown(opts ...global.ShutdownOption) RootOption {
+	sdCfg := new(global.ShutdownConfig)
+	for _, opt := range opts {
+		opt(sdCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.Shutdown = sdCfg
+	}
+}
+
+func WithEventDispatcherType(typ string) RootOption {
+	return func(cfg *RootConfig) {
+		cfg.EventDispatcherType = typ
+	}
+}
+
+func WithCacheFile(file string) RootOption {
+	return func(cfg *RootConfig) {
+		cfg.CacheFile = file
+	}
+}
+
+func WithCustom(opts ...global.CustomOption) RootOption {
+	cusCfg := new(global.CustomConfig)
+	for _, opt := range opts {
+		opt(cusCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.Custom = cusCfg
+	}
+}
+
+func WithProfiles(opts ...global.ProfilesOption) RootOption {
+	proCfg := new(global.ProfilesConfig)
+	for _, opt := range opts {
+		opt(proCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.Profiles = proCfg
+	}
+}
+
+func WithTLS(opts ...global.TLSOption) RootOption {
+	tlsCfg := new(global.TLSConfig)
+	for _, opt := range opts {
+		opt(tlsCfg)
+	}
+
+	return func(cfg *RootConfig) {
+		cfg.TLSConfig = tlsCfg
+	}
+}
diff --git a/protocol/protocol_config.go b/protocol/protocol_config.go
new file mode 100644
index 000000000..6b39061e9
--- /dev/null
+++ b/protocol/protocol_config.go
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package protocol
+
+// ProtocolConfig is protocol configuration
+type ProtocolConfig struct {
+	Name   string      `default:"dubbo" validate:"required" yaml:"name" json:"name,omitempty" property:"name"`
+	Ip     string      `yaml:"ip"  json:"ip,omitempty" property:"ip"`
+	Port   string      `default:"20000" yaml:"port" json:"port,omitempty" property:"port"`
+	Params interface{} `yaml:"params" json:"params,omitempty" property:"params"`
+
+	// MaxServerSendMsgSize max size of server send message, 1mb=1000kb=1000000b 1mib=1024kb=1048576b.
+	// more detail to see https://pkg.go.dev/github.com/dustin/go-humanize#pkg-constants
+	MaxServerSendMsgSize string `yaml:"max-server-send-msg-size" json:"max-server-send-msg-size,omitempty"`
+	// MaxServerRecvMsgSize max size of server receive message
+	MaxServerRecvMsgSize string `default:"4mib" yaml:"max-server-recv-msg-size" json:"max-server-recv-msg-size,omitempty"`
+}
+
+type ProtocolOption func(*ProtocolConfig)
+
+func WithName(name string) ProtocolOption {
+	return func(cfg *ProtocolConfig) {
+		cfg.Name = name
+	}
+}
+
+func WithIp(ip string) ProtocolOption {
+	return func(cfg *ProtocolConfig) {
+		cfg.Ip = ip
+	}
+}
+
+func WithPort(port string) ProtocolOption {
+	return func(cfg *ProtocolConfig) {
+		cfg.Port = port
+	}
+}
+
+func WithParam(param interface{}) ProtocolOption {
+	return func(cfg *ProtocolConfig) {
+		cfg.Params = param
+	}
+}
+
+func WithMaxServerSendMsgSize(size string) ProtocolOption {
+	return func(cfg *ProtocolConfig) {
+		cfg.MaxServerSendMsgSize = size
+	}
+}
+
+func WithMaxServerRecvMsgSize(size string) ProtocolOption {
+	return func(cfg *ProtocolConfig) {
+		cfg.MaxServerRecvMsgSize = size
+	}
+}
diff --git a/registry/registry_config.go b/registry/registry_config.go
index ae1ac66b0..468c1fe51 100644
--- a/registry/registry_config.go
+++ b/registry/registry_config.go
@@ -40,3 +40,101 @@ type RegistryConfig struct {
 	UseAsMetaReport   bool              `default:"true" yaml:"use-as-meta-report" json:"use-as-meta-report,omitempty" property:"use-as-meta-report"`
 	UseAsConfigCenter bool              `default:"true" yaml:"use-as-config-center" json:"use-as-config-center,omitempty" property:"use-as-config-center"`
 }
+
+type RegistryOption func(*RegistryConfig)
+
+func WithProtocol(protocol string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Protocol = protocol
+	}
+}
+
+func WithTimeout(timeout string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Timeout = timeout
+	}
+}
+
+func WithGroup(group string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Group = group
+	}
+}
+
+func WithNamespace(namespace string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Namespace = namespace
+	}
+}
+
+func WithTTL(ttl string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.TTL = ttl
+	}
+}
+
+func WithAddress(address string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Address = address
+	}
+}
+
+func WithUsername(name string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Username = name
+	}
+}
+
+func WithPassword(password string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Password = password
+	}
+}
+
+func WithSimplified(flag bool) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Simplified = flag
+	}
+}
+
+func WithPreferred(flag bool) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Preferred = flag
+	}
+}
+
+func WithZone(zone string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Zone = zone
+	}
+}
+
+func WithWeight(weight int64) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Weight = weight
+	}
+}
+
+func WithParams(params map[string]string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.Params = params
+	}
+}
+
+func WithRegistryType(typ string) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.RegistryType = typ
+	}
+}
+
+func WithUseAsMetaReport(flag bool) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.UseAsMetaReport = flag
+	}
+}
+
+func WithUseAsConfigCenter(flag bool) RegistryOption {
+	return func(cfg *RegistryConfig) {
+		cfg.UseAsConfigCenter = flag
+	}
+}