hyperiondb-client 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/client.d.ts +49 -3
- package/client.js +119 -18
- package/index.js +52 -52
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -106,6 +106,40 @@ try {
|
|
|
106
106
|
All statements in a transaction run on one dedicated connection. Repeated SQL reuses a
|
|
107
107
|
server-side prepared statement (deadpool `prepare_cached`).
|
|
108
108
|
|
|
109
|
+
## Retries & idempotency
|
|
110
|
+
|
|
111
|
+
`transaction(cb)` retries the whole callback on serialization/deadlock (`40001`/`40P01`) and
|
|
112
|
+
on connection failures that happen *before* `COMMIT`. A failure *during* `COMMIT` is ambiguous
|
|
113
|
+
(the write may have landed), so it is surfaced as `error.code === 'IN_DOUBT'` and **never**
|
|
114
|
+
auto-retried — handle that one idempotently.
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
await pool.transaction(async (tx) => { /* ... */ }, { maxAttempts: 5 })
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Reads can be retried too — on by default for `read-only`/`prefer-standby` pools (every query
|
|
121
|
+
is a read); on a `read-write` pool opt a specific read in with `{ retry: true }`:
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
const rows = await pool.query('select …', [], { retry: true })
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`insert(table, row, { idempotency: true })` makes a write safe to retry through the in-doubt
|
|
128
|
+
window by adding `ON CONFLICT (<conflictTarget>) DO NOTHING` (the conflict key defaults to
|
|
129
|
+
`_id`, which is any unique column — `varchar`/`text`, `uuid`, etc.). A re-applied row collapses to a
|
|
130
|
+
no-op and returns `[]`:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const requestId = 'evt-2026-06-05-abc123' // any client-supplied unique key
|
|
134
|
+
const [order] = await pool.insert('orders', { _id: requestId, amount: 100 }, { idempotency: true })
|
|
135
|
+
// a duplicate retry returns [] — the row exists exactly once
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Retry policy is per-pool: `createPool({ …, retry: { maxAttempts, baseDelayMs, maxDelayMs } })`
|
|
139
|
+
(defaults `3 / 50 / 1000`). This is the Postgres-side equivalent of MongoDB's retryable
|
|
140
|
+
writes — except the in-doubt commit needs your idempotency key, since Postgres has no built-in
|
|
141
|
+
per-statement dedup token.
|
|
142
|
+
|
|
109
143
|
## Cancellation & timeouts
|
|
110
144
|
|
|
111
145
|
`query` takes an optional third argument. Both a timeout and an `AbortSignal` cancel the
|
package/client.d.ts
CHANGED
|
@@ -21,6 +21,17 @@ export interface PoolOptions {
|
|
|
21
21
|
applicationName?: string
|
|
22
22
|
/** Called once per query with timing and outcome. Errors thrown here are ignored. */
|
|
23
23
|
logger?: (event: QueryEvent) => void
|
|
24
|
+
/** Retry policy for retryable reads, `transaction(cb)`, and idempotent `insert`. */
|
|
25
|
+
retry?: RetryOptions
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RetryOptions {
|
|
29
|
+
/** Max total attempts (1 = no retry). Defaults to 3. */
|
|
30
|
+
maxAttempts?: number
|
|
31
|
+
/** First backoff delay in ms (doubles per attempt, jittered). Defaults to 50. */
|
|
32
|
+
baseDelayMs?: number
|
|
33
|
+
/** Backoff cap in ms. Defaults to 1000. */
|
|
34
|
+
maxDelayMs?: number
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
export interface QueryEvent {
|
|
@@ -60,11 +71,36 @@ export interface QueryOptions {
|
|
|
60
71
|
timeoutMs?: number
|
|
61
72
|
/** Abort the query (server-side cancel) when the signal fires. */
|
|
62
73
|
signal?: AbortSignal
|
|
74
|
+
/**
|
|
75
|
+
* Retry on transient errors (serialization/deadlock, connection loss). Only safe for
|
|
76
|
+
* reads or idempotent statements. Defaults to true on `read-only`/`prefer-standby` pools,
|
|
77
|
+
* false otherwise — set explicitly to opt a specific query in or out.
|
|
78
|
+
*/
|
|
79
|
+
retry?: boolean
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface InsertOptions {
|
|
83
|
+
/** Add `ON CONFLICT (<conflictTarget>) DO NOTHING`, making the insert safely retryable. */
|
|
84
|
+
idempotency?: boolean
|
|
85
|
+
/** Conflict key for idempotent inserts. Defaults to `'_id'`. */
|
|
86
|
+
conflictTarget?: string | string[]
|
|
87
|
+
timeoutMs?: number
|
|
88
|
+
signal?: AbortSignal
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface TransactionOptions {
|
|
92
|
+
/** Max total attempts for the retry loop. Defaults to the pool's `retry.maxAttempts`. */
|
|
93
|
+
maxAttempts?: number
|
|
63
94
|
}
|
|
64
95
|
|
|
65
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* A PostgreSQL `Error` carries the 5-character SQLSTATE on `.code`. A `transaction(cb)`
|
|
98
|
+
* whose `COMMIT` is lost to a connection failure (outcome unknown) throws with
|
|
99
|
+
* `code === 'IN_DOUBT'` and is never auto-retried.
|
|
100
|
+
*/
|
|
66
101
|
export interface DbError extends Error {
|
|
67
102
|
code?: string
|
|
103
|
+
cause?: unknown
|
|
68
104
|
}
|
|
69
105
|
|
|
70
106
|
export interface Transaction {
|
|
@@ -75,10 +111,20 @@ export interface Transaction {
|
|
|
75
111
|
|
|
76
112
|
export interface Pool {
|
|
77
113
|
query<T = Row>(sql: string, params?: Param[], opts?: QueryOptions): Promise<T[]>
|
|
114
|
+
/**
|
|
115
|
+
* Insert `row` into `table`, returning the inserted row(s). With `idempotency: true` a
|
|
116
|
+
* re-applied row collapses to a no-op (`ON CONFLICT (<conflictTarget>) DO NOTHING`),
|
|
117
|
+
* making the write safe to retry through the in-doubt window — a duplicate returns `[]`.
|
|
118
|
+
*/
|
|
119
|
+
insert<T = Row>(table: string, row: Record<string, Param>, opts?: InsertOptions): Promise<T[]>
|
|
78
120
|
/** Begin a transaction on a dedicated connection. Remember to `commit()` or `rollback()`. */
|
|
79
121
|
begin(): Promise<Transaction>
|
|
80
|
-
/**
|
|
81
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Run `fn` inside a transaction, auto `COMMIT` on resolve and `ROLLBACK` on throw, retrying
|
|
124
|
+
* the whole callback on serialization/deadlock and pre-commit connection failures. A failure
|
|
125
|
+
* during `COMMIT` is surfaced as a `code === 'IN_DOUBT'` error and never auto-retried.
|
|
126
|
+
*/
|
|
127
|
+
transaction<T>(fn: (tx: Transaction) => Promise<T>, opts?: TransactionOptions): Promise<T>
|
|
82
128
|
/** Live pool counters: size, idle, in-use, and waiters. */
|
|
83
129
|
status(): PoolStatus
|
|
84
130
|
/** Drain and close the pool. */
|
package/client.js
CHANGED
|
@@ -4,6 +4,16 @@ const native = require('./index.js')
|
|
|
4
4
|
|
|
5
5
|
const SQLSTATE = /^\[SQLSTATE ([0-9A-Za-z]{5})\] ([\s\S]*)$/
|
|
6
6
|
|
|
7
|
+
const SERIALIZATION = new Set(['40001', '40P01'])
|
|
8
|
+
const CONNECTION_SQLSTATE = new Set([
|
|
9
|
+
'08000', '08003', '08006', '08001', '08004', '08007',
|
|
10
|
+
'57P01', '57P02', '57P03', '53300', '53400',
|
|
11
|
+
])
|
|
12
|
+
const READ_MODES = new Set(['read-only', 'readonly', 'ro', 'prefer-standby', 'preferstandby'])
|
|
13
|
+
const DEFAULT_RETRY = { maxAttempts: 3, baseDelayMs: 50, maxDelayMs: 1000 }
|
|
14
|
+
|
|
15
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
16
|
+
|
|
7
17
|
function decorate(error) {
|
|
8
18
|
if (error && typeof error.message === 'string') {
|
|
9
19
|
const match = SQLSTATE.exec(error.message)
|
|
@@ -15,6 +25,37 @@ function decorate(error) {
|
|
|
15
25
|
return error
|
|
16
26
|
}
|
|
17
27
|
|
|
28
|
+
function isSerialization(error) {
|
|
29
|
+
return !!error && SERIALIZATION.has(error.code)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isConnectionError(error) {
|
|
33
|
+
if (!error) return false
|
|
34
|
+
if (error.code) return CONNECTION_SQLSTATE.has(error.code)
|
|
35
|
+
return typeof error.message === 'string' &&
|
|
36
|
+
/no writable primary|connection|closed|terminat|reset|broken pipe|server closed/i.test(error.message)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isRetryable(error) {
|
|
40
|
+
return isSerialization(error) || isConnectionError(error)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function inDoubt(cause) {
|
|
44
|
+
const error = new Error(`transaction commit outcome unknown (in doubt): ${cause.message}`)
|
|
45
|
+
error.code = 'IN_DOUBT'
|
|
46
|
+
error.cause = cause
|
|
47
|
+
return error
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function backoff(attempt, cfg) {
|
|
51
|
+
const base = Math.min(cfg.baseDelayMs * 2 ** (attempt - 1), cfg.maxDelayMs)
|
|
52
|
+
return Math.round(base * (0.5 + Math.random() * 0.5))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function quoteIdent(name) {
|
|
56
|
+
return '"' + String(name).replace(/"/g, '""') + '"'
|
|
57
|
+
}
|
|
58
|
+
|
|
18
59
|
async function guard(run) {
|
|
19
60
|
try {
|
|
20
61
|
return await run()
|
|
@@ -27,9 +68,7 @@ function emit(logger, event) {
|
|
|
27
68
|
if (logger) {
|
|
28
69
|
try {
|
|
29
70
|
logger(event)
|
|
30
|
-
} catch {
|
|
31
|
-
// a logging hook must never break a query
|
|
32
|
-
}
|
|
71
|
+
} catch {}
|
|
33
72
|
}
|
|
34
73
|
}
|
|
35
74
|
|
|
@@ -78,16 +117,60 @@ class Transaction {
|
|
|
78
117
|
|
|
79
118
|
class Pool {
|
|
80
119
|
constructor(options) {
|
|
81
|
-
const { logger, ...nativeOptions } = options
|
|
120
|
+
const { logger, retry, ...nativeOptions } = options
|
|
82
121
|
this._logger = logger
|
|
122
|
+
this._retry = { ...DEFAULT_RETRY, ...(retry || {}) }
|
|
123
|
+
this._retryReads = READ_MODES.has(options.mode)
|
|
83
124
|
this._inner = native.createPool(nativeOptions)
|
|
84
125
|
}
|
|
85
126
|
|
|
86
127
|
async query(sql, params, opts) {
|
|
87
128
|
checkAborted(opts)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
)
|
|
129
|
+
const retry = opts?.retry ?? this._retryReads
|
|
130
|
+
const max = retry ? this._retry.maxAttempts : 1
|
|
131
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
132
|
+
try {
|
|
133
|
+
return await runLogged(this._logger, sql, () =>
|
|
134
|
+
this._inner.query(sql, params ?? null, opts?.timeoutMs ?? null, opts?.signal ?? null),
|
|
135
|
+
)
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (retry && isRetryable(error) && attempt < max && !opts?.signal?.aborted) {
|
|
138
|
+
await sleep(backoff(attempt, this._retry))
|
|
139
|
+
continue
|
|
140
|
+
}
|
|
141
|
+
throw error
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async insert(table, row, opts) {
|
|
147
|
+
const columns = Object.keys(row)
|
|
148
|
+
const placeholders = columns.map((_, index) => '$' + (index + 1)).join(', ')
|
|
149
|
+
const params = columns.map((column) => row[column])
|
|
150
|
+
const idempotent = opts?.idempotency === true
|
|
151
|
+
let onConflict = ''
|
|
152
|
+
if (idempotent) {
|
|
153
|
+
const target = opts?.conflictTarget ?? '_id'
|
|
154
|
+
const targets = Array.isArray(target) ? target : [target]
|
|
155
|
+
onConflict = ` ON CONFLICT (${targets.map(quoteIdent).join(', ')}) DO NOTHING`
|
|
156
|
+
}
|
|
157
|
+
const sql = `INSERT INTO ${quoteIdent(table)} (${columns.map(quoteIdent).join(', ')}) ` +
|
|
158
|
+
`VALUES (${placeholders})${onConflict} RETURNING *`
|
|
159
|
+
|
|
160
|
+
const max = idempotent ? this._retry.maxAttempts : 1
|
|
161
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
162
|
+
try {
|
|
163
|
+
return await runLogged(this._logger, sql, () =>
|
|
164
|
+
this._inner.query(sql, params, opts?.timeoutMs ?? null, opts?.signal ?? null),
|
|
165
|
+
)
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (idempotent && isRetryable(error) && attempt < max) {
|
|
168
|
+
await sleep(backoff(attempt, this._retry))
|
|
169
|
+
continue
|
|
170
|
+
}
|
|
171
|
+
throw error
|
|
172
|
+
}
|
|
173
|
+
}
|
|
91
174
|
}
|
|
92
175
|
|
|
93
176
|
async begin() {
|
|
@@ -95,19 +178,37 @@ class Pool {
|
|
|
95
178
|
return new Transaction(inner, this._logger)
|
|
96
179
|
}
|
|
97
180
|
|
|
98
|
-
async transaction(callback) {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await tx.commit()
|
|
103
|
-
return result
|
|
104
|
-
} catch (error) {
|
|
181
|
+
async transaction(callback, opts) {
|
|
182
|
+
const max = opts?.maxAttempts ?? this._retry.maxAttempts
|
|
183
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
184
|
+
let tx
|
|
105
185
|
try {
|
|
106
|
-
await
|
|
107
|
-
|
|
108
|
-
|
|
186
|
+
tx = await this.begin()
|
|
187
|
+
const result = await callback(tx)
|
|
188
|
+
try {
|
|
189
|
+
await tx.commit()
|
|
190
|
+
} catch (commitError) {
|
|
191
|
+
if (isSerialization(commitError) && attempt < max) {
|
|
192
|
+
await sleep(backoff(attempt, this._retry))
|
|
193
|
+
continue
|
|
194
|
+
}
|
|
195
|
+
if (isConnectionError(commitError)) throw inDoubt(commitError)
|
|
196
|
+
throw commitError
|
|
197
|
+
}
|
|
198
|
+
return result
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error.code === 'IN_DOUBT') throw error
|
|
201
|
+
if (tx) {
|
|
202
|
+
try {
|
|
203
|
+
await tx.rollback()
|
|
204
|
+
} catch {}
|
|
205
|
+
}
|
|
206
|
+
if (isRetryable(error) && attempt < max) {
|
|
207
|
+
await sleep(backoff(attempt, this._retry))
|
|
208
|
+
continue
|
|
209
|
+
}
|
|
210
|
+
throw error
|
|
109
211
|
}
|
|
110
|
-
throw error
|
|
111
212
|
}
|
|
112
213
|
}
|
|
113
214
|
|
package/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('hyperiondb-client-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('hyperiondb-client-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
80
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('hyperiondb-client-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('hyperiondb-client-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
96
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('hyperiondb-client-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('hyperiondb-client-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
117
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('hyperiondb-client-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('hyperiondb-client-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
133
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('hyperiondb-client-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('hyperiondb-client-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
150
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('hyperiondb-client-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('hyperiondb-client-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
166
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('hyperiondb-client-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('hyperiondb-client-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
185
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('hyperiondb-client-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('hyperiondb-client-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
201
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('hyperiondb-client-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('hyperiondb-client-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
217
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('hyperiondb-client-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('hyperiondb-client-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
237
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('hyperiondb-client-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('hyperiondb-client-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
253
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('hyperiondb-client-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('hyperiondb-client-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
274
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('hyperiondb-client-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('hyperiondb-client-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
290
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('hyperiondb-client-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('hyperiondb-client-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
308
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('hyperiondb-client-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('hyperiondb-client-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
324
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('hyperiondb-client-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('hyperiondb-client-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
342
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('hyperiondb-client-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('hyperiondb-client-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
358
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('hyperiondb-client-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('hyperiondb-client-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
376
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('hyperiondb-client-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('hyperiondb-client-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
392
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('hyperiondb-client-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('hyperiondb-client-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
410
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('hyperiondb-client-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('hyperiondb-client-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
426
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('hyperiondb-client-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('hyperiondb-client-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
443
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('hyperiondb-client-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('hyperiondb-client-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
459
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('hyperiondb-client-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('hyperiondb-client-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
479
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('hyperiondb-client-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('hyperiondb-client-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
495
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('hyperiondb-client-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('hyperiondb-client-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
511
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperiondb-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Native Node.js client for a HyperionDb / pg_replica Postgres cluster — a primary-following connection pool over the N nodes.",
|
|
5
5
|
"main": "client.js",
|
|
6
6
|
"types": "client.d.ts",
|
|
@@ -33,17 +33,18 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "napi build --platform --release",
|
|
35
35
|
"build:debug": "napi build --platform",
|
|
36
|
-
"test": "node --test --test-concurrency=1 test/types.test.js test/fence.test.js",
|
|
36
|
+
"test": "node --test --test-concurrency=1 test/types.test.js test/retry.test.js test/fence.test.js",
|
|
37
37
|
"test:chaos": "node --test test/chaos.test.js",
|
|
38
|
-
"test:all": "node --test --test-concurrency=1 test/types.test.js test/fence.test.js test/chaos.test.js"
|
|
38
|
+
"test:all": "node --test --test-concurrency=1 test/types.test.js test/retry.test.js test/fence.test.js test/chaos.test.js"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@napi-rs/cli": "3.7.0"
|
|
42
42
|
},
|
|
43
|
+
"homepage": "https://github.com/hyperiondb/node-addon",
|
|
43
44
|
"optionalDependencies": {
|
|
44
|
-
"hyperiondb-client-linux-x64-gnu": "0.
|
|
45
|
-
"hyperiondb-client-linux-arm64-gnu": "0.
|
|
46
|
-
"hyperiondb-client-linux-x64-musl": "0.
|
|
47
|
-
"hyperiondb-client-linux-arm64-musl": "0.
|
|
45
|
+
"hyperiondb-client-linux-x64-gnu": "0.2.0",
|
|
46
|
+
"hyperiondb-client-linux-arm64-gnu": "0.2.0",
|
|
47
|
+
"hyperiondb-client-linux-x64-musl": "0.2.0",
|
|
48
|
+
"hyperiondb-client-linux-arm64-musl": "0.2.0"
|
|
48
49
|
}
|
|
49
50
|
}
|