Forum Discussion
Best practive for iRules-LX calls with a proc
I have just found out that ILX::init cannot be called in a RULE_INIT block: The ILX iRule doc says "Valid During: ANY_EVENT with the exception of RULE_INIT". So, static is not necessary.
If you want to reuse the RPC handle, create the handle in the first event block, and make a proc to accept the handle as an argument. e.g.,
proc send_req {message handle} {
set response [ILX::call $handle AsrFunc1 $message]
return $response
}
when CLIENT_ACCEPTED {
set RPC_HANDLE [ILX::init AsrPlugin "AsrExt"]
log local0. "ACCPT: [call send_req "hello_req" $RPC_HANDLE]"
}
when HTTP_REQUEST {
log local0. "REQ: [call send_req "hello_req" $RPC_HANDLE]"
}
when HTTP_RESPONSE {
log local0. "RESP: [call send_req "hello_resp" $RPC_HANDLE]"
}
An issue is maintainability. When the code becomes longer, finding the RPC_HANDLE variable would become tedious. Also, when you add another event that occurs before the handle initialisation (e.g., FLOW_INIT starts before CLIENT_ACCEPTED), you get a TCL error. So, I would still (personally) go for the init next to call style (assuming ILX::init is cheap).
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
