Config Modules
Config modules are modules that aren’t imported into flows explicitly. Instead, you inject global modules into a flow from the outside when running it.
This inversion of control is useful for passing externally managed configuration into flows.
Tweakstreet config modules
Tweakstreet config modules are created through the GUI.
Example config module
If their role is set to config
, they can be used as config modules. They are available as $config
in the flows they are injected into.
Accessing values from a tweakstreet config module
Tweakflow config modules
Tweakflow config modules are *.tf
files that declare a global name. In the following example, the global name env
is used:
global module env;
export library conf {
data_path: "/var/incoming/data/";
}
Config modules are available as $<declared-name>
in the flows they are injected into.
Accessing values from a tweakflow config module
Injecting a config module
Workbench
In the workbench you can select or clear the config module to use in the File menu.
Once a config module is selected in the workbench, all flows are consistently injected with the chosen module. The currently chosen config module is displayed on the right side of the status bar.
Command Line
All command line tools support a -g
switch, allowing you to pass config modules into the process.
λ:tweakstreet-app $ bin/engine.sh -g conf/env.tf flow.cfl
15:31:39 ¦ INFO ¦ main ¦ loading flow flow.cfl
15:31:40 ¦ INFO ¦ flow.cfl ¦ initializing
15:31:40 ¦ INFO ¦ Logger.0 ¦ data path: /var/incoming/data/
15:31:40 ¦ INFO ¦ flow.cfl ¦ flow finished successfully
If you try to run a flow that depends on a global name like $config
, but do not inject any module that provides that name, you will see an error like this:
INFO:
at: flow.cfl:vars.data_path:1:1
code: EXPRESSION_ERROR
message: config is undefined
value: nil
ERROR:
code: UNRESOLVED_REFERENCE
message: config is undefined
source: $config.conf.data_path
line: $config.conf.data_path
TRACE:
none