TCI Scripting Extension
TIBCO Cloud Integration Flogo Scripting activity.
Overview
There are 3 Option to dynamically executed Scripts stored on a remote location, all allow Script adjustments on the fly with redeploying the Service to TCI.
-
Allow to execute any JavaScripts using the OTTO Engine. Thanks to ... https://github.com/robertkrimen/otto
-
Allow to execute GOlang as well - but is not working within the Cloud, yet. I see no Issues to use it with 'native' Flogo!
Thanks to ... https://github.com/novalagung/golpal
-
You can find a experimental Version for one line GO Eval, too. But this really just a working draft.
Thanks to ... https://github.com/xtaci/goeval
Install URL
to install e.g. the JavaScript Activity use in the Flogo Extension Upload UI:
github.com/TIBCOSoftware/TCSTK-GOlang/scripting/activity/execjs
Source
All Source on GitHub here: https://github.com/TIBCOSoftware/TCSTK-GOlang/tree/master/scripting/activity
Activities
The first JavaScript Extension is the most Advanced Option here as it supports longer Scripts.
JavaScript Execution
Sample of dynamic Javascript execution, the script is loaded on the fly from any URL.
So it can be changed at any time without any redeployment, etc.
Multiple Values can be handover vis JSON Object as well.
Input
- Input string
- ScriptURL string
Output
GOlang Execution
Sample of dynamic GOlang execution, the script is loaded on the fly from any URL.
So it can be changed at any time without any redeployment, etc.
Warning: not working in TCI, yet! This is because Golpal needs a temp. Folder, and TCI does not allow that.
Similar Implementation should work in Flogo without any Issues.
Input
- Input string (replaces {input} inside the script)
- ScriptURL string
Output
GOlang Eval
Just for tiny calculations, etc., the one line string is loaded on the fly from any URL.
So it can be changed at any time without any redeployment, etc.
Warning: just for GOlang calculations, yet!
Input
- Input string (input is set as Value to the eval)
- ScriptURL string
Output
JavaScript Execution Hints
here some first sample Scripts to how it works, more can be found in 'logicscripts' folder.
Sample Input Data
Sample Output Data
- Output = "Input: some data"
var feedback = "Input: " + input;
console.log("JS VM - the value " + feedback);
feedback;
Sample Input Data
Sample Output Data
var feedback;
if (input=="green"){
console.log("JS VM: green path selected");
feedback = "25";
} else {
console.log("JS VM: other path selected");
feedback = "75";
};
feedback;
Sample Input Data with complex JSON
Sample Output Data
var feedback;
console.log("JS VM IN: " + input);
var obj = JSON.parse(input);
if (obj.data=="green"){
console.log("JS VM: green path selected");
feedback = "25";
} else {
console.log("JS VM: other path selected");
feedback = "75";
};
feedback;
GOlang Execution Hints
Sample Input Data
Sample Output Data
input := "{input}"
feedback := ""
if (input=="green"){
feedback = "25"
} else {
feedback = "75"
}
return feedback
^ as 'golpal' not support Input like 'otto' {input} is replaced with the Input String.
GOlang Eval Hints
Sample Input Data
Sample Output Data
feedback := input / 2
^ Eval support only simple calculations, and loops, but no 'if', so I recommend to stick with just calculations.