Go Template Engine

Receiver Sender

This module implements the bpmn / template flow-service.

docker pull registry.goingrid.io/flow/gotmplengine:v0.1.0

Table of Content

Properties

Controls

There are no Controls for the Template Engine.

However, you can access Controls from the Templates via the Functions provided for Controls:

  • getRequestControl
  • setRequestControl
  • newControl

Protocol

The common Protocol used in ingrid can be accessed via the Templatefunctions. The Protocol is documented here Protocol

API

The flow service api lets you do the following:

  • Implement Logic in the Templates. To Interact with all the other Services and Workers.

You have to pass a Template to the worker. The Worker will the run the Template against the Data he receives from a Channel and Execute the Commands from the Template

Service configuration

Like every other service, the log service includes all properties of the service configuration and since it listens on input the input configuration and also the output config.

In addition those are the following file service properties for the service:

Parameter Default value Description
“Template” "dispatcher.tmpl" “Template for File Import or Export”
“RequestTimeout” 60s “Add a ‘filesum’ Attribute in the Document with the current File Filesum”
“StartTag” "[[" “Template Start Tag”
“StopTag” "]]" “Template Stop Tag”
“MultiThreading” false “Enable multi threading. Experimental (Not recommended/Not all Features will work as expected)”
“QueueManagement” false “Enable queue mangement. This need a dispatcher to be running”
“RegisterChannel” "register" “Queue Manegement Register Channel”

QueueManagement

If you intend to run Recursions with “Go Template Engine” you need to make sure, there are enought ‘workers’ running for the Job As all Workers are ‘blocking’ while running and the Hive does Round Robin Loadbalancing, there is a possibilitie of a deadlock. To prevent the system from deadlocks you should use “controlled entries” , “dispatcher” and a minimum of needed ‘flows’ for the Job.

For QueueManagement see the Service dispatcher

Template

The Template can be configured as

Type Notation
String string://yourtemplate-content
Hive hive://template-name.tmpl
File file:///you/dir/template-name.bpmn

The Template can either be an BPMN/XML Template containing a valid BPMN XML definition. See BPMN.

Or a simple golang Template.

Template functions

The following Template Functions are implemented.

Sprig has been added to. You can use all the Sprig Template functions

Example Template

The following code is the default dispatcher.

_debug Dispatch Request to Queue
[[- $queue := (printf "%s_%s"  .Data.Class .Data.Operation) ]]
_debug [[- print " " $queue ]]
Request Class: [[ print .Data.Class ]] | Operation: [[ print .Data.Operation ]]
[[- $result := goodCall $queue .Data]]
Result  Code: [[ print $result.Result.Code ]] | Message: [[ print $result.Result.Message]]
[[- $_ := setCurrentResult $result.Result ]]

A simple Echo Workflow would like this

[[ $name := getValue (getRequestData (getRequest)) "name" ]]
[[ $res := newResult ]]
[[ $res = setResultCode $res 200]]
[[ $res = setResultMsg $res ( print "Echo back from " $name) ]]
[[ $_ := setResult $res]]

Cheat Sheets

Ingrid Functions

Ingrid Current Functions