Skip to content

Commit 3c16712

Browse files
authored
chore: changed examples and added multiple framework version targets (#28)
* changing examples to use trades and target multiple .net versions * tests target multiple framework versions now * changed AtNow. Brought back sync example on README
1 parent ddfc751 commit 3c16712

File tree

11 files changed

+70
-65
lines changed

11 files changed

+70
-65
lines changed

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,28 @@ See more in-depth documentation [here](https://questdb.io/docs/clients/ingest-do
4040
### Basic usage
4141

4242
```csharp
43-
using var sender = Sender.New("http::addr=localhost:9000;");
44-
await sender.Table("metric_name")
45-
.Symbol("Symbol", "value")
46-
.Column("number", 10)
47-
.Column("double", 12.23)
48-
.Column("string", "born to shine")
43+
using var sender = Sender.New("http::addr=localhost:9000;");
44+
await sender.Table("trades")
45+
.Symbol("symbol", "ETH-USD")
46+
.Symbol("side", "sell")
47+
.Column("price", 2615.54)
48+
.Column("amount", 0.00044)
4949
.AtAsync(new DateTime(2021, 11, 25, 0, 46, 26));
5050
await sender.SendAsync();
5151
```
5252

5353
### Multi-line send (sync)
5454

5555
```csharp
56-
using var sender = Sender.New("http::addr=localhost:9000;auto_flush=off;");
56+
using var sender = Sender.New("http::addr=localhost:9000;");
5757
for(int i = 0; i < 100; i++)
5858
{
59-
sender.Table("metric_name")
60-
.Column("counter", i)
61-
.AtNow();
59+
sender.Table("trades")
60+
.Symbol("symbol", "ETH-USD")
61+
.Symbol("side", "sell")
62+
.Column("price", 2615.54)
63+
.Column("amount", 0.00044)
64+
.At(DateTime.UtcNow);
6265
}
6366
sender.Send();
6467
```
@@ -107,13 +110,13 @@ using var sender = Sender.New("http::addr=localhost:9000;auto_flush=on;auto_flus
107110
#### HTTP Authentication (Basic)
108111

109112
```csharp
110-
using var sender = Sender.New("https::addr=localhost:9009;tls_verify=unsafe_off;username=admin;password=quest;");;
113+
using var sender = Sender.New("https::addr=localhost:9009;tls_verify=unsafe_off;username=admin;password=quest;");
111114
```
112115

113116
#### HTTP Authentication (Token)
114117

115118
```csharp
116-
using var sender = Sender.New("https::addr=localhost:9009;tls_verify=unsafe_off;username=admin;token=<bearer token>");;
119+
using var sender = Sender.New("https::addr=localhost:9009;tls_verify=unsafe_off;username=admin;token=<bearer token>");
117120
```
118121

119122
#### TCP Authentication

src/example-auth-http-tls/Program.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33

44
// Runs against QuestDB Enterprise, demonstrating HTTPS and Basic Authentication support.
5+
// Disabling tls verification. Note this is not a best practice in production
56

67
using var sender =
78
Sender.New("https::addr=localhost:9000;tls_verify=unsafe_off;username=admin;password=quest;");
8-
await sender.Table("trades_dotnet")
9-
.Symbol("pair", "USDGBP")
10-
.Symbol("type", "buy")
11-
.Column("traded_price", 0.83)
12-
.Column("limit_price", 0.84)
13-
.Column("qty", 100)
14-
.Column("traded_ts", new DateTime(
15-
2022, 8, 6, 7, 35, 23, 189, DateTimeKind.Utc))
9+
// See: https://questdb.io/docs/operations/rbac/#authentication
10+
11+
await sender.Table("trades")
12+
.Symbol("symbol", "ETH-USD")
13+
.Symbol("side", "sell")
14+
.Column("price", 2615.54)
15+
.Column("amount", 0.00044)
1616
.AtAsync(DateTime.UtcNow);
17-
await sender.Table("trades_dotnet")
18-
.Symbol("pair", "GBPJPY")
19-
.Column("traded_price", 135.97)
20-
.Column("qty", 400)
17+
18+
await sender.Table("trades")
19+
.Symbol("symbol", "BTC-USD")
20+
.Symbol("side", "sell")
21+
.Column("price", 39269.98)
22+
.Column("amount", 0.001)
2123
.AtAsync(DateTime.UtcNow);
22-
await sender.SendAsync();
24+
25+
await sender.SendAsync();

src/example-auth-http-tls/example-auth-http-tls.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
66
<RootNamespace>example_auth_http_tls</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>

src/example-auth-tls/Program.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33

44

55
// Demonstrates TCPS connection against QuestDB Enterprise
6+
// Disabling tls verification. Note this is not a best practice in production
67

78
using var sender =
89
Sender.New(
910
"tcps::addr=localhost:9009;tls_verify=unsafe_off;username=admin;token=NgdiOWDoQNUP18WOnb1xkkEG5TzPYMda5SiUOvT1K0U=;");
10-
// See: https://questdb.io/docs/reference/api/ilp/authenticate
11-
await sender.Table("trades_dotnet")
12-
.Symbol("pair", "USDGBP")
13-
.Symbol("type", "buy")
14-
.Column("traded_price", 0.83)
15-
.Column("limit_price", 0.84)
16-
.Column("qty", 100)
17-
.Column("traded_ts", new DateTime(
18-
2022, 8, 6, 7, 35, 23, 189, DateTimeKind.Utc))
11+
// See: https://questdb.io/docs/operations/rbac/#authentication
12+
13+
await sender.Table("trades")
14+
.Symbol("symbol", "ETH-USD")
15+
.Symbol("side", "sell")
16+
.Column("price", 2615.54)
17+
.Column("amount", 0.00044)
1918
.AtAsync(DateTime.UtcNow);
20-
await sender.Table("trades_dotnet")
21-
.Symbol("pair", "GBPJPY")
22-
.Column("traded_price", 135.97)
23-
.Column("qty", 400)
19+
20+
await sender.Table("trades")
21+
.Symbol("symbol", "BTC-USD")
22+
.Symbol("side", "sell")
23+
.Column("price", 39269.98)
24+
.Column("amount", 0.001)
2425
.AtAsync(DateTime.UtcNow);
26+
2527
await sender.SendAsync();
2628

src/example-auth-tls/example-auth-tls.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
88
<Title>QuestDB client - Example with Authentication and TLS</Title>
99
<Description>Authentication and TLS example using the QuestDB ILP protocol client</Description>
10-
<TargetFramework>net6.0</TargetFramework>
10+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
1111
<OutputType>Exe</OutputType>
1212
</PropertyGroup>
1313

src/example-basic/Program.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
using QuestDB;
33

44
using var sender = Sender.New("http::addr=localhost:9000;");
5-
await sender.Table("trades_dotnet")
6-
.Symbol("pair", "USDGBP")
7-
.Symbol("type", "buy")
8-
.Column("traded_price", 0.83)
9-
.Column("limit_price", 0.84)
10-
.Column("qty", 100)
11-
.Column("traded_ts", new DateTime(
12-
2022, 8, 6, 7, 35, 23, 189, DateTimeKind.Utc))
5+
await sender.Table("trades")
6+
.Symbol("symbol", "ETH-USD")
7+
.Symbol("side", "sell")
8+
.Column("price", 2615.54)
9+
.Column("amount", 0.00044)
1310
.AtAsync(DateTime.UtcNow);
14-
await sender.Table("trades_dotnet")
15-
.Symbol("pair", "GBPJPY")
16-
.Column("traded_price", 135.97)
17-
.Column("qty", 400)
11+
12+
await sender.Table("trades")
13+
.Symbol("symbol", "BTC-USD")
14+
.Symbol("side", "sell")
15+
.Column("price", 39269.98)
16+
.Column("amount", 0.001)
1817
.AtAsync(DateTime.UtcNow);
18+
1919
await sender.SendAsync();

src/example-basic/example-basic.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
88
<Title>QuestDB client - Basic Example</Title>
99
<Description>Basic example using the QuestDB ILP protocol client</Description>
10-
<TargetFramework>net6.0</TargetFramework>
10+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
1111
<OutputType>Exe</OutputType>
1212
</PropertyGroup>
1313

src/example-streaming/Program.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010

1111
for (var i = 0; i < rowsToSend; i++)
1212
{
13-
await sender.Table("trades_dotnet")
14-
.Symbol("pair", "USDGBP")
15-
.Symbol("type", "buy")
16-
.Column("traded_price", 0.83)
17-
.Column("limit_price", 0.84)
18-
.Column("qty", 100)
19-
.Column("traded_ts", new DateTime(
20-
2022, 8, 6, 7, 35, 23, 189, DateTimeKind.Utc))
13+
await sender.Table("trades")
14+
.Symbol("symbol", "ETH-USD")
15+
.Symbol("side", "sell")
16+
.Column("price", 2615.54)
17+
.Column("amount", 0.00044)
2118
.AtAsync(DateTime.UtcNow);
2219
}
2320

@@ -28,4 +25,4 @@ await sender.Table("trades_dotnet")
2825
timer.Stop();
2926

3027
Console.WriteLine(
31-
$"Wrote {rowsToSend} rows in {timer.Elapsed.TotalSeconds} seconds at a rate of {rowsToSend / timer.Elapsed.TotalSeconds} rows/second.");
28+
$"Wrote {rowsToSend} rows in {timer.Elapsed.TotalSeconds} seconds at a rate of {rowsToSend / timer.Elapsed.TotalSeconds} rows/second.");

src/example-streaming/example-streaming.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
66
<RootNamespace>example_streaming</RootNamespace>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>

src/net-questdb-client-tests/net-questdb-client-tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
55
<RootNamespace>net_questdb_client_tests</RootNamespace>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

src/tcp-client-test/tcp-client-test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<RootNamespace>tcp_client_test</RootNamespace>
55
<Nullable>enable</Nullable>
66
<IsPackable>false</IsPackable>
7-
<TargetFramework>net6.0</TargetFramework>
7+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
88
<OutputType>Library</OutputType>
99
</PropertyGroup>
1010

0 commit comments

Comments
 (0)