Skip to main content

InfluxDBClient

This item only works when running on the server. Server

Client to write InfluxDB points to the server.

Functions

new

InfluxDBClient.new(
clientConfigInfluxDBClientConfig?,
requestHandlerInfluxDBRequestHandler?--

Defaults to HttpPromise.request. Inject a mock to avoid real HTTP.

) → InfluxDBClient

Creates a new InfluxDB client

newMock

InfluxDBClient.newMock(clientConfigInfluxDBClientConfig?) → ()

Creates a new InfluxDB client wired to an InfluxDBRequestHandlerMock so no real HTTP calls are made. Returns both the client and the mock, so a test can inspect the requests it would have sent.

local client, requestMock = InfluxDBClient.newMock()
client:SetClientConfig({ url = "https://example.com", token = "token" })

local writeAPI = client:GetWriteAPI("org", "bucket")
writeAPI:QueuePoint(point)
writeAPI:PromiseFlush():Wait()

print(#requestMock:GetRequests()) --> 1

SetClientConfig

InfluxDBClient.SetClientConfig(
clientConfigInfluxDBClientConfig
) → ()

Sets the client config for this client

PromiseFlushAll

InfluxDBClient.PromiseFlushAll(selfInfluxDBClient) → Promise<()>

Flushes all write APIs. Returns a promise that resolves when all write APIs are flushed for all buckets.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new InfluxDB client",
            "params": [
                {
                    "name": "clientConfig",
                    "desc": "",
                    "lua_type": "InfluxDBClientConfig?"
                },
                {
                    "name": "requestHandler",
                    "desc": "Defaults to [HttpPromise.request]. Inject a mock to avoid real HTTP.",
                    "lua_type": "InfluxDBRequestHandler?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "InfluxDBClient"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 43,
                "path": "src/influxdbclient/src/Server/InfluxDBClient.lua"
            }
        },
        {
            "name": "newMock",
            "desc": "Creates a new InfluxDB client wired to an [InfluxDBRequestHandlerMock] so no real HTTP calls are\nmade. Returns both the client and the mock, so a test can inspect the requests it would have sent.\n\n```lua\nlocal client, requestMock = InfluxDBClient.newMock()\nclient:SetClientConfig({ url = \"https://example.com\", token = \"token\" })\n\nlocal writeAPI = client:GetWriteAPI(\"org\", \"bucket\")\nwriteAPI:QueuePoint(point)\nwriteAPI:PromiseFlush():Wait()\n\nprint(#requestMock:GetRequests()) --> 1\n```",
            "params": [
                {
                    "name": "clientConfig",
                    "desc": "",
                    "lua_type": "InfluxDBClientConfig?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(InfluxDBClient, InfluxDBRequestHandlerMock)"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 83,
                "path": "src/influxdbclient/src/Server/InfluxDBClient.lua"
            }
        },
        {
            "name": "SetClientConfig",
            "desc": "Sets the client config for this client",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "InfluxDBClient"
                },
                {
                    "name": "clientConfig",
                    "desc": "",
                    "lua_type": "InfluxDBClientConfig"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 97,
                "path": "src/influxdbclient/src/Server/InfluxDBClient.lua"
            }
        },
        {
            "name": "PromiseFlushAll",
            "desc": "Flushes all write APIs. Returns a promise that resolves when all write APIs are flushed for all buckets.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "InfluxDBClient"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<()>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 160,
                "path": "src/influxdbclient/src/Server/InfluxDBClient.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "InfluxDBClient",
    "desc": "Client to write InfluxDB points to the server.",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 8,
        "path": "src/influxdbclient/src/Server/InfluxDBClient.lua"
    }
}