Automatic Trigger pattern
The svc_expr
service can act as a client service on notifications,
providing a simple pattern for one-shot or periodically triggered events.
In the example in Table 1, the notify operation is triggered 4 times with an interval of 5 seconds between each invocation.
Example | Description |
---|---|
<notify name="myNotify" service="Sequencer" clients="Expr" fields="PING"> <prop name="expr.auto" interval="5s" count="4"/> </notify> |
The myNotify operation specifies Expr as a client
service.The
If
the
expr.auto property or either of its attributes were missing, default
values would apply:
By default, a notify operation that has |
In the example in Table 2,
the state variable Value
is checked once every hour while the
Expr
service is up. If Value
is greater than 100, then a
notify is fired outputting a field mapped to the Value
variable.
Example | Description |
---|---|
<mix name="Mix"> <service name="Expr" provision="expr"> <prop name="expr.state" Value="NewValue"/> </service> <notify name="myNotify" service="Sequencer" clients="Expr" fields="BIG value_field"> <prop name="expr.auto" interval="1h"/> <prop name="expr.src" content-type="text/x-erlang"><![CDATA[ case Value > 100 of true -> put("value_field", Value), true; _Otherwise -> false end. ]]></prop> </notify> </mix> |
The Expr service specifies that Value is a state
variable.This variable has no initial value. The The The This means that
myNotify , which gets triggered
every hour, only gets fired if Value exceeds 100 when the operation is
triggered.Note: Do not manually type the
<![CDATA...]]> delimiters. The Editor
automatically renders text content as XML CDATA sections. |