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
增加对properties文件的支持: ali-sentinel.properties #72
Conversation
VanXD seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Codecov Report
@@ Coverage Diff @@
## master #72 +/- ##
=============================================
+ Coverage 41.71% 52.79% +11.07%
+ Complexity 1376 911 -465
=============================================
Files 304 150 -154
Lines 8764 5097 -3667
Branches 1182 733 -449
=============================================
- Hits 3656 2691 -965
+ Misses 4662 2083 -2579
+ Partials 446 323 -123
Continue to review full report at Codecov.
|
这个license/cla Pending就没法解决了么。。我已经去details里签署过了。 |
请查看对应 GitHub 账号是否正确,包括产生的提交记录的 email 需要与当前 GitHub 账号一致。貌似你的提交记录里 email 和当前账号不对应。 === Please make sure that the email of your commits matches the email of your GitHub account. |
非常感谢, 我换了帐号过来. |
@@ -34,6 +34,7 @@ | |||
*/ | |||
public class SentinelConfig { | |||
|
|||
private static final String DEFAULT_PROPERTIES_NAME = "ali-sentinel"; |
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.
sentinel is better
import java.net.URL; | ||
import java.util.*; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* The universal config of Courier. The config is retrieved from | ||
* {@code ${user.home}/logs/csp/${appName}.properties} by default. |
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.
classpath is better.
sentinel-core/src/main/java/com/alibaba/csp/sentinel/util/ClassHelper.java
Show resolved
Hide resolved
add some tests |
参考了dubbo那边对config进行的测试 === reference config tests from dubbo. |
@@ -60,34 +60,15 @@ private AppNameUtil() { | |||
RecordLog.info("App name resolved: " + appName); | |||
} | |||
|
|||
/** | |||
* resolve app name from jvm options | |||
*/ | |||
public static void resolveAppName() { |
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.
We have to consider the case when project.name
is absent both in system property and configuration file, so we have to provide a default parsed appName rather than empty.
@@ -93,6 +98,7 @@ private static void loadProps() { | |||
RecordLog.info("[SentinelConfig] JVM parameter overrides {0}: {1} -> {2}", configKey, configValueOld, configValue); | |||
} | |||
} | |||
AppNameUtil.setAppName(SentinelConfig.getConfig(AppNameUtil.APP_NAME)); |
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.
We have to consider what if the appName
from SentinelConfig
is invalid (null or empty)?
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.
您的两个问题都是关于appName不合法, 在dubbo里dubbo.application.name是必填项, 不配置启动会异常.
如果我们这里需要一个默认值的话, 那或许我可以在resolveAppName()中改为解析不到project.name就设置成"sentinel".
综合你们的考虑看需要怎么改呢, 因为这里主要目的是为了加载配置文件.
Ping @VanXD . Conflict happens after merging a previous commit. Please rebase the branch against master and push it back again. Thanks a lot. |
ping @VanXD |
Resolved via #804. Anyway thanks for nice work! |
Describe what this PR does / why we need it
更方便的对sentinel进行配置.
Convenient to write configuration.
Does this pull request fix one issue?
Fixes #64
Describe how you did it
Describe how to verify it
在resources文件夹下创建"ali-sentinel.properties"文件.并且在其中书写配置.
create file in resources dir, and write your configuration.
Special notes for reviews
no