The CREATE TRAFFIC RULE
syntax is used to create dual routing 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
support SQL_MATCH
and SQL_HINT
two types;
LOAD_BALANCER
support RANDOM
and ROUND_ROBIN
two types.
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