...
| Code Block |
|---|
| language | py |
|---|
| title | Policy vs If Cycle |
|---|
|
# The single Policy is verified when all the rules that compose it are verified.
# --- Policy1 ---
if (Rule1 and Rule2 and Rule3): // Policy logic
action1 // Policy action
# --- Policy2 ---
if (Rule1): // Policy logic
action1action2 // Policy action
# --- Policy3 ---
if (Rule1 and Rule2): // Policy logic
action3 // Policy action |
When the Listener is invoked it will have to choose which action to perform, based on the Policy associated with it. The Listener will probe the list of its Policies, following a precise order, like a Switch/Case or an else if statement.
| Code Block |
|---|
| language | py |
|---|
| title | ElseIf statement |
|---|
|
# The position of the Policy is important, because the Policies that are after the first verified Policy will be ignored.
if Policy1: // Policy position
action1
elif Policy2: // Policy position
action2
elif Policy3: // Policy position
action3
else:
default pool // If the listener has no default pool, then an error 503 is returned |