...
Code Block | ||||
---|---|---|---|---|
| ||||
ruleset com.windley.krl.blast { meta { name "cs_module" description << For testing modules System tests depend on this ruleset. >> configure using c = "Hello" provides a, f, search_twitter, g } global { a = 5; b = 6; f = function(x){x + b}; g = function(){ent:c} } } |
Suppose that we used this module as follows:
Code Block | ||||
---|---|---|---|---|
| ||||
ruleset foobar { meta { use module com.windley.krl.blast } global { x = com.windley.krl.blast:a + 4; y = com.windley.krl.blast:f(4); z = (com.windley.krl.blast:search_twitter("kynetx")); } ... } |
When rules in ruleset foobar
execute, x
will have the value 9 , and y
will have the value 10, and z
will contain the query term "kynetx" since that's what we pick out of the JSON response. Note that if we had referenced com.windley.krl.blast
:b
it would be undefined since b
is not in the provides
pragma in the module. Also note that the datasource
declaration of twitter_search
in the module is not visible in rulesets that use the module because it's not in the provides
pragma. However, the function search_twitter()
is available and can use the twitter_search
datasource because a module is a closure over the global values declared therein.blast
:b
it would be undefined since b
is not in the provides
pragma in the module.
Module Configuration and Aliasing
...
Warning | ||
---|---|---|
| ||
You can wrap something that isn't cachable (such as a persistent variable) in a function to make it cachable and then immediately call the function, providing the result from the module (see the examples below). When While the system determines will determine that your module is cachable, the result provided will be stale if the wrapped persistent variable is updated, since that will not invalidate the cache. |
...