mirror of
https://github.com/tdely/nimflux
synced 2026-01-15 03:51:47 +00:00
No description
| .github/workflows | ||
| src | ||
| tests | ||
| CHANGELOG.md | ||
| LICENSE | ||
| nimflux.nimble | ||
| README.md | ||
Nimflux
Nimflux is an InfluxDB API client library for Nim that can be used to ping,
write, query, or send custom requests. The DataPoint type is used to
easily create measurements for write, but it's also possible to send your own
Line Protocol string should the need arise.
import nimflux
var data = DataPoint(measurement: "temp")
data.addTag("loc", "home")
data.addField("ambient", 22.0)
var client = newInfluxClient("localhost", "nimtest")
var resp = client.write(data)
assert resp.code.toInfluxStatus == Ok
resp = client.query("select * from temp")
echo resp.body
Asynchronous actions are also supported through AsyncInfluxClient:
import asyncdispatch, nimflux
var data = DataPoint(measurement: "temp")
data.addTag("loc", "home")
data.addField("ambient", 22.0)
proc asyncProc(data: DataPoint): Future[AsyncResponse] {.async.} =
var client = newAsyncInfluxClient("localhost", "nimtest")
var resp = await client.write(data)
assert resp.code.toInfluxStatus == Ok
return await client.query("select * from temp")
echo asyncProc(data).waitFor().body.waitFor()