scripting/

directory
v0.0.0-...-5339e54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2022 License: BSD-3-Clause

README

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.

  1. Allow to execute any JavaScripts using the OTTO Engine. Thanks to ... https://github.com/robertkrimen/otto

  2. 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

  3. 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.

Exec Javascript image

Multiple Values can be handover vis JSON Object as well.

Input

  • Input string
  • ScriptURL string

Output

  • Output string
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

  • Output string
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

  • Output int

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

  • Output = "25"
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

  • Output = "25"
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

  • Output = "25"
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

  • Output = "25"
feedback := input / 2

^ Eval support only simple calculations, and loops, but no 'if', so I recommend to stick with just calculations.

Directories

Path Synopsis
activity
execgo
* BSD 3-Clause License * Copyright © 2020.
* BSD 3-Clause License * Copyright © 2020.
goeval
* BSD 3-Clause License * Copyright © 2020.
* BSD 3-Clause License * Copyright © 2020.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL