Constant Operations pattern

A constant operation outputs constant values for a particular request- or consume-reply operation.

In the example in Table 1, a constant operation delivers the initial divisor 2 of any candidate prime number.

Table 1. Constant operation
Example Description
<service name="Expr"  
  provision="expr"/>  

<request name="FirstDivisor"  
  service="Expr"  
  fields="TEST">    

  <prop name="expr.bind.out"    
    Div="div"/>    

  <prop name="expr.src"
    content-type="text/x-erlang"><![CDATA[
Div = 2,
"Ok".  
  ]]></prop>    

  <reply name="Ok"    
    fields="div"/>
</request>
Note: Do not manually type the <![CDATA...]]> delimiters. The Editor automatically renders text content as XML CDATA sections.
The service does not need a property.

The value of input fields, if they have such, is irrelevant.

The expr.src property has a list of Erlang expressions. These must be separated by commas and terminated by a full stop.

The last expression value has to name the reply set, in this case "Ok".

The value 2 is assigned to the variable Div.

Note: Variable names must start with a capital letter.

This variable is mapped to the output field with the expr.bind.out property.

Note: The example is from a version of the Primes demo using svc_expr.