Skip to content

Commit

Permalink
Fix: merge config-enhance
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceLiZhixin committed Sep 26, 2021
2 parents 491f156 + 26aa12b commit 1397e8b
Show file tree
Hide file tree
Showing 239 changed files with 7,689 additions and 6,879 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ remoting/zookeeper/zookeeper-4unittest/
config_center/zookeeper/zookeeper-4unittest/
registry/zookeeper/zookeeper-4unittest/
metadata/report/zookeeper/zookeeper-4unittest/
config_center/apollo/mockDubbog.properties.json

# vim stuff
*~
Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/available_cluster_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

import (
"github.com/golang/mock/gomock"

"github.com/stretchr/testify/assert"
)

Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/base_cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cluster_impl

import (
perrors "github.com/pkg/errors"

"go.uber.org/atomic"
)

Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/broadcast_cluster_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

import (
"github.com/golang/mock/gomock"

"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 2 additions & 0 deletions cluster/cluster_impl/failback_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (

import (
"github.com/golang/mock/gomock"

perrors "github.com/pkg/errors"

"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 2 additions & 0 deletions cluster/cluster_impl/failfast_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import (

import (
"github.com/golang/mock/gomock"

perrors "github.com/pkg/errors"

"github.com/stretchr/testify/assert"
)

Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/failover_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

import (
perrors "github.com/pkg/errors"

"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 2 additions & 0 deletions cluster/cluster_impl/failsafe_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import (

import (
"github.com/golang/mock/gomock"

perrors "github.com/pkg/errors"

"github.com/stretchr/testify/assert"
)

Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/forking_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

import (
"github.com/golang/mock/gomock"

"github.com/stretchr/testify/assert"
)

Expand Down
1 change: 1 addition & 0 deletions cluster/cluster_impl/zone_aware_cluster_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

import (
"github.com/golang/mock/gomock"

"github.com/stretchr/testify/assert"
)

Expand Down
3 changes: 2 additions & 1 deletion cluster/router/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

import (
perrors "github.com/pkg/errors"

"go.uber.org/atomic"
)

Expand Down Expand Up @@ -122,7 +123,7 @@ func NewRouterChain(url *common.URL) (*RouterChain, error) {

for key, routerFactory := range routerFactories {
if virtualServiceConfigByte == nil || destinationRuleConfigByte == nil {
logger.Warnf("virtual Service Config or destinationRule Confi Byte may be empty, pls check your CONF_VIRTUAL_SERVICE_FILE_PATH and CONF_DEST_RULE_FILE_PATH env is correctly point to your yaml file\n")
logger.Warnf("virtual Service ProtocolConfig or destinationRule Confi Byte may be empty, pls check your CONF_VIRTUAL_SERVICE_FILE_PATH and CONF_DEST_RULE_FILE_PATH env is correctly point to your yaml file\n")
}
r, err := routerFactory().NewPriorityRouter(virtualServiceConfigByte, destinationRuleConfigByte)
if r == nil || err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cluster/router/v3router/k8s_api/listener_handler_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
metav "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"

"k8s.io/client-go/kubernetes/scheme"

"k8s.io/client-go/rest"
)

Expand Down
3 changes: 3 additions & 0 deletions cluster/router/v3router/k8s_crd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"

"k8s.io/client-go/kubernetes/scheme"

"k8s.io/client-go/rest"

"k8s.io/client-go/tools/cache"
)

Expand Down
1 change: 1 addition & 0 deletions cluster/router/v3router/k8s_crd/listener_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"

"k8s.io/client-go/rest"
)

Expand Down
1 change: 1 addition & 0 deletions cluster/router/v3router/router_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

import (
"github.com/stretchr/testify/assert"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
3 changes: 2 additions & 1 deletion common/constant/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ const (
DEFAULT_REST_CLIENT = "resty"
DEFAULT_REST_SERVER = "go-restful"
DEFAULT_PORT = 20000
DEFAULT_METADATAPORT = 20005
DEFAULT_SERIALIZATION = HESSIAN2_SERIALIZATION
)

const (
DEFAULT_KEY = "default"
PREFIX_DEFAULT_KEY = "default."
DEFAULT_SERVICE_FILTERS = EchoFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," + GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey
DEFAULT_SERVICE_FILTERS = EchoFilterKey + "," + MetricsFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," + GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey
DEFAULT_REFERENCE_FILTERS = GracefulShutdownConsumerFilterKey
GENERIC_REFERENCE_FILTERS = GenericFilterKey
GENERIC = "$invoke"
Expand Down
12 changes: 2 additions & 10 deletions common/constant/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,8 @@ package constant

// nolint
const (
// CONF_CONSUMER_FILE_PATH ...
CONF_CONSUMER_FILE_PATH = "CONF_CONSUMER_FILE_PATH"
// CONF_PROVIDER_FILE_PATH ...
CONF_PROVIDER_FILE_PATH = "CONF_PROVIDER_FILE_PATH"
// CONFIG_FILE_ENV_KEY is key of environment variable dubbogo configure file path
CONFIG_FILE_ENV_KEY = "DUBBO_GO_CONFIG_PATH"
// APP_LOG_CONF_FILE ...
APP_LOG_CONF_FILE = "APP_LOG_CONF_FILE"
// CONF_ROUTER_FILE_PATH Specify Path variable of router config file
CONF_ROUTER_FILE_PATH = "CONF_ROUTER_FILE_PATH"
// CONF_VIRTUAL_SERVICE_FILE_PATH Specify path to Virtual service of uniform router config file
CONF_VIRTUAL_SERVICE_FILE_PATH = "CONF_VIRTUAL_SERVICE_FILE_PATH"
// CONF_DEST_RULE_FILE_PATH Specify path to destination rule of uniform router config file
CONF_DEST_RULE_FILE_PATH = "CONF_DEST_RULE_FILE_PATH"
)
97 changes: 53 additions & 44 deletions common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ const (
PORT_KEY = "port"
PROTOCOL_KEY = "protocol"
PATH_SEPARATOR = "/"
COMMA_SEPARATOR = ","
// DUBBO_KEY = "dubbo"
SSL_ENABLED_KEY = "ssl-enabled"
// PARAMS_TYPE_Key key used in pass through invoker factory, to define param type
PARAMS_TYPE_Key = "parameter-type-names"
PARAMS_TYPE_Key = "parameter-type-names"
DEFAULT_Key = "default"
METADATATYPE_KEY = "metadata-type"
)

const (
Expand All @@ -62,25 +65,26 @@ const (

// Filter Keys
const (
AccessLogFilterKey = "accesslog"
ActiveFilterKey = "active"
AuthConsumerFilterKey = "sign"
AuthProviderFilterKey = "auth"
EchoFilterKey = "echo"
ExecuteLimitFilterKey = "execute"
GenericFilterKey = "generic"
GenericServiceFilterKey = "generic_service"
GracefulShutdownProviderFilterKey = "pshutdown"
GracefulShutdownConsumerFilterKey = "cshutdown"
HystrixConsumerFilterKey = "hystrix_consumer"
HystrixProviderFilterKey = "hystrix_provider"
MetricsFilterKey = "metrics"
SeataFilterKey = "seata"
SentinelProviderFilterKey = "sentinel-provider"
SentinelConsumerFilterKey = "sentinel-consumer"
TokenFilterKey = "token"
TpsLimitFilterKey = "tps"
TracingFilterKey = "tracing"
AccessLogFilterKey = "accesslog"
ActiveFilterKey = "active"
AuthConsumerFilterKey = "sign"
AuthProviderFilterKey = "auth"
EchoFilterKey = "echo"
ExecuteLimitFilterKey = "execute"
GenericFilterKey = "generic"
GenericServiceFilterKey = "generic_service"
GracefulShutdownProviderFilterKey = "pshutdown"
GracefulShutdownConsumerFilterKey = "cshutdown"
GracefulShutdownFilterShutdownConfig = "GracefulShutdownFilterShutdownConfig"
HystrixConsumerFilterKey = "hystrix_consumer"
HystrixProviderFilterKey = "hystrix_provider"
MetricsFilterKey = "metrics"
SeataFilterKey = "seata"
SentinelProviderFilterKey = "sentinel-provider"
SentinelConsumerFilterKey = "sentinel-consumer"
TokenFilterKey = "token"
TpsLimitFilterKey = "tps"
TracingFilterKey = "tracing"
)

const (
Expand Down Expand Up @@ -121,17 +125,19 @@ const (
)

const (
REGISTRY_KEY = "registry"
REGISTRY_PROTOCOL = "registry"
ROLE_KEY = "registry.role"
REGISTRY_DEFAULT_KEY = "registry.default"
// Deprecated use CONFIG_TIMEOUT_KEY key
REGISTRY_TIMEOUT_KEY = "registry.timeout"
REGISTRY_LABEL_KEY = "label"
PREFERRED_KEY = "preferred"
ZONE_KEY = "zone"
ZONE_FORCE_KEY = "zone.force"
REGISTRY_TTL_KEY = "registry.ttl"
REGISTRY_KEY = "registry"
REGISTRY_PROTOCOL = "registry"
SERVICE_REGISTRY_PROTOCOL = "service-discovery-registry"
ROLE_KEY = "registry.role"
REGISTRY_DEFAULT_KEY = "registry.default"
REGISTRY_TIMEOUT_KEY = "registry.timeout"
REGISTRY_LABEL_KEY = "label"
PREFERRED_KEY = "preferred"
ZONE_KEY = "zone"
ZONE_FORCE_KEY = "zone.force"
REGISTRY_TTL_KEY = "registry.ttl"
SIMPLIFIED_KEY = "simplified"
NAMESPACE_KEY = "namespace"
)

const (
Expand Down Expand Up @@ -170,19 +176,22 @@ const (
)

const (
RegistryConfigPrefix = "dubbo.registries."
SingleRegistryConfigPrefix = "dubbo.registry."
ReferenceConfigPrefix = "dubbo.reference."
ServiceConfigPrefix = "dubbo.service."
ConfigBasePrefix = "dubbo.base."
RemotePrefix = "dubbo.remote."
ServiceDiscPrefix = "dubbo.service-discovery."
ProtocolConfigPrefix = "dubbo.protocols."
ProviderConfigPrefix = "dubbo.provider."
ConsumerConfigPrefix = "dubbo.consumer."
ShutdownConfigPrefix = "dubbo.shutdown."
MetadataReportPrefix = "dubbo.metadata-report."
RouterConfigPrefix = "dubbo.router."
RegistryConfigPrefix = "dubbo.registries"
ApplicationConfigPrefix = "dubbo.application"
ConfigCenterPrefix = "dubbo.config-center"
SingleRegistryConfigPrefix = "dubbo.registry"
ReferenceConfigPrefix = "dubbo.reference"
ServiceConfigPrefix = "dubbo.service"
ConfigBasePrefix = "dubbo.base"
RemotePrefix = "dubbo.remote"
ServiceDiscPrefix = "dubbo.service-discovery"
ProtocolConfigPrefix = "dubbo.protocols"
ProviderConfigPrefix = "dubbo.provider"
ConsumerConfigPrefix = "dubbo.consumer"
ShutdownConfigPrefix = "dubbo.shutdown"
MetadataReportPrefix = "dubbo.metadata-report"
RouterConfigPrefix = "dubbo.router"
LoggerConfigPrefix = "dubbo.logger"
)

const (
Expand Down
30 changes: 30 additions & 0 deletions common/extension/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 extension

var (
configs = map[string]Config{}
)

type Config interface {
Prefix() string
}

func SetConfig(c Config) {
configs[c.Prefix()] = c
}
4 changes: 3 additions & 1 deletion common/extension/config_center_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package extension

import (
"dubbo.apache.org/dubbo-go/v3/common/logger"
"dubbo.apache.org/dubbo-go/v3/config_center"
)

Expand All @@ -31,7 +32,8 @@ func SetConfigCenterFactory(name string, v func() config_center.DynamicConfigura
// GetConfigCenterFactory finds the DynamicConfigurationFactory with @name
func GetConfigCenterFactory(name string) config_center.DynamicConfigurationFactory {
if configCenterFactories[name] == nil {
panic("config center for " + name + " is not existing, make sure you have import the package.")
logger.Warn("config center for " + name + " is not existing, make sure you have import the package.")
return nil
}
return configCenterFactories[name]()
}
4 changes: 3 additions & 1 deletion common/extension/proxy_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package extension

import (
"dubbo.apache.org/dubbo-go/v3/common/logger"
"dubbo.apache.org/dubbo-go/v3/common/proxy"
)

Expand All @@ -34,7 +35,8 @@ func GetProxyFactory(name string) proxy.ProxyFactory {
name = "default"
}
if proxyFactories[name] == nil {
panic("proxy factory for " + name + " is not existing, make sure you have import the package.")
logger.Warn("proxy factory for " + name + " is not existing, make sure you have import the package.")
return nil
}
return proxyFactories[name]()
}
8 changes: 4 additions & 4 deletions common/extension/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import (
"dubbo.apache.org/dubbo-go/v3/registry"
)

var registrys = make(map[string]func(config *common.URL) (registry.Registry, error))
var registries = make(map[string]func(config *common.URL) (registry.Registry, error))

// SetRegistry sets the registry extension with @name
func SetRegistry(name string, v func(_ *common.URL) (registry.Registry, error)) {
registrys[name] = v
registries[name] = v
}

// GetRegistry finds the registry extension with @name
func GetRegistry(name string, config *common.URL) (registry.Registry, error) {
if registrys[name] == nil {
if registries[name] == nil {
panic("registry for " + name + " does not exist. please make sure that you have imported the package dubbo.apache.org/dubbo-go/v3/registry/" + name + ".")
}
return registrys[name](config)
return registries[name](config)
}
Loading

0 comments on commit 1397e8b

Please sign in to comment.