bunqueue-client 0.1.1 → 0.1.2
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 +46 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,6 +24,50 @@ npm install bunqueue-client
|
|
|
24
24
|
# or: bun add bunqueue-client / pnpm add bunqueue-client / deno add npm:bunqueue-client
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
Sixty seconds from zero to a working queue. Step 1, start the server (requires [Bun](https://bun.sh), or use the Docker image):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bunx bunqueue start
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Step 2, create `app.ts`: add a job and process it, in the same file for the sake of the demo:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Queue, Worker } from 'bunqueue-client';
|
|
39
|
+
|
|
40
|
+
const worker = new Worker('hello', async (job) => {
|
|
41
|
+
console.log('processing', job.data);
|
|
42
|
+
return { greeted: job.data.name };
|
|
43
|
+
});
|
|
44
|
+
worker.on('completed', (job, result) => {
|
|
45
|
+
console.log('completed', job.id, result);
|
|
46
|
+
worker.close();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const queue = new Queue('hello');
|
|
50
|
+
await queue.add('greet', { name: 'world' });
|
|
51
|
+
queue.close();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Step 3, run it with the runtime you already use:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
node --experimental-strip-types app.ts # Node 22 or later
|
|
58
|
+
bun app.ts # Bun
|
|
59
|
+
deno run -A app.ts # Deno 2 or later
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Expected output:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
processing { name: 'world' }
|
|
66
|
+
completed 019f40a5-... { greeted: 'world' }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
That is the whole model: the server owns state, retries, and scheduling, your code only adds and processes. In production the producer and the worker are separate services, often in different languages: the [Python client](https://github.com/egeominotti/bunqueue/tree/main/sdk/python) speaks the same protocol against the same queue. Defaults are `host: 'localhost'`, `port: 6789`, so constructors need no options on a local setup.
|
|
70
|
+
|
|
27
71
|
## Producing jobs
|
|
28
72
|
|
|
29
73
|
```typescript
|
|
@@ -132,6 +176,8 @@ Authentication uses server side tokens (`AUTH_TOKENS`). Transport security uses
|
|
|
132
176
|
|
|
133
177
|
The following features require the in process Bun runtime and are intentionally out of scope for this client: embedded mode, sandboxed workers, and `QueueEvents`. Use webhooks or the HTTP SSE and WebSocket endpoints for event streaming.
|
|
134
178
|
|
|
179
|
+
Note on numeric payloads: JavaScript numbers are IEEE 754 doubles, exact up to 2^53. Pass larger 64 bit identifiers, for example snowflake IDs, as strings to avoid silent precision loss. Never place `BigInt` values in job data.
|
|
180
|
+
|
|
135
181
|
## Quality assurance
|
|
136
182
|
|
|
137
183
|
Every release is validated against a real bunqueue server, spawned fresh for each run, across every supported runtime:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunqueue-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Cross-runtime TypeScript client for the bunqueue job queue server — Node.js, Bun, Deno and Cloudflare Workers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"lint": "biome lint src tests",
|
|
30
30
|
"format": "biome format --write src tests",
|
|
31
31
|
"check": "biome check src tests",
|
|
32
|
-
"test:workers": "cd tests/workers && node run.mjs"
|
|
32
|
+
"test:workers": "bun pm pack --destination tests/workers && cd tests/workers && mv bunqueue-client-*.tgz bunqueue-client.tgz && bun install && node run.mjs"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"queue",
|