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 1
1
package cn .springcloud .bamboo ;
2
2
3
+
4
+ /**
5
+ * 个接口是负责将bamboo跟ribbon连接起来的,将请求的信息, 以及根据业务需要添加的一些路由信息,和获取请求接口的目标版本,
6
+ * 还有触发执行LoadBanceRequestTrigger等,都是由该接口的实现类DefaultRibbonConnectionPoint负责实现。
7
+ */
3
8
public interface BambooRibbonConnectionPoint {
4
9
5
10
@@ -12,7 +17,6 @@ public interface BambooRibbonConnectionPoint {
12
17
// void executeBeforeReuqestTrigger();
13
18
14
19
15
-
16
20
// void executeAfterReuqestTrigger();
17
21
18
22
}
Original file line number Diff line number Diff line change 1
1
package cn .springcloud .bamboo ;
2
2
3
+ /**
4
+ * Ribbon请求的触发器,在ribbon请求发起时, 会被执行
5
+ */
3
6
public interface LoadBalanceRequestTrigger {
4
7
5
8
9
+ /**
10
+ * 判断是否需要执行的方法
11
+ *
12
+ * @return
13
+ */
6
14
boolean shouldExecute ();
7
15
16
+
17
+ /**
18
+ * 请求之前执行
19
+ *
20
+ * @param connectPointContext
21
+ */
8
22
void before (ConnectPointContext connectPointContext );
9
23
24
+
25
+ /**
26
+ * 请求完成之后执行
27
+ * 如果出现异常,该方法依然会被执行
28
+ *
29
+ * @param connectPointContext
30
+ */
10
31
void after (ConnectPointContext connectPointContext );
11
32
}
Original file line number Diff line number Diff line change 1
1
package cn .springcloud .bamboo ;
2
2
3
+
4
+ /**
5
+ * 这个接口负责获取请求需要访问的目标接口的版本。
6
+ * 比如有些接口版本是放在路径上,如:/v1/api/test/get。也有放在uri参数中:/api/test/get?v=1。
7
+ * 也有可能放到header中,所以在bamboo抽象出来一个接口, 具体的实现由开发者根据业务去实现。
8
+ */
3
9
public interface RequestVersionExtractor {
4
10
5
11
String extractVersion (BambooRequest bambooRequest );
6
12
7
13
8
- class Default implements RequestVersionExtractor {
14
+ /**
15
+ * 默认从querystring中获取:/api/test?version=1
16
+ */
17
+ class Default implements RequestVersionExtractor {
9
18
private static final String VERSION = "version" ;
10
19
11
20
@ Override
Original file line number Diff line number Diff line change @@ -10,34 +10,33 @@ public final class RequestIpKeeper {
10
10
11
11
private static RequestIpKeeper INSTANCE = new RequestIpKeeper ();
12
12
13
- private RequestIpKeeper (){
13
+ private RequestIpKeeper () {
14
14
15
15
}
16
16
17
- public static RequestIpKeeper instance (){
17
+ public static RequestIpKeeper instance () {
18
18
return INSTANCE ;
19
19
}
20
20
21
21
22
- public void setIp (String ip ){
22
+ void setIp (String ip ) {
23
23
ipLocal .set (ip );
24
24
}
25
25
26
26
27
- public String getIp (){
27
+ public String getIp () {
28
28
return ipLocal .get ();
29
29
}
30
30
31
31
32
- public void clear (){
32
+ public void clear () {
33
33
ipLocal .remove ();
34
34
}
35
35
36
36
37
-
38
- public static String getRequestIp (){
37
+ public static String getRequestIp () {
39
38
String ip = instance ().getIp ();
40
- if (StringUtils .isEmpty (ip )){
39
+ if (StringUtils .isEmpty (ip )) {
41
40
ip = BambooAppContext .getLocalIp ();
42
41
}
43
42
return ip ;
Original file line number Diff line number Diff line change 3
3
public interface GrayClientConfig {
4
4
5
5
6
+ /**
7
+ * 启动时是否灰度注册
8
+ *
9
+ * @return
10
+ */
6
11
boolean isGrayEnroll ();
7
12
13
+ /**
14
+ * 向灰度服务器注册的延迟时间(ms)
15
+ *
16
+ * @return
17
+ */
8
18
int grayEnrollDealyTimeInMs ();
9
19
10
20
21
+ /**
22
+ * 灰度服务器的url
23
+ *
24
+ * @return
25
+ */
11
26
String getServerUrl ();
12
27
13
28
29
+ /**
30
+ * 更新灰度列表的时间间隔(ms)
31
+ *
32
+ * @return
33
+ */
14
34
int getServiceUpdateIntervalTimerInMs ();
15
35
16
36
37
+ /**
38
+ * 在和灰度服务器通信时,如果交互失败,是否重试。
39
+ *
40
+ * @return
41
+ */
17
42
boolean isRetryable ();
18
43
44
+ /**
45
+ * 重试次数
46
+ *
47
+ * @return
48
+ */
19
49
int getRetryNumberOfRetries ();
20
50
21
51
}
You can’t perform that action at this time.
0 commit comments