Skip to content

Script Development / Built-in Variables _DFF_XXX

To facilitate scripts in obtaining relevant runtime status information, DataFlux Func directly embeds some variables in the script context that can be used directly.

Built-in Variable Type Scope Description Example Value
_DFF_SCRIPT_SET_ID str All Script Set ID "demo"
_DFF_SCRIPT_ID str All Script ID "demo__basic"
_DFF_FUNC_ID str All Func ID "demo__basic.hello_world"
_DFF_FUNC_NAME str All Func Name "hello_world"
_DFF_START_TIME int All Actual Start Time (seconds) 1625651910
_DFF_START_TIME_MS int All Actual Start Time (milliseconds) 1625651910630
_DFF_TRIGGER_TIME int All Scheduled Start Time (seconds) 1625651909
_DFF_TRIGGER_TIME_MS int All Scheduled Start Time (milliseconds) 1625651909582
_DFF_CRONTAB str Cron Job (Legacy: Auto Trigger Config) Crontab Expression * * * * *
_DFF_HTTP_REQUEST dict Sync API (Legacy: Auth Link), Async API (Legacy: Batch) Request Body for API Call See below

Difference Between _DFF_START_TIME and _DFF_TRIGGER_TIME

_DFF_START_TIME refers to the actual start time of the function, equivalent to int(time.time()) executed at the function entry, which may be delayed due to queue congestion and other factors.

_DFF_TRIGGER_TIME refers to the function trigger time, which does not change due to queue congestion and can be considered as the "scheduled start time." The values are as follows:

Function Call Method Value
UI Function Execution Time when the backend API service receives the HTTP request
Sync API (Legacy: Auth Link) Time when the backend API service receives the HTTP request
Async API (Legacy: Batch) Time when the backend API service receives the HTTP request
Cron Job (Legacy: Auto Trigger Config) The exact time corresponding to the Crontab expression

When using Cron Job (Legacy: Auto Trigger Config) to obtain time series data at fixed intervals, you should use _DFF_TRIGGER_TIME and _DFF_TRIGGER_TIME_MS as the baseline, do not use time.time() in the code to get the current time

_DFF_HTTP_REQUEST Data Structure

_DFF_HTTP_REQUEST contains the details of the request body.

For the following request:

Request Example
1
2
3
4
5
curl \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"a":"b"}' \
    http://localhost:8088/api/v1/al/auln-xxxxx/simplified?x=y

The value of _DFF_HTTP_REQUEST is as follows:

_DFF_HTTP_REQUEST Content Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
    "method"     : "POST",
    "originalUrl": "/api/v1/al/auln-xxxxx/simplified?x=y",
    "url"        : "/api/v1/al/auln-xxxxx/simplified",
    "host"       : "localhost:8088",
    "hostname"   : "localhost",
    "protocol"   : "http",
    "headers": {
        "host"          : "localhost:8088",
        "user-agent"    : "curl/7.68.0",
        "accept"        : "*/*",
        "content-type"  : "application/json",
        "content-length": "9"
    },
    "query": {
        "x": "y"
    },
    "body": {
        "a": "b"
    },
    "ip" : "127.0.0.1",
    "ips": [],
    "xhr": false
}

The fields included in _DFF_HTTP_REQUEST may vary slightly across different versions of DataFlux Func. Please refer to the actual content.

The headers field is of type IgnoreCaseDict. IgnoreCaseDict inherits dict and is used in the same way but is case-insensitive for key names. For example, the following lines of code will all yield the same value

Python
1
2
3
_DFF_HTTP_REQUEST['headers']['user-agent']
_DFF_HTTP_REQUEST['headers']['User-Agent']
_DFF_HTTP_REQUEST['headers']['USER-AGENT']