Skip to content

Commit bc53f1c

Browse files
feat:upgrade lane. (#563)
1 parent a30fabe commit bc53f1c

File tree

19 files changed

+1231
-137
lines changed

19 files changed

+1231
-137
lines changed

polaris-assembly/polaris-assembly-factory/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
<artifactId>router-isolated</artifactId>
4646
<version>${project.version}</version>
4747
</dependency>
48+
<dependency>
49+
<groupId>com.tencent.polaris</groupId>
50+
<artifactId>router-lane</artifactId>
51+
<version>${project.version}</version>
52+
</dependency>
4853
<dependency>
4954
<groupId>com.tencent.polaris</groupId>
5055
<artifactId>router-healthy</artifactId>

polaris-circuitbreaker/polaris-circuitbreaker-factory/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
<artifactId>router-isolated</artifactId>
5151
<version>${project.version}</version>
5252
</dependency>
53+
<dependency>
54+
<groupId>com.tencent.polaris</groupId>
55+
<artifactId>router-lane</artifactId>
56+
<version>${project.version}</version>
57+
</dependency>
5358
<dependency>
5459
<groupId>com.tencent.polaris</groupId>
5560
<artifactId>router-healthy</artifactId>

polaris-common/polaris-config-default/src/main/resources/conf/default-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ consumer:
169169
beforeChain:
170170
# 隔离路由
171171
- isolatedRouter
172+
# 泳道路由
173+
- laneRouter
172174
#描述: 服务路由链
173175
chain:
174176
# 命名空间就近路由
175177
- namespaceRouter
176-
# 泳道路由
177-
- laneRouter
178178
# 元数据路由
179179
- metadataRouter
180180
# 规则路由

polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/CompareUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static int compareSingleValue(String value1, String value2) {
3535
return 0;
3636
}
3737
if (serviceWildcard1) {
38-
// 1 before 2
38+
// 2 before 1
3939
return 1;
4040
}
4141
if (serviceWildcard2) {
@@ -52,4 +52,14 @@ public static int compareService(String namespace1, String service1, String name
5252
}
5353
return CompareUtils.compareSingleValue(service1, service2);
5454
}
55+
56+
/**
57+
* compare two boolean.
58+
*/
59+
public static int compareBoolean(boolean b1, boolean b2) {
60+
if (b1 == b2) {
61+
return 0;
62+
}
63+
return b1 ? -1 : 1;
64+
}
5565
}

polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/RuleUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public static boolean matchMetadata(Map<String, MatchString> ruleMeta, Map<Strin
172172
return matchMetadata(ruleMeta, destMeta, null, isMatchSource, multiEnvRouterParamMap, variables, null);
173173
}
174174

175+
// 匹配metadata
176+
public static boolean matchMetadata(Map<String, MatchString> ruleMeta, Map<String, String> destMeta, MetadataContainerGroup metadataContainerGroup) {
177+
return matchMetadata(ruleMeta, destMeta, metadataContainerGroup, true, Collections.emptyMap(), Collections.emptyMap(), null);
178+
}
179+
175180
// 匹配metadata
176181
public static boolean matchMetadata(Map<String, MatchString> ruleMeta, Map<String, String> destMeta,
177182
MetadataContainerGroup metadataContainerGroup, boolean isMatchSource,
@@ -223,7 +228,7 @@ public static boolean matchMetadata(Map<String, MatchString> ruleMeta, Map<Strin
223228
destMetaValue = metadataContainerGroup.getCustomMetadataContainer().getRawMetadataStringValue(ruleMetaKey);
224229
}
225230
}
226-
if (StringUtils.isBlank(destMetaValue) && destMeta.containsKey(ruleMetaKey)) {
231+
if (StringUtils.isBlank(destMetaValue) && CollectionUtils.isNotEmpty(destMeta) && destMeta.containsKey(ruleMetaKey)) {
227232
destMetaValue = destMeta.get(ruleMetaKey);
228233
}
229234
if (StringUtils.isNotBlank(destMetaValue)) {

polaris-configuration/polaris-configuration-factory/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
<artifactId>router-isolated</artifactId>
6969
<version>${project.version}</version>
7070
</dependency>
71+
<dependency>
72+
<groupId>com.tencent.polaris</groupId>
73+
<artifactId>router-lane</artifactId>
74+
<version>${project.version}</version>
75+
</dependency>
7176
<dependency>
7277
<groupId>com.tencent.polaris</groupId>
7378
<artifactId>router-healthy</artifactId>

polaris-plugins/polaris-plugins-connector/connector-composite/src/main/java/com/tencent/polaris/plugins/connector/composite/CompositeServiceUpdateTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ public void execute() {
122122
|| serviceEventKey.getEventType().equals(EventType.NEARBY_ROUTE_RULE)
123123
|| serviceEventKey.getEventType().equals(EventType.LOSSLESS)
124124
|| serviceEventKey.getEventType().equals(EventType.CIRCUIT_BREAKING)
125-
|| serviceEventKey.getEventType().equals(EventType.RATE_LIMITING)))) {
125+
|| serviceEventKey.getEventType().equals(EventType.RATE_LIMITING)
126+
|| serviceEventKey.getEventType().equals(EventType.LANE_RULE)))) {
126127
return;
127128
}
128129
boolean svcDeleted = this.notifyServerEvent(

polaris-plugins/polaris-plugins-connector/connector-consul/src/main/java/com/tencent/polaris/plugins/connector/consul/ConsulAPIConnector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.tencent.polaris.plugins.connector.consul.service.ServiceService;
5252
import com.tencent.polaris.plugins.connector.consul.service.circuitbreaker.CircuitBreakingService;
5353
import com.tencent.polaris.plugins.connector.consul.service.lossless.LosslessService;
54+
import com.tencent.polaris.plugins.connector.consul.service.lane.LaneService;
5455
import com.tencent.polaris.plugins.connector.consul.service.ratelimiting.RateLimitingService;
5556
import com.tencent.polaris.plugins.connector.consul.service.router.NearByRouteRuleService;
5657
import com.tencent.polaris.plugins.connector.consul.service.router.RoutingService;
@@ -234,6 +235,7 @@ private void initActually(InitContext ctx, ServerConnectorConfig connectorConfig
234235
consulServiceMap.put(ServiceEventKey.EventType.LOSSLESS, new LosslessService(consulClient, consulRawClient, consulContext, "consul-lossless", mapper));
235236
consulServiceMap.put(ServiceEventKey.EventType.CIRCUIT_BREAKING, new CircuitBreakingService(consulClient, consulRawClient, consulContext, "consul-circuit-breaking", mapper));
236237
consulServiceMap.put(ServiceEventKey.EventType.RATE_LIMITING, new RateLimitingService(consulClient, consulRawClient, consulContext, "consul-rate-limiting", mapper));
238+
consulServiceMap.put(ServiceEventKey.EventType.LANE_RULE, new LaneService(consulClient, consulRawClient, consulContext, "consul-lane", mapper));
237239
initialized = true;
238240
}
239241

0 commit comments

Comments
 (0)