File tree Expand file tree Collapse file tree 5 files changed +73
-10
lines changed
spring-cloud-bamboo/src/main/java/cn/springcloud/bamboo
spring-cloud-gray-client/src/main/java/cn/springcloud/gray/client Expand file tree Collapse file tree 5 files changed +73
-10
lines changed Original file line number Diff line number Diff line change 11package cn .springcloud .bamboo ;
22
3+
4+ /**
5+ * 个接口是负责将bamboo跟ribbon连接起来的,将请求的信息, 以及根据业务需要添加的一些路由信息,和获取请求接口的目标版本,
6+ * 还有触发执行LoadBanceRequestTrigger等,都是由该接口的实现类DefaultRibbonConnectionPoint负责实现。
7+ */
38public interface BambooRibbonConnectionPoint {
49
510
@@ -12,7 +17,6 @@ public interface BambooRibbonConnectionPoint {
1217// void executeBeforeReuqestTrigger();
1318
1419
15-
1620// void executeAfterReuqestTrigger();
1721
1822}
Original file line number Diff line number Diff line change 11package cn .springcloud .bamboo ;
22
3+ /**
4+ * Ribbon请求的触发器,在ribbon请求发起时, 会被执行
5+ */
36public interface LoadBalanceRequestTrigger {
47
58
9+ /**
10+ * 判断是否需要执行的方法
11+ *
12+ * @return
13+ */
614 boolean shouldExecute ();
715
16+
17+ /**
18+ * 请求之前执行
19+ *
20+ * @param connectPointContext
21+ */
822 void before (ConnectPointContext connectPointContext );
923
24+
25+ /**
26+ * 请求完成之后执行
27+ * 如果出现异常,该方法依然会被执行
28+ *
29+ * @param connectPointContext
30+ */
1031 void after (ConnectPointContext connectPointContext );
1132}
Original file line number Diff line number Diff line change 11package cn .springcloud .bamboo ;
22
3+
4+ /**
5+ * 这个接口负责获取请求需要访问的目标接口的版本。
6+ * 比如有些接口版本是放在路径上,如:/v1/api/test/get。也有放在uri参数中:/api/test/get?v=1。
7+ * 也有可能放到header中,所以在bamboo抽象出来一个接口, 具体的实现由开发者根据业务去实现。
8+ */
39public interface RequestVersionExtractor {
410
511 String extractVersion (BambooRequest bambooRequest );
612
713
8- class Default implements RequestVersionExtractor {
14+ /**
15+ * 默认从querystring中获取:/api/test?version=1
16+ */
17+ class Default implements RequestVersionExtractor {
918 private static final String VERSION = "version" ;
1019
1120 @ Override
Original file line number Diff line number Diff line change @@ -10,34 +10,33 @@ public final class RequestIpKeeper {
1010
1111 private static RequestIpKeeper INSTANCE = new RequestIpKeeper ();
1212
13- private RequestIpKeeper (){
13+ private RequestIpKeeper () {
1414
1515 }
1616
17- public static RequestIpKeeper instance (){
17+ public static RequestIpKeeper instance () {
1818 return INSTANCE ;
1919 }
2020
2121
22- public void setIp (String ip ){
22+ void setIp (String ip ) {
2323 ipLocal .set (ip );
2424 }
2525
2626
27- public String getIp (){
27+ public String getIp () {
2828 return ipLocal .get ();
2929 }
3030
3131
32- public void clear (){
32+ public void clear () {
3333 ipLocal .remove ();
3434 }
3535
3636
37-
38- public static String getRequestIp (){
37+ public static String getRequestIp () {
3938 String ip = instance ().getIp ();
40- if (StringUtils .isEmpty (ip )){
39+ if (StringUtils .isEmpty (ip )) {
4140 ip = BambooAppContext .getLocalIp ();
4241 }
4342 return ip ;
Original file line number Diff line number Diff line change 33public interface GrayClientConfig {
44
55
6+ /**
7+ * 启动时是否灰度注册
8+ *
9+ * @return
10+ */
611 boolean isGrayEnroll ();
712
13+ /**
14+ * 向灰度服务器注册的延迟时间(ms)
15+ *
16+ * @return
17+ */
818 int grayEnrollDealyTimeInMs ();
919
1020
21+ /**
22+ * 灰度服务器的url
23+ *
24+ * @return
25+ */
1126 String getServerUrl ();
1227
1328
29+ /**
30+ * 更新灰度列表的时间间隔(ms)
31+ *
32+ * @return
33+ */
1434 int getServiceUpdateIntervalTimerInMs ();
1535
1636
37+ /**
38+ * 在和灰度服务器通信时,如果交互失败,是否重试。
39+ *
40+ * @return
41+ */
1742 boolean isRetryable ();
1843
44+ /**
45+ * 重试次数
46+ *
47+ * @return
48+ */
1949 int getRetryNumberOfRetries ();
2050
2151}
You can’t perform that action at this time.
0 commit comments