@crvouga/mockingbird-service-redis 2.11.0 → 2.13.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/DISCOVERY.md +29 -0
- package/README.md +33 -3
- package/SUPPORT.md +10 -0
- package/dist/chunk-22CTWFCU.js +1 -0
- package/dist/{chunk-TVELGGZ4.js → chunk-AMGKTUAB.js} +53 -584
- package/dist/chunk-AMGKTUAB.js.map +7 -0
- package/dist/{chunk-TNRSFAUM.js → chunk-CXFQFJZ3.js} +20 -94
- package/dist/chunk-CXFQFJZ3.js.map +7 -0
- package/dist/chunk-PJCRB2CA.js +622 -0
- package/dist/chunk-PJCRB2CA.js.map +7 -0
- package/dist/chunk-UO4RZQ54.js +203 -0
- package/dist/chunk-UO4RZQ54.js.map +7 -0
- package/dist/cli.js +90 -22
- package/dist/cli.js.map +3 -3
- package/dist/index.js +5 -3
- package/dist/server.d.ts +10 -298
- package/dist/server.js +7 -2
- package/dist/transport.d.ts +77 -0
- package/dist/transport.js +8 -0
- package/dist/transport.js.map +7 -0
- package/package.json +6 -1
- package/dist/chunk-BIMEYU5A.js +0 -1
- package/dist/chunk-TNRSFAUM.js.map +0 -7
- package/dist/chunk-TVELGGZ4.js.map +0 -7
- /package/dist/{chunk-BIMEYU5A.js.map → chunk-22CTWFCU.js.map} +0 -0
package/DISCOVERY.md
CHANGED
|
@@ -4,6 +4,35 @@ This is the installed-package index for coding agents and tooling. All relative
|
|
|
4
4
|
inside `node_modules/@crvouga/mockingbird-service-redis/`; no repository checkout is needed to discover the emulator's
|
|
5
5
|
supported surface or documented behavior.
|
|
6
6
|
|
|
7
|
+
## Run it in a fleet
|
|
8
|
+
|
|
9
|
+
The recommended way to run this emulator is in a fleet, next to the other emulators the
|
|
10
|
+
application calls: one `mockingbird.json`, one process, each emulator on its own port.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install -D @crvouga/mockingbird-fleet @crvouga/mockingbird-service-redis
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`mockingbird.json` (add one entry per installed emulator; `"port": 0` picks a free port):
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"services": {
|
|
21
|
+
"redis": { "protocol": "redis", "port": 0 }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx mockingbird-fleet serve --config mockingbird.json --dashboard --ready-file ready.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Read this emulator's URL from `services.<name>.url` in `ready.json` and point the client at it.
|
|
31
|
+
`adminBase` in the same file is the fleet controller, which resets, snapshots and restores every
|
|
32
|
+
emulator in one call, and `dashboard` is one page with every HTTP emulator's admin UI and the
|
|
33
|
+
notifications the application sent. The guide: <https://mockingbird.chrisvouga.dev/docs/fleets>. The README covers running this
|
|
34
|
+
emulator alone or in-process.
|
|
35
|
+
|
|
7
36
|
## Capability and behavior sources
|
|
8
37
|
|
|
9
38
|
| Question | Authoritative file | What it contains |
|
package/README.md
CHANGED
|
@@ -26,10 +26,9 @@ import { Redis } from "ioredis"
|
|
|
26
26
|
import { createRedis, manualClock } from "@crvouga/mockingbird-service-redis"
|
|
27
27
|
import { serve } from "@crvouga/mockingbird-service-redis/server"
|
|
28
28
|
|
|
29
|
-
// Test setup: an emulator on a manual clock, listening on a free port.
|
|
30
|
-
// because the two entry points bundle separate declarations of the `Redis` type.
|
|
29
|
+
// Test setup: an emulator on a manual clock, listening on a free port.
|
|
31
30
|
const emulator = createRedis({ clock: manualClock(1_700_000_000_000) })
|
|
32
|
-
const server = await serve(emulator
|
|
31
|
+
const server = await serve(emulator, { port: 0 })
|
|
33
32
|
|
|
34
33
|
// Application code: the ioredis client it already uses, connected to the emulator.
|
|
35
34
|
const redis = new Redis({ host: server.host, port: server.port })
|
|
@@ -51,6 +50,34 @@ are the test controls.
|
|
|
51
50
|
`ioredis` connects to the TCP server unchanged. Cluster `MOVED` / `ASK` is not implemented:
|
|
52
51
|
`CLUSTER` and `READONLY` answer that cluster support is disabled.
|
|
53
52
|
|
|
53
|
+
### Without a listener (browser, worker, edge)
|
|
54
|
+
|
|
55
|
+
`createRespServer(redis, options?)` from `@crvouga/mockingbird-service-redis/transport` is the same
|
|
56
|
+
RESP server with no TCP listener and no `node:` import, so it bundles for a browser or worker.
|
|
57
|
+
`server.accept(stream)` serves one client connection given as `{ readable, writable }` web byte
|
|
58
|
+
streams or a Node `Duplex`, and resolves when that connection closes; the session's blocking
|
|
59
|
+
waiters, `MULTI` state, subscriptions and `CLIENT` registration are then released. `serve()` is this
|
|
60
|
+
server behind `net.createServer`. Options are `admit` and `controlPrivileged` as for `serve()`, plus
|
|
61
|
+
`closeEngine` (default `true`) for `server.close()`. The connection shape is the same as
|
|
62
|
+
`createWireServer` from `@crvouga/mockingbird-service-postgres/transport`.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { createRedis } from "@crvouga/mockingbird-service-redis"
|
|
66
|
+
import { createRespServer } from "@crvouga/mockingbird-service-redis/transport"
|
|
67
|
+
|
|
68
|
+
const server = createRespServer(createRedis())
|
|
69
|
+
const toServer = new TransformStream<Uint8Array, Uint8Array>()
|
|
70
|
+
const toClient = new TransformStream<Uint8Array, Uint8Array>()
|
|
71
|
+
void server.accept({ readable: toServer.readable, writable: toClient.writable })
|
|
72
|
+
// Hand the other ends (toServer.writable, toClient.readable) to the client as a socket, e.g.
|
|
73
|
+
// through ioredis's `Connector` option.
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The server writes replies in the order it produces them. Your client-side socket must deliver
|
|
77
|
+
chunks in order too: `ioredis` and BullMQ assume bytes written in one tick arrive before a timer of
|
|
78
|
+
the next, so schedule delivery on a microtask or a `MessageChannel`, not `setTimeout(0)` (clamped to
|
|
79
|
+
4 ms in a browser).
|
|
80
|
+
|
|
54
81
|
`mockingbird-redis serve --config mockingbird.json` supervises mixed HTTP/Postgres/Redis fleets.
|
|
55
82
|
See [fleet configuration and controls](../../../docs/FLEETS.md) for ephemeral discovery, namespace
|
|
56
83
|
endpoints, readiness, shutdown and coordinated state controls.
|
|
@@ -65,6 +92,9 @@ endpoints, readiness, shutdown and coordinated state controls.
|
|
|
65
92
|
- `RedisReplyError` is a Redis error reply raised by `call`.
|
|
66
93
|
- `manualClock(start)` moves only when `advance` is called. `wallClock` follows `Date.now()`.
|
|
67
94
|
- `encodeReply(reply, protocol)` writes a RESP2 or RESP3 frame.
|
|
95
|
+
- `/server`: `serve(redis, options?)` listens over TCP; `serveTarget` boots it from `serve --config`.
|
|
96
|
+
- `/transport`: `createRespServer(redis, options?)` returns `{ accept(stream), connections, close() }`
|
|
97
|
+
with no listener (see above).
|
|
68
98
|
|
|
69
99
|
## Deliberately not modelled
|
|
70
100
|
|
package/SUPPORT.md
CHANGED
|
@@ -89,6 +89,16 @@ run). Tests: `test/redis.commands.test.ts`.
|
|
|
89
89
|
| `COMMAND`, `COMMAND COUNT`, `LIST` (incl. `FILTERBY`), `INFO`, `DOCS`, `GETKEYS` | Metadata for the commands the emulator implements (captured from redis-server 8.4.0 by `scripts/command-table.ts`). `COMMAND COUNT` is the number of those commands, not Redis's `272`. `GETKEYS` handles fixed key specs plus `EVAL`, `ZUNIONSTORE`-style `numkeys`, `LMPOP` and `XREAD`. Sub-command entries and key specifications inside `INFO` are empty arrays. |
|
|
90
90
|
| `COMMAND GETKEYSANDFLAGS`, `COMMAND HELP` | **Unsupported**, explicit `ERR COMMAND <sub> is not supported by the Mockingbird Redis emulator`. |
|
|
91
91
|
|
|
92
|
+
## Transports (#698)
|
|
93
|
+
|
|
94
|
+
The RESP server runs over TCP (`serve` from `/server`, Node and Bun) or over any injected
|
|
95
|
+
connection (`createRespServer` from `/transport`, no `node:` import: browser, worker, edge). Both
|
|
96
|
+
paths run the same session code, so blocking commands, `MULTI`, pub/sub and `CLIENT` behave the
|
|
97
|
+
same; a closed stream releases the session as a closed socket does. `test/redis.transport.test.ts`
|
|
98
|
+
drives it with unmodified ioredis over in-memory web streams and over a Node `Duplex`. Not a
|
|
99
|
+
vendor behaviour, so there is no oracle comparison; the in-process transport is a Mockingbird
|
|
100
|
+
feature.
|
|
101
|
+
|
|
92
102
|
## Fleet controls
|
|
93
103
|
|
|
94
104
|
The fleet adapter supports dynamic namespace listeners, finite numeric seeds, boot/reset clocks,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-22CTWFCU.js.map
|