Function Operations pattern
A function operation contains a function mapping the input values, if any, to output values, possibly in alternate output sets.
In the example in Table 1,
svc_expr
is used to sum two input values and send the result.
Example | Description |
---|---|
<mix name="Mix"> <service name="Expr" provision="expr"/> <request name="Sum" service="Expr" fields="value1 value2"> <prop name="expr.src" content-type="text/x-erlang"><![CDATA[ Value3 = get("value1") + get("value2"), put("value3", Value3), "Ok". ]]></prop> <reply name="Ok" fields="value3"/> </request> </mix> |
The service does not need a property. The
get/1 function
retrieves the value of the input fields:
The The
last expression in the expr.src property selects the reply
"Ok" .Note: The expressions in
expr.src are
separated by commas and the last expression is terminated by a
period.Note: Do not manually type the
<![CDATA...]]> delimiters. The Editor
automatically renders text content as XML CDATA sections. |
In the example in Table 2,
svc_expr
is used to produce new field sets by assigning new values to a field.
This example shows that it is necessary to have distinct field bindings on going into the script,
and on coming out of it.
Example | Description |
---|---|
<mix name="Mix"> <service name="Expr" provision="expr"/> <consume name="Increment" service="Expr" fields="value"> <prop name="expr.src" content-type="text/x-erlang"><![CDATA[ put("value", get("value") + 1), "Ok". ]]></prop> <reply name="Ok" fields="value"/> </consume> </mix> |
The service needs no property. The The
expr.src property:
Note: Do not manually type the
<![CDATA...]]> delimiters. The Editor
automatically renders text content as XML CDATA sections. |