Skip to content

Script Development / DataFlux Func Sidecar

Using the Sidecar connector allows users to invoke the Sidecar to execute Shell commands.

The parameters for DFF.CONN(...) are as follows:

Parameter Type Required / Default Value Description
connector_id str Required Connector ID

For the complete usage documentation of Sidecar, please refer to the «Sidecar Manual»

.shell(...)

Invokes the Sidecar to execute a Shell command. The parameters are as follows:

Parameter Type Required / Default Value Description
cmd str Required The Shell command to be executed
Example: "ls -l"
wait bool True Whether to wait for the execution to complete
Setting this to False will make the function return immediately and not return terminal output
workdir str None The working directory for executing the Shell command
Example: "/home/dev"
envs dict None Environment variables, both keys and values must be strings
Example: {"MY_NAME": "Tom"}
callback_url str None Callback URL, after the command execution, the stdout and stderr will be sent via POST to the specified URL
This is generally used with the wait=False parameter to achieve asynchronous callbacks
timeout int 3 Request timeout time
Note: This parameter is not the timeout time for the Shell command, but the timeout time for the Func request to the Sidecar
That is, the Func request to the Sidecar may time out, but the executed Shell command will not stop as a result

Post-execution Callback

After invoking SidecarHelper.shell(...) and specifying the callback_url parameter, the Sidecar will send the standard output stdout and standard error stderr via POST to this address after the Shell command execution is complete.

The specific structure is as follows:

Text Only
1
2
3
4
5
6
7
8
9
POST {callback_url}
Content-Type: application/json

{
    "kwargs": {
        "stdout": "<standard output text>",
        "stderr": "<standard error text>"
    }
}

This structure matches the «Synchronous API (Old Version: Authorized Link) Standard POST Method» of DataFlux Func, and the «Synchronous API (Old Version: Authorized Link)» can be directly used to receive the callback after execution.