-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: write/query * refactor: removing external dependencies * refactor: types.gen pruned * refactor: returned dependency on lineprotocol * refactor: replaced codegen * fix: removed broken code * docs: README Usage updated * lint: fixed according to super-linter * docs: changelog * chore: update go for checking CVEs * test: write, client url * fix: close client after query * fix: retry strategy minDelay oveflow * test: unit tests * style: lint * chore: use direct * test: e2e tests * feat: removed retry * chore: rerun CI * fix: Apply suggestions from code review Co-authored-by: Jakub Bednář <[email protected]> * fix: renaming refactor * feat: iterator first iteration * test: e2e with iterator * feat: Retain flight client * test: fixed error message text * feat: removed NextValue from iterator * refactor: rename bucket to database * feat: example client close error escalation * feat: use insecure when http provided * docs: iterator README * Apply suggestions from code review Co-authored-by: Jakub Bednář <[email protected]> * feat: send database in context * fix: remove duplicit check on StatusCode * test: client increased coverage * test: client write, client * fix: fix url + test * test: TestWritePointsAndBytes fixed * fix: use queryParams * fix: compilation error --------- Co-authored-by: Jakub Bednar <[email protected]>
- Loading branch information
Showing
27 changed files
with
2,789 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ jobs: | |
- name: Scan for Vulnerabilities in Code | ||
uses: Templum/[email protected] | ||
with: | ||
go-version: 1.20.0 | ||
go-version: 1.20.4 | ||
vulncheck-version: v0.0.0-20230320232729-bfc1eaef17a4 | ||
package: ./... | ||
fail-on-vuln: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/.idea/ | ||
coverage.* | ||
coverage.* | ||
/.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"MD013": false, | ||
"MD033": { | ||
"allowed_elements": [ "a", "img", "p" ] | ||
"allowed_elements": [ "a", "img", "p", "details", "summary" ] | ||
}, | ||
"MD041": false, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
## 1.0.0 [unreleased] | ||
|
||
- initial release of new client version | ||
- write using v2 api | ||
- query using flightSQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/bonitoo-io/influxdb3-go/influx" | ||
) | ||
|
||
func main() { | ||
// Use env variables to initialize client | ||
url := os.Getenv("INFLUXDB_URL") | ||
token := os.Getenv("INFLUXDB_TOKEN") | ||
database := os.Getenv("INFLUXDB_DATABASE") | ||
|
||
// Create a new client using an InfluxDB server base URL and an authentication token | ||
client, err := influx.New(influx.Configs{ | ||
HostURL: url, | ||
AuthToken: token, | ||
}) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
// Close client at the end and escalate error if present | ||
defer func (client *influx.Client) { | ||
err := client.Close() | ||
if err != nil { | ||
panic(err) | ||
} | ||
}(client) | ||
|
||
// Create point using full params constructor | ||
p := influx.NewPoint("stat", | ||
map[string]string{"unit": "temperature"}, | ||
map[string]interface{}{"avg": 24.5, "max": 45.0}, | ||
time.Now()) | ||
// write point synchronously | ||
err = client.WritePoints(context.Background(), database, p) | ||
if err != nil { | ||
panic(err) | ||
} | ||
// Create point using fluent style | ||
p = influx.NewPointWithMeasurement("stat"). | ||
AddTag("unit", "temperature"). | ||
AddField("avg", 23.2). | ||
AddField("max", 45.0). | ||
SetTimestamp(time.Now()) | ||
// write point synchronously | ||
err = client.WritePoints(context.Background(), database, p) | ||
if err != nil { | ||
panic(err) | ||
} | ||
// Prepare custom type | ||
sensorData := struct { | ||
Table string `lp:"measurement"` | ||
Unit string `lp:"tag,unit"` | ||
Avg float64 `lp:"field,avg"` | ||
Max float64 `lp:"field,max"` | ||
Time time.Time `lp:"timestamp"` | ||
}{"stat", "temperature", 22.3, 40.3, time.Now()} | ||
// Write point | ||
err = client.WriteData(context.Background(), database, sensorData) | ||
if err != nil { | ||
panic(err) | ||
} | ||
// Or write directly line protocol | ||
line := fmt.Sprintf("stat,unit=temperature avg=%f,max=%f", 23.5, 45.0) | ||
err = client.Write(context.Background(), database, []byte(line)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Prepare FlightSQL query | ||
query := ` | ||
SELECT * | ||
FROM "stat" | ||
WHERE | ||
time >= now() - interval '5 minute' | ||
AND | ||
"unit" IN ('temperature') | ||
` | ||
|
||
iterator, err := client.Query(context.Background(), database, query) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for iterator.Next() { | ||
value := iterator.Value() | ||
|
||
fmt.Printf("avg is %f\n", value["avg"]) | ||
fmt.Printf("max is %f\n", value["max"]) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.