svc_expr properties

The Expressions extension supports the use of Erlang expressions in SPARKL.

expr.auto

Use this property to specify how many times, and how frequently a notify is triggered by the svc_expr service. If this property is not specified, default values apply.

<notify 
  name="SomeNotify"
  service="Sequencer"
  clients="SomeExprService">
  <prop 
    name="expr.auto"    
    interval="5s"    
    count="4"/>
</notify>

count

The total times the notify is triggered.

Table 1. Attribute values
Value Description
"-1" The default value. The notify is triggered an unlimited number of times.
"0" The notify is never triggered.
"n" The notify is triggered an "n" number of times.

interval

The time between each triggering of the notify.

Table 2. Attribute values
Value Description
"30s" This is the default value. The notify is triggered every 30 seconds.
"n" The notify is triggered every "n" seconds.
"n<timeunit>" The notify is triggered every "n" time unit specified. Supported time units, besides seconds, are:
  • milliseconds(ms)
  • minutes(m)
  • hours(h)

expr.bind.in

Use this property to bind the input fields of an operation to variables. Variable names must start with a capital letter.

<prop name="expr.bind.in"    
Var="input"/>

expr.bind.out

Use this property to bind the output fields of an operation to variables. Variable names must start with a capital letter.

<prop name="expr.bind.out"    
Var="output"/>

expr.init

Use this property to give variables an initial value. Depending on their use, the variables can be state or static variables.

<service 
  name="Bartender" 
  provision="expr">
  <prop 
    name="expr.init" 
    GinsServed="0"/>
  <prop 
    name="expr.state" 
    GinsServed="NewGinsServed"/>
</service>
Tip: An expression in expr.src can also initialise a state variable. For example, NewFoo = 0. This leads to a state change, as opposed to using expr.init, with the attribute Foo="0".

expr.init.[Var]

Use this property to contain variables that are longer Erlang terms, such as maps #{...}, and lists [...].

The expr.init property is appended with the name of the variable.
<service 
  name="Database" provision="expr">
  <prop 
    name="expr.init.Table"
    content-type="text/x-erlang"><![CDATA[
#{
  0 => "Foo",
  1 => "Bar"}
  ]]></prop>
</service>
Important: Do not use a full stop at the end of the term, like in the case of expressions contained in expr.src.
Tip: To get syntax highlighting, use the content-type="text/x-erlang" attribute.

expr.src

Use this property to add Erlang expressions either to a service or an operation. The content is rendered as a CDATA section.

<prop name="expr.src"
  content-type="text/x-erlang"><![CDATA[
case IsLocked of  
  true ->    
    Error = "Already locked",    
    "Error";   

  false ->    
    NewIsLocked = true,    
    "Ok"
end.
]]></prop>
Important: The expressions list must end with a full stop.

expr.state

Use this property on a service to define state variables and other state variables that update them. Use it on a notify operation to trigger it on a particular state change.

<!-- NewCount updates Count -->
<service name="Expr"  
  provision="expr">  
  <prop name="expr.state"    
    Count="NewCount"/>
</service>

<!-- OldCount is the last 
known value of Count -->
<notify name="myNotify"  
  service="Sequencer"  
  clients="Expr"  
  fields="TRIGGER">  
  <prop name="expr.state"    
    Count="OldCount"/>  
  <prop name="expr.src"    
    content-type="text/x-erlang"><![CDATA[
Count > 5.  
  ]]></prop>
</notify>
Note: Variable names must start with a capital letter.