Skip to content

Commit 3c68a47

Browse files
committed
copyright update, Api align with QuestDB terminology
1 parent 581c44d commit 3c68a47

File tree

4 files changed

+110
-48
lines changed

4 files changed

+110
-48
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
```c#
88
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), 9009);
9-
ls.Metric("metric_name")
10-
.Tag("tag", "value")
11-
.Field("number", 10)
12-
.Field("double", 12.23)
13-
.Field("string", "born to shine")
9+
ls.Table("metric_name")
10+
.Symbol("Symbol", "value")
11+
.Colum("number", 10)
12+
.Colum("double", 12.23)
13+
.Colum("string", "born to shine")
1414
.At(new DateTime(2021, 11, 25, 0, 46, 26));
1515
ls.Flush();
1616
```
@@ -22,7 +22,7 @@ using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), 9009);
2222
for(int i = 0; i < 1E6; i++)
2323
{
2424
ls.Metric("metric_name")
25-
.Field("counter", i)
25+
.Colum("counter", i)
2626
.AtNow();
2727
}
2828
ls.Flush();

src/net-questdb-client/LineTcpSender.cs

+39-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
using System;
1+
/*******************************************************************************
2+
* ___ _ ____ ____
3+
* / _ \ _ _ ___ ___| |_| _ \| __ )
4+
* | | | | | | |/ _ \/ __| __| | | | _ \
5+
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
6+
* \__\_\\__,_|\___||___/\__|____/|____/
7+
*
8+
* Copyright (c) 2014-2019 Appsicle
9+
* Copyright (c) 2019-2022 QuestDB
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*
23+
******************************************************************************/
24+
25+
using System;
226
using System.Globalization;
327
using System.Net.Sockets;
428
using System.Text;
@@ -24,7 +48,7 @@ public LineTcpSender(String address, int port, int bufferSize = 4096)
2448
_sendBuffer = new byte[bufferSize];
2549
}
2650

27-
public LineTcpSender Metric(ReadOnlySpan<char> name)
51+
public LineTcpSender Table(ReadOnlySpan<char> name)
2852
{
2953
if (_hasMetric)
3054
{
@@ -37,15 +61,15 @@ public LineTcpSender Metric(ReadOnlySpan<char> name)
3761
return this;
3862
}
3963

40-
public LineTcpSender Tag(ReadOnlySpan<char> tag, ReadOnlySpan<char> value) {
64+
public LineTcpSender Symbol(ReadOnlySpan<char> tag, ReadOnlySpan<char> value) {
4165
if (_hasMetric && _noFields) {
4266
Put(',').EncodeUtf8(tag).Put('=').EncodeUtf8(value);
4367
return this;
4468
}
4569
throw new InvalidOperationException("metric expected");
4670
}
4771

48-
private LineTcpSender Field(ReadOnlySpan<char> name) {
72+
private LineTcpSender Column(ReadOnlySpan<char> name) {
4973
if (_hasMetric) {
5074
if (_noFields) {
5175
Put(' ');
@@ -59,23 +83,23 @@ private LineTcpSender Field(ReadOnlySpan<char> name) {
5983
throw new InvalidOperationException("metric expected");
6084
}
6185

62-
public LineTcpSender Field(ReadOnlySpan<char> name, ReadOnlySpan<char> value)
86+
public LineTcpSender Column(ReadOnlySpan<char> name, ReadOnlySpan<char> value)
6387
{
64-
Field(name).Put('\"');
88+
Column(name).Put('\"');
6589
_quoted = true;
6690
EncodeUtf8(value);
6791
_quoted = false;
6892
Put('\"');
6993
return this;
7094
}
7195

72-
public LineTcpSender Field(ReadOnlySpan<char> name, long value) {
73-
Field(name).Put(value).Put('i');
96+
public LineTcpSender Column(ReadOnlySpan<char> name, long value) {
97+
Column(name).Put(value).Put('i');
7498
return this;
7599
}
76100

77-
public LineTcpSender Field(ReadOnlySpan<char> name, double value) {
78-
Field(name).Put(value.ToString(CultureInfo.InvariantCulture));
101+
public LineTcpSender Column(ReadOnlySpan<char> name, double value) {
102+
Column(name).Put(value.ToString(CultureInfo.InvariantCulture));
79103
return this;
80104
}
81105

@@ -234,5 +258,10 @@ public void At(DateTime timestamp)
234258
long epoch = timestamp.Ticks - EpochTicks;
235259
Put(' ').Put(epoch).Put('0').Put('0').AtNow();
236260
}
261+
262+
public void At(long epochNano)
263+
{
264+
Put(' ').Put(epochNano).AtNow();
265+
}
237266
}
238267
}

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

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
<Nullable>enable</Nullable>
77
<LangVersion>10</LangVersion>
88
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
9+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10+
<Title>QuestDB client</Title>
11+
<Description>Simple QuestDB ILP protocol client</Description>
12+
<Copyright>QuesetDB</Copyright>
13+
<PackageProjectUrl>https://questdb.io</PackageProjectUrl>
14+
<PackageLicenseUrl>Apache 2.0</PackageLicenseUrl>
15+
<RepositoryUrl>https://github.com/questdb/net-questdb-client</RepositoryUrl>
16+
<PackageTags>QuestDB, ILP</PackageTags>
17+
<Company>QuestDB Limited</Company>
918
</PropertyGroup>
1019

1120
</Project>

src/tcp-client-test/LineTcpSenderTests.cs

+56-32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*******************************************************************************
2+
* ___ _ ____ ____
3+
* / _ \ _ _ ___ ___| |_| _ \| __ )
4+
* | | | | | | |/ _ \/ __| __| | | | _ \
5+
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
6+
* \__\_\\__,_|\___||___/\__|____/|____/
7+
*
8+
* Copyright (c) 2014-2019 Appsicle
9+
* Copyright (c) 2019-2022 QuestDB
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*
23+
******************************************************************************/
24+
125
using System;
226
using System.IO;
327
using System.Net;
@@ -22,10 +46,10 @@ public void SendLine()
2246
srv.AcceptAsync();
2347

2448
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port);
25-
ls.Metric("metric name")
26-
.Tag("t a g", "v alu, e")
27-
.Field("number", 10)
28-
.Field("string", " -=\"")
49+
ls.Table("metric name")
50+
.Symbol("t a g", "v alu, e")
51+
.Column("number", 10)
52+
.Column("string", " -=\"")
2953
.At(new DateTime(1970, 01, 01, 0, 0, 1));
3054
ls.Flush();
3155

@@ -46,12 +70,12 @@ public void SendLineExceedsBuffer()
4670
var totalExpectedSb = new StringBuilder();
4771
for (int i = 0; i < lineCount; i++)
4872
{
49-
ls.Metric("metric name")
50-
.Tag("t a g", "v alu, e")
51-
.Field("number", 10)
52-
.Field("db l", 123.12)
53-
.Field("string", " -=\"")
54-
.Field("при вед", "медвед")
73+
ls.Table("metric name")
74+
.Symbol("t a g", "v alu, e")
75+
.Column("number", 10)
76+
.Column("db l", 123.12)
77+
.Column("string", " -=\"")
78+
.Column("при вед", "медвед")
5579
.At(new DateTime(1970, 01, 01, 0, 0, 1));
5680
totalExpectedSb.Append(expected);
5781
}
@@ -68,11 +92,11 @@ public void SendNegativeLongAndDouble()
6892
srv.AcceptAsync();
6993

7094
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port);
71-
ls.Metric("neg\\name")
72-
.Field("number1", long.MinValue + 1)
73-
.Field("number2", long.MaxValue)
74-
.Field("number3", double.MinValue)
75-
.Field("number4", double.MaxValue)
95+
ls.Table("neg\\name")
96+
.Column("number1", long.MinValue + 1)
97+
.Column("number2", long.MaxValue)
98+
.Column("number3", double.MinValue)
99+
.Column("number4", double.MaxValue)
76100
.AtNow();
77101
ls.Flush();
78102

@@ -92,11 +116,11 @@ public void SendMillionToFile()
92116
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port, 2048);
93117
for(int i = 0; i < 1E6; i++)
94118
{
95-
ls.Metric(metric)
96-
.Tag("nopoint", "tag" + i%100 )
97-
.Field("counter", i * 1111.1)
98-
.Field("int", i)
99-
.Field("привед", "мед вед")
119+
ls.Table(metric)
120+
.Symbol("nopoint", "tag" + i%100 )
121+
.Column("counter", i * 1111.1)
122+
.Column("int", i)
123+
.Column("привед", "мед вед")
100124
.At(new DateTime(2021, 1, 1, (i/360/1000) % 60, (i/60/1000) % 60, (i / 1000) % 60, i % 1000));
101125
}
102126
ls.Flush();
@@ -123,8 +147,8 @@ public void SendNegativeLongMin()
123147

124148
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port);
125149
Assert.Throws<ArgumentOutOfRangeException>(
126-
() => ls.Metric("name")
127-
.Field("number1", long.MinValue)
150+
() => ls.Table("name")
151+
.Column("number1", long.MinValue)
128152
.AtNow()
129153
);
130154
}
@@ -136,8 +160,8 @@ public void SendSpecialStrings()
136160
srv.AcceptAsync();
137161

138162
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port);
139-
ls.Metric("neg\\name")
140-
.Field("привед", " мед\rве\n д")
163+
ls.Table("neg\\name")
164+
.Column("привед", " мед\rве\n д")
141165
.AtNow();
142166
ls.Flush();
143167

@@ -153,9 +177,9 @@ public void SendTagAfterField()
153177

154178
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port);
155179
Assert.Throws<InvalidOperationException>(
156-
() => ls.Metric("name")
157-
.Field("number1", 123)
158-
.Tag("nand", "asdfa")
180+
() => ls.Table("name")
181+
.Column("number1", 123)
182+
.Symbol("nand", "asdfa")
159183
.AtNow()
160184
);
161185
}
@@ -168,9 +192,9 @@ public void SendMetricOnce()
168192

169193
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port);
170194
Assert.Throws<InvalidOperationException>(
171-
() => ls.Metric("name")
172-
.Field("number1", 123)
173-
.Metric("nand")
195+
() => ls.Table("name")
196+
.Column("number1", 123)
197+
.Table("nand")
174198
.AtNow()
175199
);
176200
}
@@ -183,12 +207,12 @@ public void StartFromMetric()
183207

184208
using var ls = new LineTcpSender(IPAddress.Loopback.ToString(), _port);
185209
Assert.Throws<InvalidOperationException>(
186-
() => ls.Field("number1", 123)
210+
() => ls.Column("number1", 123)
187211
.AtNow()
188212
);
189213

190214
Assert.Throws<InvalidOperationException>(
191-
() => ls.Tag("number1", "1234")
215+
() => ls.Symbol("number1", "1234")
192216
.AtNow()
193217
);
194218
}

0 commit comments

Comments
 (0)