-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Added examples and manifest. (#4)
* chore: Added examples and manifest. * chore: Added repo to examples' headers. * Fix sample snippets * Document purpose of manifest * Add missing newline * Fix linter command * Change examples structure Co-authored-by: Andrey Pechkurov <[email protected]>
- Loading branch information
Showing
3 changed files
with
110 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# manifest file lets questdb.io find the examples and lets Cloud docs | ||
# substitute host/port and auth keys when auto-generating examples | ||
- name: ilp | ||
lang: go | ||
path: examples/basic/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). | ||
- name: ilp-auth-tls | ||
lang: go | ||
path: examples/auth-and-tls/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 |
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,48 @@ | ||
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"), | ||
qdb.WithTls(), | ||
) | ||
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) | ||
} | ||
} |
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,42 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
qdb "github.com/questdb/go-questdb-client" | ||
) | ||
|
||
func main() { | ||
ctx := context.TODO() | ||
// Connect to QuestDB running on 127.0.0.1:9009 | ||
sender, err := qdb.NewLineSender(ctx) | ||
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) | ||
} | ||
} |