Modules
Tweakflow modules
Tweakstreet comes with an extensive library of functions to help processing data. These libraries are available through tweakflow modules.
They include the tweakflow standard library as well as additional data-processing libraries. The tweakstreet/json module gives you control over (de-)serialization of JSON strings, for example.
You can import any of those libraries into your flows in the flow properties dialog.
importing standard libraries
Custom tweakflow modules
You can write your own tweakflow modules
A module contains libraries, which in turn contain variables. Variables contain values.
A simple module might look like this:
# samples/module.tf
export library conf {
data_path: "/var/incoming/data/";
}
export library util {
file_path: (filename) -> conf.data_path .. filename;
}
The library conf
contains a string variable named data_path
. The library util
contains a function variable named file_path
.
All exported libraries can be imported into other modules or flows.
To reference a module’s library content in a flow, you import the library in the flow properties dialog.
For example:
import conf, util from './samples/module.tf';
Imported libraries are available in the entire flow.
importing a custom module
Tweakstreet modules
Tweakstreet supports a GUI-driven way to define modules.
Creating a new tweakstreet module presents you with a dialog that allows you to define variables and services. Tweakstreet modules are saved as *.tsm
files. They are semantically identical to a tweakflow module that contains two libraries:
vars
for variablesservices
for services
If you wish to import a *.tsm
module into a flow or another module, you can do it in the import section like this:
Importing the whole module
import * as utils from './my_utils.tsm';
The contents of the module are then available in the entire flow as utils.vars.<name>
and utils.services.<name>
respectively.
Importing a single library
import vars as utils from './my_utils.tsm';
The module’s variables are then available in the entire flow as utils.<name>
.