Skip to content

Commit 9e15b0a

Browse files
authored
[DEVEX-189] Rebrand Client (#392)
# Highlights 1. Use Rust client for read operations 2. Added a benchmark workflow in GitHub Actions. You can run the benchmark on GitHub by dispatching it manually ```mermaid xychart-beta title "KurrentDB NodeJS Client Performance Comparison" x-axis ["EventStoreDB Client v6.2.1", "KurrentDB Client 1.0.0", "KurrentDB bridge"] y-axis "Events per millisecond" 0 --> 70 bar [31.33, 60.66, 65.58] ``` ## Breaking Changes This document outlines the breaking changes introduced in the upcoming release of the KurrentDB client, which includes a performance boost for read operations as it now uses the Rust client for these operations. **Upgrading users must address these changes to ensure compatibility.** --- ## 1. Client Initialization via Connection String ### What Changed We've removed the class constructor method for initializing `KurrentDBClient`. Clients must now be created using a **connection string**, aligning with patterns used in other clients in our ecosystem. ### Migration Guide #### Old Approach ```typescript // Legacy constructor-based initialization const client = new KurrentDBClient({ { endpoint: "localhost:2113" }, { rootCertificate: node.certs.root }, { username: "admin", password: "changeit" } }); ``` #### Change to ```typescript const client = KurrentDBClient.connectionString`kdb://localhost:2113?tls=false`; ``` > **_NOTE:_** If you were using connection string, the code will remain unchanged. --- ## 2. Node.js 14 Deprecation ### What Changed We've officially dropped support for Node.js 14 following the [Node.js Release Schedule](https://github.com/nodejs/Release?tab=readme-ov-file#release-schedule). ### Action Required - Upgrade to Node.js **v20** or higher (LTS) - If maintaining multiple Node versions, use a version manager like `nvm`: ```bash nvm install --lts nvm use --lts ``` ### Impact - CI/CD pipelines using Node 14 will fail - TypeScript definitions now use features from ES2021+ --- ## 3. Stream Handling Migration to Async Iterables ### What Changed Previously, we supported both event emitter pattern and async iteration. In this release, we've **removed event emitter pattern** and now support only async iteration. ### Migration Guide #### Previously Supported Approaches ```typescript // Event Emitter Pattern client .readAll() .on("data", (event) => handleEvent(event)) .on("error", (err) => handleError(err)); // Async Iteration Pattern try { const stream = client.readAll(); for await (const event of stream) { handleEvent(event); } } catch (err) { handleError(err); } ``` #### Now Required ```typescript try { const stream = client.readAll(); for await (const event of stream) { handleEvent(event); } } catch (err) { handleError(err); } ``` ## 4. Removed the certChain and privateKey options from the KurrentDB client settings constructor ## 5. Rename otel tags Previously, we were using esdb as prefix in opentelemetry tags. With the rebranding efforts, we now changed it to kurrent. **Before** ``` db.esdb.user db.esdb.system db.esdb.operation db.esdb.subscription.id db.esdb.event db.esdb.event.type db.esdb.stream ``` **After** ``` db.kurrent.user db.kurrent.system db.kurrent.operation db.kurrent.subscription.id db.kurrent.event db.kurrent.event.type db.kurrent.stream ```
1 parent a7c32aa commit 9e15b0a

203 files changed

Lines changed: 15086 additions & 12729 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
// prettier decides
99
"no-unexpected-multiline": ["off"],
1010
"no-async-promise-executor": ["off"],
11+
"@typescript-eslint/no-unsafe-function-type": ["off"],
1112
"@typescript-eslint/no-empty-interface": [
1213
"error",
1314
{
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Bug Report
2+
description: Create a bug report to help us improve
3+
body:
4+
- type: markdown
5+
attributes:
6+
value: |
7+
Thanks for taking the time to fill out this bug report!
8+
- type: textarea
9+
id: description
10+
attributes:
11+
label: Bug Description
12+
description: A clear and concise description of what the bug is
13+
placeholder: Tell us what you see!
14+
validations:
15+
required: true
16+
- type: textarea
17+
id: reproduction
18+
attributes:
19+
label: To Reproduce
20+
description: Steps to reproduce the behavior
21+
placeholder: |
22+
1. Start the KurrentDB server
23+
2. Connect the client to the server
24+
3. Create a new stream
25+
4. Append an event to the stream
26+
5. Read the event from the stream
27+
6. Observe the issue
28+
validations:
29+
required: true
30+
- type: textarea
31+
id: expected
32+
attributes:
33+
label: Expected behavior
34+
description: A clear and concise description of what you expected to happen
35+
validations:
36+
required: true
37+
- type: markdown
38+
attributes:
39+
value: '## Environment'
40+
- type: input
41+
id: db
42+
attributes:
43+
label: KurrentDB Version
44+
placeholder: ex. 24.10.0
45+
validations:
46+
required: true
47+
- type: input
48+
id: client
49+
attributes:
50+
label: Client Version
51+
placeholder: ex. 1.0.0
52+
validations:
53+
required: true
54+
- type: input
55+
id: nodejs-version
56+
attributes:
57+
label: Node.js Version
58+
placeholder: ex. 18.16.0
59+
validations:
60+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Feature request
4+
url: https://discuss.eventstore.com/
5+
about: Suggest an idea for this project
6+
- name: Question / Problem
7+
url: https://discuss.eventstore.com/
8+
about: Questions and problems with n8n

.github/files/package_check.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/scripts/bump_versions.mjs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {promisify} from 'util';
2+
import assert from 'assert';
3+
import {resolve} from 'path';
4+
import semver from 'semver';
5+
import {exec as execCallback} from 'child_process';
6+
import {writeFile, readFile} from 'fs/promises';
7+
8+
const exec = promisify(execCallback);
9+
10+
async function updatePackageVersion(packagePath, currentVersion, releaseType) {
11+
const packageFile = resolve(packagePath, 'package.json');
12+
const packageJson = JSON.parse(await readFile(packageFile, 'utf-8'));
13+
14+
packageJson.version = semver.inc(currentVersion, releaseType);
15+
16+
await writeFile(packageFile, JSON.stringify(packageJson, null, 2) + '\n');
17+
}
18+
19+
async function main() {
20+
const releaseType = process.env.RELEASE_TYPE;
21+
assert.match(releaseType, /^(patch|minor|major)$/, 'Invalid RELEASE_TYPE');
22+
23+
const packages = JSON.parse((await exec('pnpm ls -r --only-projects --json')).stdout);
24+
25+
for (let {name, path, version, private: isPrivate} of packages) {
26+
if (isPrivate && name !== 'kurrent-node-client-repository') continue;
27+
await updatePackageVersion(path, version, releaseType);
28+
}
29+
}
30+
31+
main().catch(error => {
32+
console.error('Error updating package versions:', error);
33+
process.exit(1);
34+
});

.github/workflows/benchmark.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Benchmark
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
benchmark:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
os: [ ubuntu-latest ]
17+
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version-file: .github/files/.nvmrc
25+
26+
- name: Corepack
27+
run: corepack enable
28+
29+
- name: Install Dependencies
30+
run: yarn
31+
32+
- name: Build
33+
run: yarn build
34+
35+
- name: Start KurrentDB
36+
run: docker compose -f packages/benchmark/docker-compose.yml up -d
37+
38+
- name: Load Events
39+
run: yarn nx run benchmark:loadEvents
40+
41+
- name: Run Benchmarks
42+
run: |
43+
echo "Number of events: 10k"
44+
echo "Size of each event: 23bytes"
45+
echo "Node.js version: $(node --version)"
46+
echo "1 warmup iteration"
47+
echo "20 iterations"
48+
yarn nx run benchmark:benchmark | tee benchmark-bridge-client-output-${{ matrix.os }}.txt
49+
50+
- name: Upload Benchmark Results
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: benchmark-results
54+
path: benchmark-bridge-client-output-${{ matrix.os }}.txt
55+
56+
- name: Shutdown KurrentDB
57+
run: docker compose -f packages/benchmark/docker-compose.yml down

.github/workflows/build_and_lint.yml

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v3
17+
18+
- name: Corepack
19+
run: corepack enable
20+
1721
- name: Install
1822
run: yarn
23+
1924
- name: Linting
2025
run: yarn lint
26+
2127
- name: Build on Ubuntu
2228
run: yarn build
29+
2330
- name: All generated code is commited
2431
run: |
2532
git update-index --refresh
@@ -30,54 +37,27 @@ jobs:
3037
strategy:
3138
fail-fast: true
3239
matrix:
33-
os: [ubuntu-latest, macos-latest, windows-latest]
40+
os: [ ubuntu-latest, macos-latest, windows-latest ]
3441
runs-on: ${{ matrix.os }}
3542

3643
steps:
3744
- uses: actions/checkout@v4
45+
3846
- uses: actions/setup-node@v4
3947
with:
4048
node-version-file: .github/files/.nvmrc
41-
- name: NodeJS version
42-
run: node -v
43-
- name: Install
44-
run: yarn
45-
- name: Build
46-
run: yarn build
4749

48-
package:
49-
name: Package compiles as a dependency
50-
runs-on: ubuntu-latest
51-
steps:
52-
- name: Check out repository
53-
uses: actions/checkout@v4
5450
- name: NodeJS version
5551
run: node -v
52+
53+
- name: Corepack
54+
run: corepack enable
55+
56+
- name: Yarn version
57+
run: yarn --version
58+
5659
- name: Install
5760
run: yarn
61+
5862
- name: Build
5963
run: yarn build
60-
- name: Create and Test All Packages
61-
run: |
62-
for DIR in packages/*; do
63-
if [ -d "$DIR" ]; then
64-
cd $DIR
65-
if [ -f "package.json" ]; then
66-
PACKAGE_NAME=$(node -p "require('./package.json').name")
67-
SHOULD_PUBLISH=$(node -p "require('./package.json').publishConfig && require('./package.json').publishConfig.public ? 'true' : 'false'")
68-
if [[ $PACKAGE_NAME == @eventstore/* ]] && [[ $SHOULD_PUBLISH == 'true' ]]; then
69-
npm pack
70-
PACKAGE_PATH=$(pwd)/$(ls *.tgz)
71-
mkdir -p ../../../temp/$PACKAGE_NAME
72-
cd ../../../temp/$PACKAGE_NAME
73-
yarn init -y
74-
yarn add $PACKAGE_PATH
75-
yarn add --dev typescript
76-
cp ../../..$DIR/.github/files/package_check.txt ./main.ts
77-
yarn tsc main.ts --alwaysStrict --noImplicitAny --noImplicitReturns --strictNullChecks --module system --moduleResolution node --target es2018 --lib es2020 --types node
78-
cd ../../..
79-
fi
80-
fi
81-
cd ..
82-
fi
83-
done

.github/workflows/release_pr.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 'Release: Create Pull Request'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
base-branch:
7+
description: 'The branch, tag, or commit to create this release PR from.'
8+
required: true
9+
default: 'master'
10+
11+
release-type:
12+
description: 'A SemVer release type.'
13+
required: true
14+
type: choice
15+
default: 'minor'
16+
options:
17+
- patch
18+
- minor
19+
- major
20+
21+
jobs:
22+
create-release-pr:
23+
runs-on: ubuntu-latest
24+
25+
permissions:
26+
contents: write
27+
pull-requests: write
28+
29+
timeout-minutes: 5
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4.1.1
34+
with:
35+
fetch-depth: 0
36+
ref: ${{ github.event.inputs.base-branch }}
37+
38+
- run: npm install --prefix=.github/scripts --no-package-lock
39+
40+
- name: Bump package versions
41+
run: |
42+
echo "NEXT_RELEASE=$(node .github/scripts/bump_versions.mjs)" >> $GITHUB_ENV
43+
env:
44+
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
45+
46+
- name: Push the base branch
47+
run: |
48+
git push -f origin refs/remotes/origin/${{ github.event.inputs.base-branch }}:refs/heads/release/${{ env.NEXT_RELEASE }}
49+
50+
- name: Push the release branch, and Create the PR
51+
uses: peter-evans/create-pull-request@v6
52+
with:
53+
base: 'release/${{ env.NEXT_RELEASE }}'
54+
branch: 'release-pr/${{ env.NEXT_RELEASE }}'
55+
commit-message: 'Release ${{ env.NEXT_RELEASE }}'
56+
delete-branch: true
57+
labels: release,release:${{ github.event.inputs.release-type }}
58+
title: 'Release ${{ env.NEXT_RELEASE }}'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 'Release: Publish'
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- 'release/*'
9+
10+
jobs:
11+
publish-to-npm:
12+
name: Publish to NPM
13+
runs-on: ubuntu-latest
14+
if: github.event.pull_request.merged == true
15+
timeout-minutes: 10
16+
permissions:
17+
id-token: write
18+
outputs:
19+
release: ${{ steps.set-release.outputs.release }}
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4.1.1
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Corepack
27+
run: corepack enable
28+
29+
- run: yarn
30+
31+
- name: Build
32+
run: yarn build
33+
34+
- name: Cache build artifacts
35+
uses: actions/cache/save@v4.0.0
36+
with:
37+
path: ./packages/**/dist
38+
key: ${{ github.sha }}-release:build
39+
40+
- name: Dry-run publishing
41+
run: yarn publish -r --no-git-checks --dry-run
42+
43+
- name: Publish to NPM
44+
run: |
45+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
46+
yarn npm publish -r --publish-branch ${{github.event.pull_request.base.ref}} --access public --no-git-checks

.github/workflows/test_LTS.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,3 @@ jobs:
1414
uses: ./.github/workflows/tests.yml
1515
with:
1616
version: "latest"
17-
secrets:
18-
eventstore_cloud_id: ${{ secrets.EVENTSTORE_CLOUD_ID }}
19-
tailscale_auth: ${{ secrets.TAILSCALE_AUTH }}

0 commit comments

Comments
 (0)