script
An embedded tremor script is created with a special syntax that deviates from the operator creation. For a full reference see the section on tremor-query embedded-scripts.
The tremor script runtime allows to modify events or their metadata. To learn more about Tremor Script please see the related section.
The script
operator allows to modify the events metadata (via $
), and the script local state
which persists across single events. state
can be initialized with a state
section in the scrtipt definition.
in addition to the script
section, that is executed when an event arrives on the in
port, the script
operator allows to define multiple other sections with script from <port>
that get executed when an event arrives on <port>
all sections share the same state
allowing to decuple control and dataflow.
Inputs:
in
- the mainscript
sectionscript from <port>
is executed when data arrives at the port<port>
Outputs:
out
(default output used withemit
)error
- channel for runtime errors<anything else>
used whenemit event => "<anything else>"
Examples:
# definition
define script rt
script
emit
end;
define script add
state
state = 1
script from cfg
# update the summand to a new value
let state = event;
drop
script
emit event + state
end;
select event from in into add;
select event from cfg into add/cfg;
select event from add into out;