Function Rule: doesn't using hub var for param limit parallel runs?

I’m looking into Rule Machine’s function feature. If the input parameter value needs to be first stored in a global Hub variable, then won’t that interfere with parallel calls to the function?

For example:

  • Subfunction reads hub var TEMP and does something.
  • Rule1 sets hub var TEMP to ‘a’ and calls subfunction. At the same time Rule2 sets hub var TEMP to ‘b’ and calls subfunction.
  • Seems like a race condition to set the value a TEMP.

So seems like functions are only good to breakup a large rule to sub-functions (good for repeat usage with the main rule) BUT sub-functions can’t really be used by other rules.

Not really. RM keeps track of which rule made each call and returns the function value to the proper rule. I have used a function rule for 5 parallel rules since the feature was released without a problem.

My issue is with the variable holding the input param, not the output.

When invoking a rule function, it seems like the param variable is limited to only hub (global) variables and local variables is not an option.

So in the example below, the input param variable is limited to only global hub ones.

So if I invoke this function from different rules, won’t those rules be competing on changing the value of the shared hub variable used by the function?

Yes.

Welp, seems like the creator of the function feature thinks that the effort was a waste. :downcast_face_with_sweat:

Anyway, there is a way to trigger a rule with a trigger url and have a parameter string stored in the url, but return value needs to be stored in global var.

So no local var input + local var output solution with Rules.

Yes, it can be done in many ways. The Function Rule adds a bit of readability to the process by showing in the rule as Set Return_Value to Rule Function(Function Name). This is appreciated by many of us.

My guess is that many RM users are not currently doing programming. More likely, active programmers went into WebCore or writing their own code.