Skip to main content

Hub Domain Specific Language (DSL)

The Hub DSL provides an implementation model for expressing digital onboarding solutions in a concise manner without superfluous details. Letting developers focus on the business logic. In addition to the main purpose Hub DSL supports these objectives:
  • enables transparent handling of failures,
  • facilitates working with data payloads, data mapping and transformation,
  • bridges the gap between developers and domain experts using a common language.
The Hub DSL provides the following features

DSL Commands

Route

A route represents an interaction with a user. Typically, the goal is to display route-specific information and gather input from the user. A route is rendered by a Hub Client as a web page or mobile app screen, depending on the Hub Client implementation. A route is identified by its name and can be used in a workflow definition. A minimal definition specifies a route uri intended for a Hub Client.

Definition and usage

It is possible provide a route definition inline within a workflow definition.
Another option is to define a route as part of a Hub component and use it in a workflow by referencing the route name. This approach facilitates route reusability and separation of concerns.
Additionally, it is possible to reference a route by name and provide additional details when used in a workflow. This allows for separating a route definition (uri, data constrains) and usage (export, namespace, checkpoint).

Route Result

A route result is stored using a namespace attribute key.
If a validate block is specific, a route result is validated before storing the result and resuming the execution. The route submit request results in a validation error if the validation fails.

Exporting data

In order to pass route data, the export is used. Any JSON-like data can be exported, using context attributes or serializable values.

Route check-point

A route can be marked as a check-point, meaning it is disabled to go back to the previous route.

Terminal route

A terminal route marks the end of a workflow execution. The corresponding execution is terminated when a terminal route is executed. Also, a terminal route is marked as a check-point.
In addition, it is possible to set an execution result payload using a terminal route.

Route functions

A route function allows a Hub Client to execute functions in the context of the given route. A Hub client executes a route function via Hub Client API. Some use-cases of route functions:
  • dynamic queries based on user input, like auto-complete,
  • asynchronous data processing, like document OCR,
  • communication between different execution.
  • initial execution context for corresponding function execution
  • namespace stores the result of a route function execution
It is possible to specify one or more route functions. See route examples for more details.

Exchange

An exchange is a connector proxy. It makes external (API) calls using an HTTP connector or a custom connector. It provides the following tools for handling connector failures:
  • timeout, an exchange fails with an error if the connector does not respond within the specified timeout
  • retry strategy, retries failed connector requests
An exchange is executed asynchronously when marked with async().

HTTP connector

It is possible to use built-in HTTP connector to make external calls, see more details.

Custom connector

Optionally, an exchange can use a custom connector with config.
Connector Development Guide For comprehensive guidance on developing custom connectors, see the Custom Connector Development Guide and Plugin Connector Development Guide.

Exchange Result

An exchange result is stored using a namespace attribute key.

Result handlers

An exchange command can specify one on more result handlers
  • onError() executed when the result is error
  • onSuccess() executed when the result is success
In functions, each result handler can define an inline function that is executed when the handler condition is match. In workflows, each result handler can define an inline workflow. E.g. handling an exchange error in a workflow
E.g. handling an exchange error in a function
The built-in http connector provides additional handlers
  • onStatus(status) executed when response status code matches the given status, the response body is passed as input
  • onResponse() executed for any response, the response entity (headers, status, payload) is passed as input
E.g. handling an http responses

Exchange Timeout

It is possible to set an exchange timeout in seconds. The default value is 30 seconds. An exchange fails with an error if the underlying connector doesn’t respond within the specified timeout

Exchange Retry strategies

An exchange uses a retry strategy to retry when a connector request fails. The default strategy uses fixed delays between retry attempts. The following retry strategies are available:
Fixed backoff
Uses fixed delays between retry attempts, given a number of retry attempts and the backoff delay in seconds.
  • retry a number of retry attempts, the default is 5
  • backoff a number of seconds between retries, the default is 5
Exponential backoff
Uses a randomized exponential backoff strategy, given a number of retry attempts and minimum and maximux backoff delays in seconds.
  • retry a number of retry attempts, the default is 5
  • backoff a minimum delay between retry attempts, the default is 5
  • maxBackoff a maximum delay between retry attempts, the default is 50
No retry
Does not retry when a connector request fails.

function

  • like workflow but without user interactions (route, workflow)
  • can be executed asynchronously
  • separate execution with different UUID, data passed using context and input
A function makes it possible to query dynamic data, perform complex calculations or make external calls using exhange(). Functions can be executed from a workflow or from another function.
  • name a function name
  • input a function input
  • context execution context for function execution
  • namespace a namespace to store function result
  • async() the function will be executed asynchronously

workflow

Executes a sub-workflow synchronously as a separate workflow execution with different UUID. Data is passed using context and input. Execution is terminated if sub-workflow terminates with terminal route.
  • name a workflow name
  • input a workflow input
  • context execution context for workflow execution
  • namespace a namespace to store workflow result

mapper

An attribute mapper transforms an input into an attribute output using mapper expression, see Mapper. The output gets stored in a namespace if specified. Can be used for data transformations, calculations and providing default values etc.

path

Executes a path (workflow snippet) specified by a name. A path is executed as part of the current execution and shares the same execution context. It is only possible to reference a path defined within the same component as a workflow being executed.

Execution result

There are several ways of terminating an execution and specifying an execution result
  • success() for a success result with payload
  • error() for an error result with payload
  • decision() for a success result with a decision and payload
  • response for exposed function response
  • the result of the last command or expression
Terminates an execution successfully with a payload
or with an empty payload
Terminates an execution with an error using the specified payload
or with an empty error payload
If more granularity in needed, it is possible to terminate an execution successfully using decision(). Terminates an execution successfully with a decision and payload
or with an empty error payload

Exposed function response

Exposed functions can specify an HTTP response details, including body, headers and status code.

Execution result handlers

Each function and workflow command can specify one on more result handlers
  • onError() executed when the result is error
  • onSuccess() executed when the result is success or any decision
  • onDecision() executed when the result is a given decision
Only the first matching handler is executed. When a handler is executed, the result payload is passed as an input. E.g. handling a workflow error
E.g. handling a workflow decision result

sharable

Generates a sharable token or a link with the token. A sharable token can be used for starting a new workflow or function execution. It is possible to specifies a sharable token manually. Otherwise, it is generated as 6 random alpha numerical characters.
For comprehensive documentation on sharables including use cases, integration patterns, and API reference, see the Sharables Guide
A token expires when a corresponding execution is terminated, unless the token is marked as reusable().
  • url if provided generates a link using the sharable token
  • payload an attribute/payload to be shared
  • function a name of function to execute, optionally execution input and context can be provided
  • workflow a name of workflow to execute, optionally execution input and context can be provided
  • latest() a workflow or function reference revision is resolved when sharable token is used (rather than fixed)
  • expired() expires specified token
  • reusable() the token does not expire after corresponding execution terminates
  • namespace asynchronously stores the function or workflow execution result
  • expireIn token will expire after specified duration (use ISO-8601 duration format, default is 24 hours)
Examples of usage are following:
Generates a sharable token to execute a function named function-name. The token gets stored in the token namespace.
Generates a sharable link to execute a workflow named workflow-name with input and context. The link gets stored in the link namespace. The link will expire in 30 minutes.
Generates a sharable payload that stores application attribute and can be accessed using input.token token.
Expires a specific sharable token.
Expires a sharable token that was used to execute the current execution.

Exporting namespaces

A context attribute namespace can be exported and queried using Execution API

Logging

It is possible to generate application logs from the DSL using the log command
The log message is logged using com.zenoo.hub.dsl.executor.DSLLogger class with the following format
Example: a log message using context attributes

Flow control

await

Blocks the current execution and waits until an attribute is set, e.g. by an asynchronous function, exchange or sharable token.

match

Executes a DSL script definition when an expression evaluates as true. The expression can contain context attributes.

exist

Executes a DSL script definition when an attribute is set.

switch / case

The switch statement matches expression with cases and executes the matching case. It’s a fallthrough switch-case. You can share the same code for multiple matches or use the break command. It uses different kinds of matching like, collection case, regular expression case, closure case and equals case.

loop-until

Executes a DSL script definition until an expression evaluates as true.
The maximum number of attempts can be specified.
In addition, the attempt counter can be accessed as follows:

Logging and metrics

Logging

It is possible to produce logging messages in the DSL for the purpose of tracking and trouble-shooting. The logging messages are logged as DEBUG messages via com.zenoo.hub.dsl.executor.DSLLogger. In addition, the log messages are stored as part of execution events.

Metrics

You can use the following commands in order for tracking visited interactions and their outputs.
e.g.

Meters

You can use the meter command to record named measurements with numeric values. Meters are useful for tracking usage, billing, and custom metrics. The execution context UUID is automatically included in the event.
The value defaults to 1 and tags defaults to an empty map when omitted. e.g.