Forum Discussion
Craig_Jackson_2
Nimbostratus
Nov 11, 2008Parameters to iRules?
What's the best way to pass parameters to iRules?
I'm thinking of an iRule which will have a couple of parameters -- integer values which will control behavior. I'd like to figure out the best way to manage these.
I've seen a lot of iRules set such parameters as global variables in a RULE_INIT handler. However, if this method is used, tuning the parameters requires modifying the program. This doesn't seem like good practice.
I'm thinking of putting the parameters in a string data group. The iRule would look these up to determine the current policy.
My questions are:
- Will this work? Is a data group consulted dynamically, or will the iRule need to be recompiled anyway every time the data group changes?
- Is this a good way to do this? Will using the data group add an enormous amount of overhead?
- Has anybody else tried this, or any other method other than hard-coding the values in the iRule?
Craig
1 Reply
- hoolio
Cirrostratus
Hi Craig,
As you suggest, you can either configure a global parameter in RULE_INIT (or in any event of any iRule) or you can use a datagroup (called a class in the bigip.conf). I don't think there is a significant difference between referencing a global parameter compared with referencing a class. You could test this using timing or by looping a few hundred or thousand references and comparing the times.
A reference to either object is checked on every attempt--there isn't any caching. Generally, I've suggested our clients use a global variable if it's something the administrator won't need to modify on a regular basis. If it's something an end user would need to view or change regularly a datagroup is probably easier. Modifying a global variable within the iRule requires reloading the entire rule, whereas modifying a datagroup doesn't.
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects