Qrtz

qrtz is the processing language for hybrixd. It is used to handle routing requests. Each routing request spawns a process that follows qrtz steps to a result, or a failure.

A qrtz command always consists of 4 characters. The parameters are appended in either a space or a comma-separated fashion:

head parameter1 parameter2 ...

head(parameter1,parameter2,...)

Recipe

Recipes are JSON files that contain parameters and qrtz methods for asset handling, data source queries or actionable engines. A recipe, depending on what it does, fits in one of three categories: asset, source, or engine.

A source-recipe in principle contains only methods to query read-only data sources.

An engine-recipe contains methods to perform actions based on incoming data, business logic and often interfaces with other programming languages.

An asset-recipe contains methods to query value-related ledger or cryptocurrency API's. It returns path options to the hybrixd routing engine for users or machines to perform actions like, for example, querying the balance of an address.

The categories above make it easier to recognize the functionality of a recipe instantly, and analyze it from the proper context. Source and engine recipes are interpreted identically by the scheduler. However, they are available through separate paths: /source and /engine. Asset recipes are specifically tailored to be used in the context of decentralized banking and are available through the routing path: /asset.

Data flow

Every step in a qrtz recipe has the potential to alter the data of the process in which the script is running. Process data is available by using the dollar sign $. It is also available as input to every new process step. It behaves like a variable in qrtz in that it can be read anywhere. However, the difference with a variable is that the data of the process can be changed by every step of the process. The design consideration is that this coaxes you to design your qrtz script with a concise data flow in mind.

Here is an example of some qrtz steps and the resulting data flow.

data 'Hello dog!'       // data 'Hello dog!'    - set the data of the process
pull -4                 // data 'Hello '        - pulls the last 4 characters
repl ' ' 'world!'       // data 'Hello world!'  - replaces the ' ' (space) by 'world!'

Variables & Scopes

$ the main stream variable it is the output of the previous step. Use $$ to escape the dollar sign (for example in regular expressions).

$.property

$variable Retrieve a property from the recipe.(read only) (falls back to proc:: scope if no recipe variable is found)

$local::variable or $::variable Use a local scope (maintained between all processes spawned from the same recipe).

$proc::variable process scope.

$otherRecipe::variable the local scope of another recipe (read-only)

Reference

Array/String

case modeChange case of a string.
code target [source='base256']Change encoding of a string from one format to the other.
date object [option='']Set data stream to a value.
drop [offset=1] endingDrop elements from the start or end of an array or string. (Reversed function of pick and push.)
excl valueExclude elements from an array or input string based on their value. Jump to a target based on success or failure. (Reversed function of filt.)
filt -Filter all specified elements from an array, removing all other entries. (Reversed function of excl.)
find needle [onFound=1] [onNotFound=1]Find a string in an array of objects, and return the object it was found in.
flat [depth=infinite]Flatten an array or object.
flipFlip reverse the contents of an array or string
fuse input [offset=length] [delete=0]Fuse or insert new data onto array or string.
head [size=1]Get the front of a string or array.
indx needle [backwardSearch=false] [arraySearch=false]Find a string in a string or an array of strings, and return the index(es) of it.
join [separator='']Join an array into a string.
jpar [success=1] [failure=1]Attempt to turn a string into a JSON object. In case of success or failure jump.
jstrTurns JSON object into a string.
many [amount=2]Keep all duplicate elements in an array of which there are many, removing all single, or less available entries.
pick [start] [end]Pick elements from an array or input string. Indexes, a range or selection array of indexes can be entered.
pull [start] [end]Pull elements from an array or input string. Indexes, a range or selection array of indexes can be entered.
push input [offset=length]Push new data into array or string.
repl [string=] [replace=''] [regexModifier=false]Replace part or parts of a string. All matched occurrences are replaced. Regular expressions can be used by specifying regexModifier.
shufShuffle elements in an array or input string randomly.
size [input]Count the amount of entries a list, string or object has.
sort methodSort data by using a certain method.
splt [separator=] [elements=undefined]Explode a string into an array, split by separator.
tail [size=1]Get the last part or tail of a string or array.
take [start] [end]Take elements cutting them from an array or input string.
trim [leftOrBothTrim=] [rightTrim=leftOrBothTrim]Trim elements from left and or right side of a string or array.
type [type]Return or set the type of the data stream.
uniq [groupSize=1]Remove all duplicate elements from an array, leaving only unique entries.

Cryptography

keys step secretJump forward or backward several instructions. Using labels is also supported.
node requestReturn information about the hybrix node
sign key [signature] [onSuccess] [onFail]Sign a message with a secret key or verify the signature for a public key.

Finance

bank username passwordOrKeyOrFile Banking functions to control hybrix accounts from Qrtz. It is useful for quick implementations of automated and responsive transactions on the node side. Note that this command is not intended for situations where a great amount of parallelized transactions are required. Please use the interface library for this. Also, if you want to use deterministic transactions client-side, please use the hybrix interface library for this purpose. For security, this command can only be used as sessionID root.

Flow

flow [onTrue=1] [onFalse=1]Change the flow of execution based on a string or value comparison.
hook onError [err=1]Indicates a fallback target when an error is encountered.
loop position variable condition [initvalue='1'] [stepvalue='+1']Loop back to position or label based on criteria.
ship [onPositive=1] [onZero=1] [onNegative=1] [onNaN=1]Test a number to be positive, zero or negative (named after the spaceship operator)
test condition [onTrue=1] [onFalse=1]Test a condition and choose to jump.
true condition [onTrue=1] [onFalse=1]Test truth of a condition and choose to jump.
void or [onTrue=1] [onFalse=1]Change the flow of execution based on void analysis.

Interface

execExecute a client stack program.
initInitiates a client stack program. This stack can be filled by using step and executed using exec.
step keyAdd a step to a client stack program. Executed using exec.

Logging

logs [level] message...Logs data to console.

Meta

qrtz variable qrtz a,Run a Qrtz command contained in a string. The result of the command is stored in a variable.

Process

call command [data=data]Execute a quartz routine in the same engine. Call creates a new process and waits for the data of that process to be returned (combining Qrtz commands fork and read).
done [data=data]Stop processing and return message.
each commandIterate through elements of a container. Execute a given function for each element in parallel.
fail [err=1] [data=data]Fail processing and return message.
fork command [data=data] [childId=0]Creates a new process by calling the command asynchronously.
func name [legacyData]Execute a javascript module function. Only if the script is run from a recipe with a non-Quartz module defined.
mime key dataRetrieve the storage metadata based on a key.
pass [data=data]Pass data to parent process.
read processIDs [interval=500]Wait for one or more processes to finish and return the results.
stop [err=0] [data=data]Stop processing and return data.
time [millisecs] [data=data] [err=1]Set timeout of current process.
wait millisecsWait a specified amount of time before continuing the process.
with variable qrtz a,Performs a data command using a specific variable. The data buffer is left untouched.

Storage

burn keyDelete a storage item
load [key]Retrieve a string value stored under key. NOTE: When loading saved objects, pass them through jpar() for object conversion!
save key [value=data]Store a key value pair. When value is an object, it will be stored as a string.
seek [key]Seek a storage key and jump on existence or not.

String

regx patternTest the data against the regex pattern

Variables

copy source targetCopy a variable to another variable. The data stream is left untouched.
peek key [default]Gets data from a variable that was defined by poke. Used inside of other instructions.
poke key [value=data] [default]Put data in a variable for later use. Use peek to retrieve. The data is stored in the root parent process under 'vars'. (You can see this poked data stored in global.hybrixd.proc[rootID].vars, but a better way to use this data is by using the command peek("varname").

Misc

atom [reduce=false] [factor=$factor]Convert a number from atomic units (large integer), or convert to atomic units.
curl target [querystring=""] [method="GET"] [headers={}] [overwriteProperties={}] [onSuccess=1] [onFail=1]Use API queue to perform a curl call to an external host.
file [success=1] [failure=1]File reads the data of a filekey into process memory.
form [factor=$factor]Format a (floating point) number and return a neatly padded string.
have [method='sha256'] pattern objectDefinition [success=1] [failure=1]Create a sha256 hash from an input string.
math equationCalculates numbers and variables. Mathematical calculations can be done with very large numbers.
packCompress and serialize data into an URL-safe format.
prog [start] [end] [second]Set progress of parent process directly, or incrementally in a set amount of time.
rand [start] [until]Return a random number between 0 and 1, or an integer.
rout pathRoute a path through hybrixd and pass the result to the next step. /api/help for API information.
scan test [cumulative] [cinit=0]Scan through the values of an array or object, and return values that pass the test.
tran pattern [success=1] [failure=1]Transforms data using a pattern definition. Also for arrays and dictionaries of property paths. Also for explicit primitive values.
unpk [onSuccess=1] [onFailure=1] [parse=true]Deserialize and decompress data, jump on success or failure.