The communication protocol relies on the following things:
The worker shell may set the following environment variables:
DBOS_INPUTS_DIR
the path to the directory where to find input parameter filesDBOS_OUTPUTS_DIR
the path to the directory where to place output parameter filesIf DBOS_INPUTS_DIR
is set, then look for input parameter files into this folder.
Otherwise, look into the inputs
folder in the working directory of the task process.
If DBOS_OUTPUTS_DIR
is set, then look for output parameter files into this folder.
Otherwise, look into the outputs
folder in the working directory of the task process.
The name of the files in these directories are the parameter names.
Outgoing or incoming messages have all the following form:
DBOS_<type>:<payload>\n
All messages fit on one line of text, ended by new line (\n
) character.
The <type>
part defines the type of message.
The :<payload>
might be absent, the <payload>
part contains the message data and is a json string
that must not contains \n characters, the protocol requires that a message fit in one line.
Thank to the json format, multiline text can be transmitted because \n can be escaped in json text values.
The task process can print messages or logs, it is interpreted as a log only if what is printed doesn’t match the message syntax or is not a known message type.
The task process can send the following types of message:
INSTANCE
: instance metricsPROGRESS
: progression metrics of the taskSOLUTION
: solution metrics of the taskThe payload of these messages have the following form (prettified json below):
{
<optional field>
"values": [
{"name": "<name>", "value": <value>, "coefficient": <coefficient>},
{"name": "<name>", "value": <value>, "coefficient": <coefficient>}
]
}
<name>
is the name of a metric, <value>
its value (might be string or numeric) and
<coefficient>
the optional numeric value for the coefficient.
The <optional field>
is not required and depends on the type of message:
instanceId
for INSTANCE
messagesmessage
for PROGRESS
messageselapsedTime
for SOLUTION
messagesSo for instance, a complete SOLUTION
message would look like:
DBOS_SOLUTION:{"elapsedTime":123456789,"values":[{"name":"The answer","value":42}]}\n
For now, task processes can only receive the following message:
DBOS_STOP\n
When the task process receive this message, it must send its solution and exit.
In case a bridge is available in your task’s target language, we strongly recommend using it. If not available, it is recommended to use existing json library to serialize you data properly.