Skip to content

Commit b761335

Browse files
authored
docs(ilp): add ILP auth example (#5)
1 parent 2d927fc commit b761335

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

examples.manifest.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
header: |-
77
Go client library [docs](https://pkg.go.dev/github.com/questdb/go-questdb-client)
88
and [repo](https://github.com/questdb/go-questdb-client).
9+
- name: ilp-auth
10+
lang: go
11+
path: examples/auth/main.go
12+
header: |-
13+
Go client library [docs](https://pkg.go.dev/github.com/questdb/go-questdb-client)
14+
and [repo](https://github.com/questdb/go-questdb-client).
15+
auth:
16+
kid: testUser1
17+
d: 5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48
18+
addr:
19+
host: localhost
20+
port: 9009
921
- name: ilp-auth-tls
1022
lang: go
1123
path: examples/auth-and-tls/main.go

examples/auth/main.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"log"
6+
"time"
7+
8+
qdb "github.com/questdb/go-questdb-client"
9+
)
10+
11+
func main() {
12+
ctx := context.TODO()
13+
sender, err := qdb.NewLineSender(
14+
ctx,
15+
qdb.WithAddress("localhost:9009"),
16+
qdb.WithAuth(
17+
"testUser1",
18+
"5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48"),
19+
)
20+
if err != nil {
21+
log.Fatal(err)
22+
}
23+
// Make sure to close the sender on exit to release resources.
24+
defer sender.Close()
25+
// Send a few ILP messages.
26+
err = sender.
27+
Table("trades").
28+
Symbol("name", "test_ilp1").
29+
Float64Column("value", 12.4).
30+
At(ctx, time.Now().UnixNano())
31+
if err != nil {
32+
log.Fatal(err)
33+
}
34+
err = sender.
35+
Table("trades").
36+
Symbol("name", "test_ilp2").
37+
Float64Column("value", 11.4).
38+
At(ctx, time.Now().UnixNano())
39+
if err != nil {
40+
log.Fatal(err)
41+
}
42+
// Make sure that the messages are sent over the network.
43+
err = sender.Flush(ctx)
44+
if err != nil {
45+
log.Fatal(err)
46+
}
47+
}

0 commit comments

Comments
 (0)