|
| 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