-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Support adding prefix to Dubbo service resource name in Sentinel Dubbo Adapter #859
Changes from 8 commits
11dba5e
362f326
50d2a5a
509ecf2
01bda6b
5c6600d
2f485b4
d9b98e3
23ada0e
b08859a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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 com.alibaba.csp.sentinel.adapter.dubbo.config; | ||
|
||
import com.alibaba.csp.sentinel.config.SentinelConfig; | ||
import com.alibaba.csp.sentinel.util.StringUtil; | ||
|
||
/** | ||
* <p> | ||
* Responsible for dubbo service provider, consumer attribute configuration | ||
* </p> | ||
* | ||
* @author lianglin | ||
* @since 1.7.0 | ||
*/ | ||
public final class DubboConfig { | ||
|
||
public static final String DUBBO_USE_PREFIX = "csp.sentinel.dubbo.use.prefix"; | ||
private static boolean usePrefix; | ||
private static final String TRUE_STR = "true"; | ||
|
||
public static final String DUBBO_PROVIDER_PREFIX = "csp.sentinel.dubbo.provider.prefix"; | ||
public static final String DUBBO_CONSUMER_PREFIX = "csp.sentinel.dubbo.consumer.prefix"; | ||
|
||
static { | ||
String dubboUsePrefix = SentinelConfig.getConfig(DUBBO_USE_PREFIX); | ||
if (StringUtil.isNotBlank(dubboUsePrefix) && TRUE_STR.equalsIgnoreCase(dubboUsePrefix)) { | ||
usePrefix = true; | ||
}else{ | ||
usePrefix = false; | ||
} | ||
} | ||
|
||
|
||
public static String getDubboProviderPrefix() { | ||
if (usePrefix) { | ||
return SentinelConfig.getConfig(DUBBO_PROVIDER_PREFIX); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we provide a default pattern (e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
default prefix had provided |
||
} | ||
return null; | ||
} | ||
|
||
public static String getDubboConsumerPrefix() { | ||
if (usePrefix) { | ||
return SentinelConfig.getConfig(DUBBO_CONSUMER_PREFIX); | ||
} | ||
return null; | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
csp.sentinel.dubbo.use.prefix
->csp.sentinel.dubbo.resource.use.prefix
is clearer? (though too long...)So as the following two keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config keys had modified