Skip to content

Commit 452f2ac

Browse files
committed
More internal documentation
1 parent ee439f7 commit 452f2ac

2 files changed

Lines changed: 100 additions & 0 deletions

File tree

docs/src/internal/SUMMARY.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Summary
22

3+
## Used shortcuts
4+
5+
Within this document (and internal code documentation) I may use informal names for different products.
6+
Here you can find a list of those names in all their variants, with the versions we decided on in user-facing parts of the driver.
7+
8+
JS - JavaScript
9+
TS - TypeScript
10+
11+
Node, NodeJs. Official: [Node.js](https://nodejs.org/)
12+
13+
Napi, NodeAPI, Napi-rs: see [napi.md](./napi.md#distinction). Official [Node-API](https://nodejs.org/api/n-api.html) and [NAPI-RS](https://napi.rs/).
14+
15+
DSx: Official: [DataStax](https://www.ibm.com/products/datastax)
16+
17+
DSx driver, old driver, DataStax driver, cassandra driver. Official:
18+
[cassandra-driver/cassandra-nodejs-driver](https://github.com/apache/cassandra-nodejs-driver)
19+
(The version depends on whether the language of the driver is obvious).
20+
This driver was initially developed by DSx and was transferred to Apache during development of this driver.
21+
For this reason some places may use the name referring to DSx. Any remaining public documentation should refer to this driver as
22+
`cassandra-driver`, with possible annotation like: `formerly known as DataStax Node.js Driver` (see main [README.md](../../../README.md)).
23+
24+
this driver, new driver, scylladb-driver, scylladb-driver-alpha. Official: ScyllaDB Node.js-RS Driver / scylladb-driver-alpha / nodejs-rs-driver
25+
(standalone name / package name / repository name). Confusing? No worries, this repo probably breaks this convention quite a lot.
26+
27+
## Sections
28+
329
- [Errors](./error_throwing.md)
430
- [ParameterWrapper](./parameter_wrapper.md)
531
- [Query options overview](./query_options.md)
32+
- [Miscellaneous](./miscellaneous.md)
33+
- [Napi](./napi.md)

docs/src/internal/miscellaneous.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Miscellaneous stuff
2+
3+
## DataStax API
4+
5+
DSx driver had some external APIs that were related to DSx-specific features:
6+
7+
- Custom auth providers
8+
- The entire datastax & geometry modules
9+
- Some client / query options
10+
11+
How did we handle those?
12+
13+
For functions/methods, we implemented stubs in JS code:
14+
15+
```js
16+
/**
17+
* @deprecated Not supported by the driver. Usage will throw an error.
18+
*/
19+
class Vertex {
20+
constructor() {
21+
throwNotSupported("Vertex");
22+
}
23+
}
24+
```
25+
26+
See [`structure.js`](../../../lib/datastax/graph/structure.js). The goal of those stubs is to loudly inform
27+
JS users of the driver that our driver does not support those features. This approach, while good for users transitioning
28+
from the old DSx driver, may provide some unnecessary noise for new users. When stabilizing the API in 1.0, those
29+
stubs can be removed, with proper documentation for transitioning users. (If there is such a need,
30+
you could create a temporary transition version for users transferring from the DSx driver, with those stubs enabled).
31+
32+
For the TS users of the driver, it was enough to remove those endpoints from the TS files.
33+
When someone attempts to use those features, they will get a compilation error,
34+
meaning we achieved the goal of explicitly informing the user of the deprecation of those endpoints.
35+
36+
When it comes to no longer supported options, we have a very similar approach:
37+
When a JS user provides a no-longer-supported option,
38+
[we throw an error](https://github.com/adespawn/nodejs/blob/ee439f78ed4b4e6c0a73b8aa2f649e45493ae1c5/lib/client-options.js#L971-L978).
39+
Those options are not mentioned in documentation, avoiding the noise for new users.
40+
When it comes to TS users, deleting those options from the TS API is again enough.
41+
42+
## Personal vendettas
43+
44+
Well, maybe not exactly personal, but still. This list is composed of small and big annoyances with the current state of the driver.
45+
46+
### API overloads
47+
48+
```js
49+
* @example <caption>Overloads</caption>
50+
* client.eachRow(query, rowCallback);
51+
* client.eachRow(query, params, rowCallback);
52+
* client.eachRow(query, params, options, rowCallback);
53+
* client.eachRow(query, params, rowCallback, callback);
54+
* client.eachRow(query, params, options, rowCallback, callback);
55+
```
56+
57+
From this [piece of code](https://github.com/adespawn/nodejs/blob/ee439f78ed4b4e6c0a73b8aa2f649e45493ae1c5/lib/client.js#L418-L423).
58+
59+
Allowing for overloading API in this way is (while perfectly fine by JS standards) very annoying when it comes to ensuring type safety.
60+
We have to guess based on the value types what overload the user is providing us with. But touching it will break the API.
61+
Is someone using those overloads? Idk. Will it be hard for users to remove usages of those overloads? Probably not.
62+
Feel free to re-visit this when creating 1.0.
63+
64+
### Long
65+
66+
The driver was initially developed when BigInt [was not a thing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#browser_compatibility).
67+
This means there are internal (and external) parts of the driver that use [Long](https://www.npmjs.com/package/long).
68+
This is the only JS dependency (excluding development dependencies) that the driver uses.
69+
While internal pruning of Long should be (probably annoying but still) possible, removing it from external parts of the driver
70+
may break some APIs. There is an issue related to this: [#41](https://github.com/scylladb/nodejs-rs-driver/issues/41).
71+
This topic would need to be re-visited before 1.0. You would have to decide how to approach this: keep Long as a legacy part of the API,
72+
or fully remove it?

0 commit comments

Comments
 (0)