LB:method_assign_server()
Returns the server through the current load balance method configured on current the Virtual Server.
The implementation will first check whether the backend is already set. If the backend is set, then it runs the load balance algorithm to assign a server and returns the server name as a string. If the backend is not set, the function returns an empty string, and then FortiADC will set the backend only if there is only one backend available. If there is no server available in the corresponding pool or all the servers are down in the pool, an empty string will also be returned.
Syntax
LB:method_assign_server();
Arguments
N/A
Events
Applicable in the following events:
-
HTTP_REQUEST
-
HTTP_DATA_REQUEST
-
AUTH_RESULT
Example
when HTTP_REQUEST {
s=LB:method_assign_server()
if (s == nil or s == '') then
s = "No Server returned."
end
debug("assign server: '%s'\n", s)
}
Note:
The result may be overwritten by functions in PERSISTENCE events, which happen after HTTP_REQUEST. For example, this function returns server01. But the PERSISTENCE event specifies to use server02. The result from the PERSISTENCE event (server02) will always supercede results from non-PERSISTENCE events (server01).
Supported Version
FortiADC version 7.4.2 and later.