@reddb-io/client-bun 1.36.11 → 1.38.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/CHANGELOG.md +20 -0
- package/index.ts +23 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @reddb-io/client-bun
|
|
2
2
|
|
|
3
|
+
## 1.38.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2860](https://github.com/reddb-io/reddb/pull/2860) [`015220b`](https://github.com/reddb-io/reddb/commit/015220b5c8070279770da85a38fdb392cb750a65) Thanks [@filipeforattini](https://github.com/filipeforattini)! - Add Queue Consumer v2 lifecycle controls, bounded receive backoff, optional
|
|
8
|
+
concurrency, cooperative handler timeouts, and server-backed delivery lease
|
|
9
|
+
heartbeats.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`015220b`](https://github.com/reddb-io/reddb/commit/015220b5c8070279770da85a38fdb392cb750a65)]:
|
|
14
|
+
- @reddb-io/client@1.38.0
|
|
15
|
+
|
|
16
|
+
## 1.37.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`d73c445`](https://github.com/reddb-io/reddb/commit/d73c4459c77a8484d932a0a0cf0d99eae1ae8017)]:
|
|
21
|
+
- @reddb-io/client@1.37.0
|
|
22
|
+
|
|
3
23
|
## 1.36.11
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/index.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { RoutingClient } from '@reddb-io/client/routing'
|
|
8
8
|
import { decodeTopology } from '@reddb-io/client/topology'
|
|
9
|
+
import { QueueClient, type ScopedQueueClient } from '@reddb-io/client/bun'
|
|
9
10
|
|
|
10
11
|
export type ReadOptions = { consistency: 'local' | 'strong' | 'bounded_staleness'; maxLagMs?: number }
|
|
11
12
|
|
|
@@ -79,6 +80,7 @@ export class RedDBConnection {
|
|
|
79
80
|
private nextCorr = 1n
|
|
80
81
|
private serverFeatures = 0
|
|
81
82
|
private routing?: RoutingClient
|
|
83
|
+
private queueClient?: QueueClient
|
|
82
84
|
|
|
83
85
|
constructor(socket: any) {
|
|
84
86
|
this.socket = socket
|
|
@@ -223,6 +225,27 @@ export class RedDBConnection {
|
|
|
223
225
|
return (this.serverFeatures & FEATURE_PARAMS) === FEATURE_PARAMS
|
|
224
226
|
}
|
|
225
227
|
|
|
228
|
+
/** Rich queue helpers, including managed async consumers. */
|
|
229
|
+
queue(): QueueClient
|
|
230
|
+
queue(name: string): ScopedQueueClient
|
|
231
|
+
queue(name?: string): QueueClient | ScopedQueueClient {
|
|
232
|
+
if (!this.queueClient) {
|
|
233
|
+
const QueueClientConstructor = QueueClient as unknown as new (client: unknown) => QueueClient
|
|
234
|
+
this.queueClient = new QueueClientConstructor({
|
|
235
|
+
nativeQueueWait: false,
|
|
236
|
+
call: async (method: string, params: { sql?: string; params?: QueryParam[] } = {}) => {
|
|
237
|
+
if (method !== 'query' || typeof params.sql !== 'string') {
|
|
238
|
+
throw new RedDBError('UNSUPPORTED_OPERATION', method)
|
|
239
|
+
}
|
|
240
|
+
const raw = await this.query(params.sql, ...(params.params ?? []))
|
|
241
|
+
try { return JSON.parse(raw) }
|
|
242
|
+
catch { return { raw } }
|
|
243
|
+
},
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
return name === undefined ? this.queueClient : this.queueClient.scope(name)
|
|
247
|
+
}
|
|
248
|
+
|
|
226
249
|
async queryWithOptions(sql: string, options: ReadOptions, ...params: QueryParam[]): Promise<string> {
|
|
227
250
|
if (!this.routing) throw new RedDBError('CONSISTENCY_UNSUPPORTED', 'use connect() for routed reads')
|
|
228
251
|
return this.routing.queryWithOptions(sql, options, normalizeQueryParams(params))
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reddb-io/client-bun",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "RedDB wire protocol client for Bun — ultra-fast native TCP",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@reddb-io/client": "1.
|
|
7
|
+
"@reddb-io/client": "1.38.0"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"index.ts",
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
"wire-protocol"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test": "bun test frame-reader.test.ts socket-close.test.ts routing.test.ts && bun run params.test.ts && bun run wire-legacy.test.ts && bun run wire.test.ts"
|
|
23
|
+
"test": "bun test frame-reader.test.ts socket-close.test.ts routing.test.ts queue-helper.test.ts && bun run params.test.ts && bun run wire-legacy.test.ts && bun run wire.test.ts"
|
|
24
24
|
}
|
|
25
25
|
}
|