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

have you tried using

set function "${static::LIB_RULE}::FUNCTION"

then

call $function

?

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.

Thanks for the response. I have researched this and found:

GLOBALS are not CMP-compatible but STATIC GLOBALS are… DevCentral - An F5 Technical Community

We are calling library functions for common tasks (such as if an address is in a data-group, standard log formats, etc).

a 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?

Jason, I cannot figure out where to submit an RFE! :slight_smile:

you can do that by contacting support and asking them for it.