Skip to content

Commit

Permalink
docs(ilp): add ILP auth example (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrinot authored Aug 30, 2022
1 parent 2d927fc commit b761335
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
header: |-
Go client library [docs](https://pkg.go.dev/github.com/questdb/go-questdb-client)
and [repo](https://github.com/questdb/go-questdb-client).
- name: ilp-auth
lang: go
path: examples/auth/main.go
header: |-
Go client library [docs](https://pkg.go.dev/github.com/questdb/go-questdb-client)
and [repo](https://github.com/questdb/go-questdb-client).
auth:
kid: testUser1
d: 5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48
addr:
host: localhost
port: 9009
- name: ilp-auth-tls
lang: go
path: examples/auth-and-tls/main.go
Expand Down
47 changes: 47 additions & 0 deletions examples/auth/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"context"
"log"
"time"

qdb "github.com/questdb/go-questdb-client"
)

func main() {
ctx := context.TODO()
sender, err := qdb.NewLineSender(
ctx,
qdb.WithAddress("localhost:9009"),
qdb.WithAuth(
"testUser1",
"5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48"),
)
if err != nil {
log.Fatal(err)
}
// Make sure to close the sender on exit to release resources.
defer sender.Close()
// Send a few ILP messages.
err = sender.
Table("trades").
Symbol("name", "test_ilp1").
Float64Column("value", 12.4).
At(ctx, time.Now().UnixNano())
if err != nil {
log.Fatal(err)
}
err = sender.
Table("trades").
Symbol("name", "test_ilp2").
Float64Column("value", 11.4).
At(ctx, time.Now().UnixNano())
if err != nil {
log.Fatal(err)
}
// Make sure that the messages are sent over the network.
err = sender.Flush(ctx)
if err != nil {
log.Fatal(err)
}
}

0 comments on commit b761335

Please sign in to comment.