tigerbeetle-node
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -16,3 +16,3 @@ "use strict"; | ||
const TOLERANCE = 10; | ||
const client = _1.createClient({ | ||
const client = (0, _1.createClient)({ | ||
cluster_id: 0, | ||
@@ -66,3 +66,3 @@ replica_addresses: ['3001'] | ||
const encodeTransfer = (transfer, offset, output) => { | ||
assert_1.default(BigInt((offset + TRANSFER_SIZE)) <= BigInt(output.length), `Transfer ${transfer} exceeds buffer of ${output}!`); | ||
(0, assert_1.default)(BigInt((offset + TRANSFER_SIZE)) <= BigInt(output.length), `Transfer ${transfer} exceeds buffer of ${output}!`); | ||
output.writeBigUInt64LE(transfer.id, offset); | ||
@@ -82,3 +82,3 @@ output.writeBigUInt64LE(transfer.debit_account_id, offset + 16); | ||
const runBenchmarkRawRequest = async () => { | ||
assert_1.default(MAX_TRANSFERS % MAX_REQUEST_BATCH_SIZE === 0, "The raw request benchmark requires MAX_TRANSFERS to be a multiple of MAX_REQUEST_BATCH_SIZE"); | ||
(0, assert_1.default)(MAX_TRANSFERS % MAX_REQUEST_BATCH_SIZE === 0, "The raw request benchmark requires MAX_TRANSFERS to be a multiple of MAX_REQUEST_BATCH_SIZE"); | ||
console.log(`pre-allocating ${MAX_TRANSFERS} transfers and posts...`); | ||
@@ -132,3 +132,3 @@ const transfers = []; | ||
} | ||
assert_1.default(count === MAX_TRANSFERS); | ||
(0, assert_1.default)(count === MAX_TRANSFERS); | ||
console.log(`starting benchmark. MAX_TRANSFERS=${MAX_TRANSFERS} REQUEST_BATCH_SIZE=${MAX_REQUEST_BATCH_SIZE} NUMBER_OF_BATCHES=${transfers.length}`); | ||
@@ -141,3 +141,3 @@ let maxCreateTransfersLatency = 0; | ||
const transferErrors = await rawCreateTransfers(transfers[i]); | ||
assert_1.default(transferErrors.length === 0); | ||
(0, assert_1.default)(transferErrors.length === 0); | ||
const ms2 = Date.now(); | ||
@@ -150,3 +150,3 @@ const createTransferLatency = ms2 - ms1; | ||
const commitErrors = await rawCreateTransfers(posts[i]); | ||
assert_1.default(commitErrors.length === 0); | ||
(0, assert_1.default)(commitErrors.length === 0); | ||
const ms3 = Date.now(); | ||
@@ -213,3 +213,3 @@ const commitTransferLatency = ms3 - ms2; | ||
} | ||
assert_1.default(count === MAX_TRANSFERS); | ||
(0, assert_1.default)(count === MAX_TRANSFERS); | ||
console.log(`starting benchmark. MAX_TRANSFERS=${MAX_TRANSFERS} REQUEST_BATCH_SIZE=${MAX_REQUEST_BATCH_SIZE} NUMBER_OF_BATCHES=${transfers.length}`); | ||
@@ -222,3 +222,3 @@ let maxCreateTransfersLatency = 0; | ||
const transferErrors = await client.createTransfers(transfers[i]); | ||
assert_1.default(transferErrors.length === 0); | ||
(0, assert_1.default)(transferErrors.length === 0); | ||
const ms2 = Date.now(); | ||
@@ -231,3 +231,3 @@ const createTransferLatency = ms2 - ms1; | ||
const commitErrors = await client.createTransfers(posts[i]); | ||
assert_1.default(commitErrors.length === 0); | ||
(0, assert_1.default)(commitErrors.length === 0); | ||
const ms3 = Date.now(); | ||
@@ -251,5 +251,5 @@ const commitTransferLatency = ms3 - ms2; | ||
const accountResults = await client.lookupAccounts([accountA.id, accountB.id]); | ||
assert_1.default(accountResults.length === 2); | ||
assert_1.default(accountResults[0].debits_posted === 0n); | ||
assert_1.default(accountResults[1].debits_posted === 0n); | ||
(0, assert_1.default)(accountResults.length === 2); | ||
(0, assert_1.default)(accountResults[0].debits_posted === 0n); | ||
(0, assert_1.default)(accountResults[1].debits_posted === 0n); | ||
const benchmark = IS_RAW_REQUEST ? await runBenchmarkRawRequest() : await runBenchmark(); | ||
@@ -262,5 +262,5 @@ const accounts = await client.lookupAccounts([accountA.id, accountB.id]); | ||
console.log(`commit transfers max p100 latency per 10 000 transfers = ${benchmark.maxCommitTransfersLatency}ms`); | ||
assert_1.default(accounts.length === 2); | ||
assert_1.default(accounts[0].debits_posted === BigInt(MAX_TRANSFERS)); | ||
assert_1.default(accounts[1].credits_posted === BigInt(MAX_TRANSFERS)); | ||
(0, assert_1.default)(accounts.length === 2); | ||
(0, assert_1.default)(accounts[0].debits_posted === BigInt(MAX_TRANSFERS)); | ||
(0, assert_1.default)(accounts[1].credits_posted === BigInt(MAX_TRANSFERS)); | ||
if (result < PREVIOUS_BENCHMARK * (100 - TOLERANCE) / 100) { | ||
@@ -267,0 +267,0 @@ console.warn(`There has been a performance regression. Previous benchmark=${PREVIOUS_BENCHMARK}`); |
@@ -8,3 +8,3 @@ "use strict"; | ||
const _1 = require("."); | ||
const client = _1.createClient({ | ||
const client = (0, _1.createClient)({ | ||
cluster_id: 0, | ||
@@ -11,0 +11,0 @@ replica_addresses: ['3001'] |
{ | ||
"name": "tigerbeetle-node", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "TigerBeetle Node.js client", | ||
@@ -13,4 +13,2 @@ "main": "dist/index.js", | ||
"files": [ | ||
".yarn/releases", | ||
".yarnrc.yml", | ||
"LICENSE", | ||
@@ -21,4 +19,4 @@ "README.md", | ||
"package.json", | ||
"package-lock.json", | ||
"scripts/download_node_headers.sh", | ||
"scripts/postinstall.sh", | ||
"src/c.zig", | ||
@@ -32,4 +30,3 @@ "src/benchmark.ts", | ||
"src/translate.zig", | ||
"tsconfig.json", | ||
"yarn.lock" | ||
"tsconfig.json" | ||
], | ||
@@ -41,10 +38,11 @@ "engines": { | ||
"benchmark": "./scripts/benchmark.sh", | ||
"build": "yarn build:tsc && yarn build:zig", | ||
"build:tsc": "tsc", | ||
"build:zig": "mkdir -p dist && zig/zig build-lib -mcpu=baseline -OReleaseSafe -dynamic -lc -isystem build/node-$(node --version)/include/node src/node.zig -fallow-shlib-undefined -femit-bin=dist/client.node", | ||
"clean": "rm -rf build dist node_modules src/zig-cache zig", | ||
"install:zig": "./src/tigerbeetle/scripts/install_zig.sh", | ||
"postinstall": "./scripts/postinstall.sh", | ||
"prepack": "git submodule deinit --all && git submodule update --init && yarn build:tsc", | ||
"test": "yarn build && node dist/test" | ||
"test": "node dist/test", | ||
"postinstall": "npm run install_zig && npm run download_node_headers && npm run build_lib", | ||
"install_zig": "./src/tigerbeetle/scripts/install_zig.sh", | ||
"download_node_headers": "./scripts/download_node_headers.sh", | ||
"build": "npm run build_tsc && npm run build_lib", | ||
"build_tsc": "./node_modules/typescript/bin/tsc", | ||
"build_lib": "mkdir -p dist && zig/zig build-lib -mcpu=baseline -OReleaseSafe -dynamic -lc -isystem build/node-$(node --version)/include/node src/node.zig -fallow-shlib-undefined -femit-bin=dist/client.node", | ||
"prepack": "git submodule deinit --all && git submodule update --init && npm run build_tsc", | ||
"clean": "rm -rf build dist node_modules src/zig-cache zig" | ||
}, | ||
@@ -56,4 +54,4 @@ "author": "Coil Technologies, Inc", | ||
"Isaac Freund <isaac.freund@coil.com>", | ||
"Joran Dirk Greef <joran@coil.com>", | ||
"Jason Bruwer <jason.bruwer@coil.com>" | ||
"Jason Bruwer <jason.bruwer@coil.com>", | ||
"Joran Dirk Greef <joran@coil.com>" | ||
], | ||
@@ -60,0 +58,0 @@ "devDependencies": { |
@@ -5,21 +5,18 @@ # tigerbeetle-node | ||
## Installation | ||
The following steps will install the `tigerbeetle-node` module to your current working directory. | ||
### Prerequisites | ||
Install the `tigerbeetle-node` module to your current working directory: | ||
* NodeJS >= `14.0.0`. _(If the correct version is not installed, an installation error will occur)_ | ||
> Your operating system should be Linux (kernel >= v5.6) or macOS. Windows support is not yet available but is in the works. | ||
### YARN Package Manager Installation | ||
```shell | ||
yarn add tigerbeetle-node | ||
``` | ||
or | ||
### NPM Package Manager Installation | ||
```shell | ||
npm install tigerbeetle-node | ||
``` | ||
### Prerequisites | ||
* NodeJS >= `14.0.0`. _(If the correct version is not installed, an installation error will occur)_ | ||
> Your operating system should be Linux (kernel >= v5.6) or macOS. | ||
> Windows support is not yet available. | ||
## Usage | ||
A client needs to be configured with a `cluster_id` and `replica_addresses`. | ||
@@ -29,2 +26,3 @@ This instantiates the client where memory is allocated to internally buffer events to be sent. | ||
Future releases will allow multiple client instantiations. | ||
```js | ||
@@ -222,32 +220,33 @@ import { createClient } from 'tigerbeetle-node' | ||
Follow these steps to get up and running when cloning the repo: | ||
To get up and running when cloning the repo: | ||
```shell | ||
git clone --recurse-submodules https://github.com/coilhq/tigerbeetle-node.git | ||
cd tigerbeetle-node/ | ||
yarn install --immutable | ||
npm install --include dev # This will automatically install and build everything you need. | ||
``` | ||
Build locally using `yarn`: | ||
#### Rebuild | ||
To rebuild the TypeScript distribution, and to rebuild the native Node library, again after changes: | ||
```shell | ||
# Run the following from this directory: | ||
yarn && yarn build | ||
npm run build | ||
``` | ||
* **Please note: `yarn clean` will remove Zig and NodeAPI C headers, which mean you need to run:** | ||
*If you ever run `npm run clean` then you will need to `npm install --include dev` to reinstall | ||
TypeScript within `node_modules`, as TypeScript is required by `npm run prepack` when publishing.* | ||
#### Benchmark | ||
```shell | ||
./scripts/postinstall.sh #Install Zig and NodeJS C Headers | ||
npm run benchmark | ||
``` | ||
***Yarn - Run Test*** | ||
Ensure TigerBeetle (`init` & `start`) is running on the port configured in `test.ts`, then run: | ||
#### Test | ||
```shell | ||
./tigerbeetle init --cluster=1 --replica=0 --directory=. | ||
./tigerbeetle start --cluster=1 --replica=0 --directory=. --addresses=3001 | ||
yarn test | ||
npm run test | ||
``` | ||
***Yarn - Run Benchmark*** | ||
Run the benchmark (The `benchmark` will automatically start TigerBeetle on port `3001` _(single replica)_: | ||
```shell | ||
yarn benchmark | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
1108209
72
1880
250
1