Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(adasvc): do not load adaptive service filter if not set #1735

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions common/constant/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ const (
// that put the AdaptiveServiceProviderFilterKey at the end.
DefaultServiceFilters = EchoFilterKey + "," +
MetricsFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," +
GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey + "," +
AdaptiveServiceProviderFilterKey
GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey

DefaultReferenceFilters = GracefulShutdownConsumerFilterKey
)
Expand Down
12 changes: 11 additions & 1 deletion config/provider_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/creasty/defaults"

tripleConstant "github.com/dubbogo/triple/pkg/common/constant"

perrors "github.com/pkg/errors"
)

import (
Expand All @@ -49,8 +51,10 @@ type ProviderConfig struct {
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 `default:"false" yaml:"adaptive-service" json:"adaptive-service" property:"adaptive-service"`
AdaptiveServiceVerbose bool `default:"false" yaml:"adaptive-service-verbose" json:"adaptive-service-verbose" property:"adaptive-service-verbose"`
rootConfig *RootConfig

rootConfig *RootConfig
}

func (ProviderConfig) Prefix() string {
Expand Down Expand Up @@ -97,6 +101,8 @@ func (c *ProviderConfig) Init(rc *RootConfig) error {
if err := serviceConfig.Init(rc); err != nil {
return err
}

serviceConfig.adaptiveService = c.AdaptiveService
}

for k, v := range rc.Protocols {
Expand All @@ -117,6 +123,10 @@ func (c *ProviderConfig) Init(rc *RootConfig) error {
}
// enable adaptive service verbose
if c.AdaptiveServiceVerbose {
if !c.AdaptiveService {
return perrors.Errorf("The adaptive service is disabled, " +
"adaptive service verbose should be disabled either.")
}
logger.Infof("adaptive service verbose is enabled.")
logger.Debugf("debug-level info could be shown.")
aslimiter.Verbose = true
Expand Down
10 changes: 8 additions & 2 deletions config/service_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type ServiceConfig struct {
RCProtocolsMap map[string]*ProtocolConfig
RCRegistriesMap map[string]*RegistryConfig
ProxyFactoryKey string
adaptiveService bool
unexported *atomic.Bool
exported *atomic.Bool
export bool // a flag to control whether the current service should export or not
Expand Down Expand Up @@ -378,11 +379,16 @@ func (svc *ServiceConfig) getUrlMap() url.Values {
urlMap.Set(constant.EnvironmentKey, ac.Environment)

// filter
var filters string
if svc.Filter == "" {
urlMap.Set(constant.ServiceFilterKey, constant.DefaultServiceFilters)
filters = constant.DefaultServiceFilters
} else {
urlMap.Set(constant.ServiceFilterKey, svc.Filter)
filters = svc.Filter
}
if svc.adaptiveService {
filters += fmt.Sprintf(",%s", constant.AdaptiveServiceProviderFilterKey)
}
urlMap.Set(constant.ServiceFilterKey, filters)

// filter special config
urlMap.Set(constant.AccessLogFilterKey, svc.AccessLog)
Expand Down