A canary release allows you to create traffic adjustment rules by HTTP and HSF, whose parameter settings are different.
You can configure parameters for HTTP traffic adjustment rules based on the cookie, HTTP header, and URL parameter values. You can determine traffic based on the remainder range or list after the mod operation (mod 100). This type of rule is easy to configure and is not described in detail in this topic. If a parameter value contains a non-digit character, this character is converted to a digit by using the hash algorithm. If you use complex parameters, we recommend that you use lists to determine the traffic.
This topic describes the parameters of HSF traffic adjustment rules.
The end-to-end canary release allows you to obtain a property of a parameter by using a parameter expression. The following table describes supported parameter expressions.
Expression | Description | Remarks |
args0 | The value of the current parameter. | N/A |
args0.name | The name property of the parameter. | It can be translated into the |
args0.isEnabled() | The enabled property of the parameter, which is of the BOOLEAN type. | In Java specifications, getter for the BOOLEAN type must be |
args0[0] | The first value of the arg array. | N/A |
args0.get(0) | The first value of the arg list. | N/A |
args0.get("key") | The value of the key in the arg map. | N/A |
If you select the first parameter, Enterprise Distributed Application Service (EDAS) automatically generates an args0 prefix on the page.
The preceding expressions can be combined. Example:
args0.persons[0].meta.get("name")
: retrieves the first parameter in the persons array and obtains the meta property of persons, which is a map. Then, the value of name in this map is retrieved.
Supported conditions
=
: supports comparison between STRING, NUMBER, BOOLEAN, and CHAR values.!=
: supports comparison between STRING, NUMBER, BOOLEAN, and CHAR values.>
: supports comparison between NUMBER values.>=
: supports comparison between NUMBER values.<
: supports comparison between NUMBER values.<=
: supports comparison between NUMBER values.
Supported value expressions
A value expression for an HSF parameter matching condition represents a Java value. Only the basic data types of Java are supported, including STRING, NUMBER, BOOLEAN, and CHAR. Complex and custom data types are not supported.
EDAS supports the following types of value expressions:
Standard Java STRING type
A standard Java STRING expression represents a string that is enclosed in double quotation marks (
""
). Example:"tom"
: the tom string"10"
: the 10 string"abc "
: the abc string followed by a space"a"
: the a string"\n"
: the line feed"\"abc\""
: the"abc"
string"a\bc"
: the a\bc string
This type of expression can represent arbitrary strings.
NUMBER type
If you want to express a NUMBER value, just enter the number. Example:
100
1.23
-3.14
1.23f
NoteIn Java, 1.23 is a DOUBLE value by default. The FLOAT value for 1.23 is 1.23f. This is determined by the precision in Java specifications.
BOOLEAN type
The BOOLEAN type has only two valid values: true and false.
CHAR type
A CHAR value represents a character that is enclosed in single quotation marks (''). Example: 'a'.
NULL type
The NULL type indicates the null value in Java. You can directly enter null.
String literals
A string literal exactly represents a string so that no characters in this string need to be escaped. Example:
String literal
Java String
tom
"tom"
"
"\""
\
"\\"
a\b
"a\b"
The following table lists the value expressions for all types of values.
Value type
Value
Value expression (to be entered in the EDAS console)
java.lang.String
"tom"
"tom" or tom
java.lang.String
"true"
"true"
java.lang.String
"10"
"10"
NoteTo represent 10 of the STRING type, you must enclose 10 in double quotation marks (""). If double quotation marks ("") are absent, this string is parsed as 10 of the NUMBER type.
java.lang.String
Line wrapping
"\n"
java.lang.String
'
"\'"
java.lang.String
"
"\""
java.lang.String
\
"\"
java.lang.String
aa'bb
"aa'bb"
int
10
10
java.lang.Integer
10
10
byte
10
10
boolean
true
true
java.lang.Boolean
true
true
short
10
10
long
100
100
java.lang.Long
100
100
float
1.23f
1.23f
NoteIf arg uses a FLOAT value, you must suffix this value with f. For
1.23f==1.23
, false is returned.java.lang.Float
1.23f
1.23f
double
1.23
1.23
java.lang.Double
1.23
1.23
char
'a'
'a'
null
null
null
Examples
Parameters of the STRING type
You do not need to enter anything in the field. If the field is left empty, this represents the parameter itself.
Parameters of the ARRAY type
Assume that the parameter is a string array.
You can enter
[0]
in the field to retrieve the first element of the array.Parameters of the LIST type
Assume that the parameter is a
list<String>
.You can enter .get(0) in the field to retrieve the first element of the list. Make sure that the period (.) is contained.
Parameters of complex types
Assume that the first parameter of a method is of the following type:
public class Person { private String name; private int age; private String[] array; private List<String> list; private Map<String,String> map; }
You can configure the following rules.