Forum Discussion
iRule "proc" Question
With the inclusion of the powerful "proc" feature, I am trying to write a library rule for common functionality, standardized logging, etc...
So we can "[call lib_rule::FUNCTION]" from other iRules...
WITHIN the lib_rule, I call some functions in itself... Is there a way to reference the current rule's context rather than the initial calling rule's context?
NOT a show-stopper, but would be nice should we ever wish to RENAME the library rule...
In other languages (Java, C++), there is a "this" keyword... Is there an equivalent for iRules that can be used like this? [call this::FUNCTION]
I have attempted the following which DOES NOT WORK:
set static::LIB_RULE "/Common/lib_rule"
call ${static::LIB_RULE}::FUNCTION
- Brad_ParkerCirrus
have you tried using
thenset function "${static::LIB_RULE}::FUNCTION"
?call $function
- Amit_KarnikNimbostratus
I would avoid using the tcl proc to define user defined libraries.
I have not seen explicit documentation indicating that what happens with respect the Clustered Multi Processing especially if your library has any static variables.
Also your library has to be bug-free, since any error will not just affect the current connection but the overall tmm process.
My recommendation is to just use iRule snippets for what you want done on the same event and then use iRule event priorities. Ofcourse this approach may not apply to all situations.
- Steven_Filisko_Nimbostratus
Thanks for the response. I have researched this and found:
GLOBALS are not CMP-compatible but STATIC GLOBALS are... https://devcentral.f5.com/wiki/iRules.cmpcompatibility.ashx
We are calling library functions for common tasks (such as if an address is in a data-group, standard log formats, etc).
- JRahmAdmina this keyword would be helpful, but that doesn't exist today, so best practice is to be explicit to the rule AND the folder. If you submit an RFE for the "this" keyword, will you post the bugID back to this thread?
- Steven_Filisko_NimbostratusJason, I cannot figure out where to submit an RFE! :)
- you can do that by contacting support and asking them for it.
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