Skip to content

Commit 2828a0f

Browse files
committed
chore(nodejs): config object for Sender
1 parent 6b6b3b2 commit 2828a0f

File tree

13 files changed

+224
-155
lines changed

13 files changed

+224
-155
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { Sender } = require("@questdb/nodejs-client");
1414
async function run() {
1515
// create a sender with a 4k buffer
1616
// it is important to size the buffer correctly so messages can fit
17-
const sender = new Sender(4096);
17+
const sender = new Sender({bufferSize: 4096});
1818

1919
// connect to QuestDB
2020
// host and port are required in connect options
@@ -65,7 +65,7 @@ async function run() {
6565

6666
// pass the JsonWebKey to the sender
6767
// will use it for authentication
68-
const sender = new Sender(4096, JWK);
68+
const sender = new Sender({bufferSize: 4096, jwk: JWK});
6969

7070
// connect() takes an optional second argument
7171
// if 'true' passed the connection is secured with TLS encryption
@@ -106,7 +106,7 @@ async function run(): Promise<number> {
106106

107107
// pass the JsonWebKey to the sender
108108
// will use it for authentication
109-
const sender: Sender = new Sender(4096, JWK);
109+
const sender: Sender = new Sender({bufferSize: 4096, jwk: JWK});
110110

111111
// connect() takes an optional second argument
112112
// if 'true' passed the connection is secured with TLS encryption

docs/Sender.html

Lines changed: 57 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="page-title">Class: Sender</h1>
2828

2929
<header>
3030

31-
<h2><span class="attribs"><span class="type-signature"></span></span>Sender<span class="signature">(bufferSize, jwk<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h2>
31+
<h2><span class="attribs"><span class="type-signature"></span></span>Sender<span class="signature">(options)</span><span class="type-signature"></span></h2>
3232

3333
<div class="class-description">The QuestDB client's API provides methods to connect to the database, ingest data and close the connection.
3434
<p>
@@ -55,7 +55,7 @@ <h2>Constructor</h2>
5555

5656

5757

58-
<h4 class="name" id="Sender"><span class="type-signature"></span>new Sender<span class="signature">(bufferSize, jwk<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
58+
<h4 class="name" id="Sender"><span class="type-signature"></span>new Sender<span class="signature">(options)</span><span class="type-signature"></span></h4>
5959

6060

6161

@@ -87,8 +87,6 @@ <h5>Parameters:</h5>
8787
<th>Type</th>
8888

8989

90-
<th>Attributes</th>
91-
9290

9391

9492

@@ -101,64 +99,32 @@ <h5>Parameters:</h5>
10199

102100
<tr>
103101

104-
<td class="name"><code>bufferSize</code></td>
102+
<td class="name"><code>options</code></td>
105103

106104

107105
<td class="type">
108106

109107

110-
<span class="param-type">number</span>
108+
<span class="param-type">object</span>
111109

112110

113111

114112
</td>
115113

116114

117-
<td class="attributes">
118-
119-
120-
121-
122-
123-
</td>
124-
125115

126116

127117

128-
<td class="description last">Size of the buffer used by the sender to collect rows, provided in bytes.</td>
129-
</tr>
130-
131-
132-
133-
<tr>
134-
135-
<td class="name"><code>jwk</code></td>
136-
137-
138-
<td class="type">
139-
140-
141-
<span class="param-type">Object</span>
142-
143-
144-
145-
</td>
146-
147-
148-
<td class="attributes">
149-
150-
&lt;optional><br>
151-
152-
153-
154-
155-
156-
</td>
157-
158-
159-
160-
161-
<td class="description last">JWK for authentication, client is not authenticated if not provided. <br> Server might reject the connection depending on configuration.</td>
118+
<td class="description last">Configuration options. <br>
119+
<p>
120+
Properties of the object:
121+
<ul>
122+
<li>bufferSize: <i>number</i> - Size of the buffer used by the sender to collect rows, provided in bytes. <br>
123+
Optional, defaults to 8192 bytes </li>
124+
<li>jwk: <i>{x: string, y: string, kid: string, kty: string, d: string, crv: string}</i> - JsonWebKey for authentication. <br>
125+
If not provided, client is not authenticated and server might reject the connection depending on configuration.</li>
126+
</ul>
127+
</p></td>
162128
</tr>
163129

164130

@@ -199,7 +165,7 @@ <h5>Parameters:</h5>
199165

200166
<dt class="tag-source">Source:</dt>
201167
<dd class="tag-source"><ul class="dummy"><li>
202-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line22">line 22</a>
168+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line24">line 24</a>
203169
</li></ul></dd>
204170

205171

@@ -356,7 +322,7 @@ <h5>Parameters:</h5>
356322

357323
<dt class="tag-source">Source:</dt>
358324
<dd class="tag-source"><ul class="dummy"><li>
359-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line289">line 289</a>
325+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line323">line 323</a>
360326
</li></ul></dd>
361327

362328

@@ -445,7 +411,7 @@ <h4 class="name" id="atNow"><span class="type-signature"></span>atNow<span class
445411

446412
<dt class="tag-source">Source:</dt>
447413
<dd class="tag-source"><ul class="dummy"><li>
448-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line307">line 307</a>
414+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line343">line 343</a>
449415
</li></ul></dd>
450416

451417

@@ -605,7 +571,7 @@ <h5>Parameters:</h5>
605571

606572
<dt class="tag-source">Source:</dt>
607573
<dd class="tag-source"><ul class="dummy"><li>
608-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line227">line 227</a>
574+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line254">line 254</a>
609575
</li></ul></dd>
610576

611577

@@ -716,7 +682,7 @@ <h4 class="name" id="close"><span class="type-signature">(async) </span>close<sp
716682

717683
<dt class="tag-source">Source:</dt>
718684
<dd class="tag-source"><ul class="dummy"><li>
719-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line128">line 128</a>
685+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line149">line 149</a>
720686
</li></ul></dd>
721687

722688

@@ -911,7 +877,7 @@ <h5>Parameters:</h5>
911877

912878
<dt class="tag-source">Source:</dt>
913879
<dd class="tag-source"><ul class="dummy"><li>
914-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line74">line 74</a>
880+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line92">line 92</a>
915881
</li></ul></dd>
916882

917883

@@ -1071,7 +1037,7 @@ <h5>Parameters:</h5>
10711037

10721038
<dt class="tag-source">Source:</dt>
10731039
<dd class="tag-source"><ul class="dummy"><li>
1074-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line241">line 241</a>
1040+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line269">line 269</a>
10751041
</li></ul></dd>
10761042

10771043

@@ -1129,15 +1095,16 @@ <h5>Returns:</h5>
11291095

11301096

11311097

1132-
<h4 class="name" id="flush"><span class="type-signature">(async) </span>flush<span class="signature">()</span><span class="type-signature"></span></h4>
1098+
<h4 class="name" id="flush"><span class="type-signature">(async) </span>flush<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
11331099

11341100

11351101

11361102

11371103

11381104

11391105
<div class="description">
1140-
Sends the buffer's content to the database and clears the buffer.
1106+
Sends the buffer's content to the database and compacts the buffer.
1107+
If the last row is not finished it stays in the sender's buffer.
11411108
</div>
11421109

11431110

@@ -1181,7 +1148,7 @@ <h4 class="name" id="flush"><span class="type-signature">(async) </span>flush<sp
11811148

11821149
<dt class="tag-source">Source:</dt>
11831150
<dd class="tag-source"><ul class="dummy"><li>
1184-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line138">line 138</a>
1151+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line162">line 162</a>
11851152
</li></ul></dd>
11861153

11871154

@@ -1206,6 +1173,28 @@ <h4 class="name" id="flush"><span class="type-signature">(async) </span>flush<sp
12061173

12071174

12081175

1176+
<h5>Returns:</h5>
1177+
1178+
1179+
<div class="param-desc">
1180+
Returns true if there was data in the buffer to send.
1181+
</div>
1182+
1183+
1184+
1185+
<dl>
1186+
<dt>
1187+
Type
1188+
</dt>
1189+
<dd>
1190+
1191+
<span class="param-type">boolean</span>
1192+
1193+
1194+
</dd>
1195+
</dl>
1196+
1197+
12091198

12101199

12111200

@@ -1341,7 +1330,7 @@ <h5>Parameters:</h5>
13411330

13421331
<dt class="tag-source">Source:</dt>
13431332
<dd class="tag-source"><ul class="dummy"><li>
1344-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line255">line 255</a>
1333+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line285">line 285</a>
13451334
</li></ul></dd>
13461335

13471336

@@ -1452,7 +1441,7 @@ <h4 class="name" id="reset"><span class="type-signature"></span>reset<span class
14521441

14531442
<dt class="tag-source">Source:</dt>
14541443
<dd class="tag-source"><ul class="dummy"><li>
1455-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line62">line 62</a>
1444+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line80">line 80</a>
14561445
</li></ul></dd>
14571446

14581447

@@ -1518,8 +1507,9 @@ <h4 class="name" id="resize"><span class="type-signature"></span>resize<span cla
15181507

15191508

15201509
<div class="description">
1521-
Reinitializes the buffer of the sender. <br>
1510+
Extends the size of the sender's buffer. <br>
15221511
Can be used to increase the size of buffer if overflown.
1512+
The buffer's content is copied into the new buffer.
15231513
</div>
15241514

15251515

@@ -1612,7 +1602,7 @@ <h5>Parameters:</h5>
16121602

16131603
<dt class="tag-source">Source:</dt>
16141604
<dd class="tag-source"><ul class="dummy"><li>
1615-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line50">line 50</a>
1605+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line65">line 65</a>
16161606
</li></ul></dd>
16171607

16181608

@@ -1772,7 +1762,7 @@ <h5>Parameters:</h5>
17721762

17731763
<dt class="tag-source">Source:</dt>
17741764
<dd class="tag-source"><ul class="dummy"><li>
1775-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line211">line 211</a>
1765+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line237">line 237</a>
17761766
</li></ul></dd>
17771767

17781768

@@ -1954,7 +1944,7 @@ <h5>Parameters:</h5>
19541944

19551945
<dt class="tag-source">Source:</dt>
19561946
<dd class="tag-source"><ul class="dummy"><li>
1957-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line188">line 188</a>
1947+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line212">line 212</a>
19581948
</li></ul></dd>
19591949

19601950

@@ -2113,7 +2103,7 @@ <h5>Parameters:</h5>
21132103

21142104
<dt class="tag-source">Source:</dt>
21152105
<dd class="tag-source"><ul class="dummy"><li>
2116-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line168">line 168</a>
2106+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line191">line 191</a>
21172107
</li></ul></dd>
21182108

21192109

@@ -2295,7 +2285,7 @@ <h5>Parameters:</h5>
22952285

22962286
<dt class="tag-source">Source:</dt>
22972287
<dd class="tag-source"><ul class="dummy"><li>
2298-
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line273">line 273</a>
2288+
<a href="src_sender.js.html">src/sender.js</a>, <a href="src_sender.js.html#line305">line 305</a>
22992289
</li></ul></dd>
23002290

23012291

@@ -2369,7 +2359,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-@q
23692359
<br class="clear">
23702360

23712361
<footer>
2372-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Aug 12 2022 08:59:08 GMT+0100 (British Summer Time)
2362+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Aug 15 2022 11:08:10 GMT+0100 (British Summer Time)
23732363
</footer>
23742364

23752365
<script> prettyPrint(); </script>

docs/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h3>Basic API usage</h3>
5454
async function run() {
5555
// create a sender with a 4k buffer
5656
// it is important to size the buffer correctly so messages can fit
57-
const sender = new Sender(4096);
57+
const sender = new Sender({bufferSize: 4096});
5858

5959
// connect to QuestDB
6060
// host and port are required in connect options
@@ -103,7 +103,7 @@ <h3>Authentication and secure connection</h3>
103103

104104
// pass the JsonWebKey to the sender
105105
// will use it for authentication
106-
const sender = new Sender(4096, JWK);
106+
const sender = new Sender({bufferSize: 4096, jwk: JWK});
107107

108108
// connect() takes an optional second argument
109109
// if 'true' passed the connection is secured with TLS encryption
@@ -142,7 +142,7 @@ <h3>TypeScript example</h3>
142142

143143
// pass the JsonWebKey to the sender
144144
// will use it for authentication
145-
const sender: Sender = new Sender(4096, JWK);
145+
const sender: Sender = new Sender({bufferSize: 4096, jwk: JWK});
146146

147147
// connect() takes an optional second argument
148148
// if 'true' passed the connection is secured with TLS encryption
@@ -176,7 +176,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-@q
176176
<br class="clear">
177177

178178
<footer>
179-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Aug 12 2022 08:59:08 GMT+0100 (British Summer Time)
179+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Aug 15 2022 11:08:10 GMT+0100 (British Summer Time)
180180
</footer>
181181

182182
<script> prettyPrint(); </script>

docs/index.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-@q
5353
<br class="clear">
5454

5555
<footer>
56-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Aug 12 2022 08:59:08 GMT+0100 (British Summer Time)
56+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Aug 15 2022 11:08:10 GMT+0100 (British Summer Time)
5757
</footer>
5858

5959
<script> prettyPrint(); </script>

docs/module-@questdb_nodejs-client.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-@q
156156
<br class="clear">
157157

158158
<footer>
159-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Fri Aug 12 2022 08:59:08 GMT+0100 (British Summer Time)
159+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Aug 15 2022 11:08:10 GMT+0100 (British Summer Time)
160160
</footer>
161161

162162
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)