CREATE TRAFFIC RULE
语法用于创建双路由规则
CreateTrafficRule ::=
'CREATE' 'TRAFFIC' 'RULE' '(' 'LABELS' '(' lableName ')' ',' trafficAlgorithmDefinition ',' loadBalancerDefinition ')'
lableName ::=
identifier
trafficAlgorithmDefinition ::=
'TRAFFIC_ALGORITHM' '(' 'TYPE' '(' 'NAME' '=' trafficAlgorithmTypeName (',' propertiesDefinition)? ')' ')'
loadBalancerDefinition ::=
'LOAD_BALANCER' '(' 'TYPE' '(' 'NAME' '=' loadBalancerName (',' propertiesDefinition)? ')' ')'
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
trafficAlgorithmTypeName ::=
string
loadBalancerTypeName ::=
string
key ::=
string
value ::=
literal
TRAFFIC_ALGORITHM
支持 SQL_MATCH
与 SQL_HINT
两种类型
LOAD_BALANCER
支持 RANDOM
与 ROUND_ROBIN
两种类型
CREATE TRAFFIC RULE sql_match_traffic (
LABELS (OLTP),
TRAFFIC_ALGORITHM(TYPE(NAME="SQL_MATCH",PROPERTIES("sql" = "SELECT * FROM t_order WHERE order_id = 1; UPDATE t_order SET order_id = 5;"))),
LOAD_BALANCER(TYPE(NAME="RANDOM")));
CREATE
、TRAFFIC
、RULE
、LABELS
、TYPE
、NAME
、PROPERTIES
、TRAFFIC_ALGORITHM
、LOAD_BALANCER