Transformer Pipeline Module API Reference (JavaScript)
8.0.2.290852-a608fcd3
|
The pipeline module is a Transformer module which embeds a powerful, yet intuitive, scripting language. This permits rapid development and deployment of business rules.
Embedded scripting language
The pipeline module embeds Duktape and the API defined in this document is written in JavaScript.
Library support
The pipeline module is supplied with a library of utility functions arranged in packages. These functions implement common utilities such as:
The use of packages permits partitioning of the symbol name space and reduces symbol name clashes.
Native function support
The pipeline module can integrate with existing transformer modules, calling their member functions directly, thus ensuring that the previous development can be reutilised.
Compilation free deployment
Pipeline scripts can be deployed without the need for a separate compilation step. Scripts are compiled into byte code as they are required.
The monitoring interface to the pipeline module allows updates to take place dynamically, a script can be uploaded whilst the Transformer is running and the current one will be replaced. Should the new script fail due to a syntax error, the change will be reverted until the next Transformer restart.
Opaque data storage
The pipeline module provides a mechanism to store and retrieve data between invocations. This permits data to be held between updates. Access to this storage is provided through the database package.
The example below calculates the price spread for all symbols under the /DEMO
namespace. It adds this as a field to the packet and sends the new packet. It also logs the spread price. It uses the log Library package which provides the log.log() function.
Append this to the end of etc/pipeline.conf
:
add-pipeline id simple listener-regex ^/DEMO/ pipeline-file simple.js update-func update end-pipeline
Place this in etc/pipeline/simple.js
:.
var log = require("log"); function update(packet) { var subject = packet.getSubject(); var bidPrice = packet.getField("BidPrice"); var askPrice = packet.getField("AskPrice"); var spread = parseInt(askPrice) - parseInt(bidPrice); log.log(log.INFO, "Spread for <" + subject + "> is " + spread + "\n"); packet.setfield("Spread", spread); packet.send(); }