Skip to content

Commit 5cf0035

Browse files
committed
Improve readme
1 parent 167bd92 commit 5cf0035

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Golang client for QuestDB's [Influx Line Protocol](https://questdb.io/docs/refer
99
The library requires Go 1.19 or newer.
1010

1111
Features:
12-
* Context-aware API.
12+
* [Context](https://www.digitalocean.com/community/tutorials/how-to-use-contexts-in-go)-aware API.
1313
* Optimized for batch writes.
1414
* Supports TLS encryption and ILP authentication.
1515
* Automatic write retries and connection reuse for ILP over HTTP.
@@ -43,23 +43,40 @@ func main() {
4343
}
4444
// Make sure to close the sender on exit to release resources.
4545
defer sender.Close(ctx)
46+
4647
// Send a few ILP messages.
48+
tradedTs, err := time.Parse(time.RFC3339, "2022-08-06T15:04:05.123456Z")
49+
if err != nil {
50+
log.Fatal(err)
51+
}
4752
err = sender.
48-
Table("trades").
49-
Symbol("name", "test_ilp1").
50-
Float64Column("value", 12.4).
51-
AtNow(ctx)
53+
Table("trades_go").
54+
Symbol("pair", "USDGBP").
55+
Symbol("type", "buy").
56+
Float64Column("traded_price", 0.83).
57+
Float64Column("limit_price", 0.84).
58+
Int64Column("qty", 100).
59+
At(ctx, tradedTs)
60+
if err != nil {
61+
log.Fatal(err)
62+
}
63+
64+
tradedTs, err = time.Parse(time.RFC3339, "2022-08-06T15:04:06.987654Z")
5265
if err != nil {
5366
log.Fatal(err)
5467
}
5568
err = sender.
56-
Table("trades").
57-
Symbol("name", "test_ilp2").
58-
Float64Column("value", 11.4).
59-
At(ctx, time.Now().UnixNano())
69+
Table("trades_go").
70+
Symbol("pair", "GBPJPY").
71+
Symbol("type", "sell").
72+
Float64Column("traded_price", 135.97).
73+
Float64Column("limit_price", 0.84).
74+
Int64Column("qty", 400).
75+
At(ctx, tradedTs)
6076
if err != nil {
6177
log.Fatal(err)
6278
}
79+
6380
// Make sure that the messages are sent over the network.
6481
err = sender.Flush(ctx)
6582
if err != nil {

0 commit comments

Comments
 (0)