@ferricstore/ferricstore 0.1.6 → 0.1.7
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 +219 -8
- package/dist/index.cjs +14576 -4786
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1639 -868
- package/dist/index.d.ts +1639 -868
- package/dist/index.js +14609 -4827
- package/dist/index.js.map +1 -1
- package/docs/api/assets/hierarchy.js +1 -1
- package/docs/api/assets/navigation.js +1 -1
- package/docs/api/assets/search.js +1 -1
- package/docs/api/classes/BitmapStore.html +2 -2
- package/docs/api/classes/BloomFilterStore.html +4 -2
- package/docs/api/classes/ClaimHydrationError.html +38 -0
- package/docs/api/classes/ConnectionClosedError.html +37 -0
- package/docs/api/classes/CountMinSketchStore.html +3 -2
- package/docs/api/classes/CuckooFilterStore.html +3 -2
- package/docs/api/classes/FerricStoreClient.html +204 -146
- package/docs/api/classes/FerricStoreError.html +1 -1
- package/docs/api/classes/FlowAlreadyExistsError.html +2 -2
- package/docs/api/classes/FlowBatchError.html +39 -0
- package/docs/api/classes/FlowNotFoundError.html +2 -2
- package/docs/api/classes/FlowWrongStateError.html +2 -2
- package/docs/api/classes/GeoStore.html +4 -2
- package/docs/api/classes/HashStore.html +2 -2
- package/docs/api/classes/HyperLogLogStore.html +3 -2
- package/docs/api/classes/InvalidCommandError.html +2 -2
- package/docs/api/classes/KeyValueStore.html +2 -2
- package/docs/api/classes/LeaseRenewalError.html +34 -0
- package/docs/api/classes/ListStore.html +6 -2
- package/docs/api/classes/LockHeldError.html +2 -2
- package/docs/api/classes/LockNotOwnedError.html +2 -2
- package/docs/api/classes/NativeAdapter.html +4 -2
- package/docs/api/classes/OverloadedError.html +2 -2
- package/docs/api/classes/Queue.html +2 -2
- package/docs/api/classes/QueueClient.html +2 -2
- package/docs/api/classes/QueueCompletionError.html +35 -0
- package/docs/api/classes/QueueWorker.html +2 -2
- package/docs/api/classes/ReconnectingExecutor.html +8 -2
- package/docs/api/classes/RequestTimeoutError.html +38 -0
- package/docs/api/classes/RerouteError.html +36 -0
- package/docs/api/classes/RoutingTopology.html +2 -2
- package/docs/api/classes/SetStore.html +4 -2
- package/docs/api/classes/SortedSetStore.html +3 -2
- package/docs/api/classes/StaleLeaseError.html +2 -2
- package/docs/api/classes/StreamStore.html +2 -2
- package/docs/api/classes/TDigestStore.html +2 -2
- package/docs/api/classes/TopKStore.html +6 -2
- package/docs/api/classes/TopologyNativeAdapterPool.html +7 -2
- package/docs/api/classes/Workflow.html +4 -2
- package/docs/api/classes/WorkflowClient.html +2 -2
- package/docs/api/classes/WorkflowContext.html +2 -2
- package/docs/api/classes/WorkflowFlowCommands.html +3 -2
- package/docs/api/classes/WorkflowWorker.html +2 -2
- package/docs/api/functions/classifyServerError.html +1 -1
- package/docs/api/functions/complete.html +1 -1
- package/docs/api/functions/fail.html +1 -1
- package/docs/api/functions/isOutcome.html +1 -0
- package/docs/api/functions/isReconnectableClosedConnectionError.html +1 -1
- package/docs/api/functions/mapException.html +1 -1
- package/docs/api/functions/retry.html +1 -1
- package/docs/api/functions/transition.html +1 -1
- package/docs/api/hierarchy.html +1 -1
- package/docs/api/index.html +151 -11
- package/docs/api/interfaces/AdminListOptions.html +4 -0
- package/docs/api/interfaces/ApprovalListOptions.html +6 -0
- package/docs/api/interfaces/ApprovalRequestOptions.html +11 -0
- package/docs/api/interfaces/AttributeQueryOptions.html +5 -0
- package/docs/api/interfaces/AutoBatchOptions.html +3 -2
- package/docs/api/interfaces/BackpressurePolicy.html +2 -2
- package/docs/api/interfaces/BudgetCommitOptions.html +3 -0
- package/docs/api/interfaces/BudgetReserveOptions.html +5 -0
- package/docs/api/interfaces/CancelOptions.html +12 -6
- package/docs/api/interfaces/ChildSpec.html +2 -2
- package/docs/api/interfaces/CircuitOpenOptions.html +4 -0
- package/docs/api/interfaces/ClaimDueOptions.html +4 -2
- package/docs/api/interfaces/ClaimHydrationItem.html +3 -0
- package/docs/api/interfaces/ClaimedItem.html +4 -3
- package/docs/api/interfaces/CommandExecutor.html +7 -2
- package/docs/api/interfaces/CompleteJobsAndClaimJobsResult.html +11 -0
- package/docs/api/interfaces/CompleteManyOptions.html +14 -0
- package/docs/api/interfaces/CompleteOptions.html +4 -2
- package/docs/api/interfaces/CompleteOutcome.html +4 -2
- package/docs/api/interfaces/CountMinMergeOptions.html +2 -2
- package/docs/api/interfaces/CreateItem.html +3 -2
- package/docs/api/interfaces/CreateManyOptions.html +10 -2
- package/docs/api/interfaces/CreateOptions.html +6 -2
- package/docs/api/interfaces/EffectCompensateOptions.html +7 -0
- package/docs/api/interfaces/EffectConfirmOptions.html +7 -0
- package/docs/api/interfaces/EffectFailOptions.html +8 -0
- package/docs/api/interfaces/EffectReserveOptions.html +8 -0
- package/docs/api/interfaces/EffectStatusOptions.html +5 -0
- package/docs/api/interfaces/ExecutePipelineOptions.html +6 -2
- package/docs/api/interfaces/ExtendLeaseOptions.html +7 -0
- package/docs/api/interfaces/FailOptions.html +4 -2
- package/docs/api/interfaces/FailOutcome.html +4 -2
- package/docs/api/interfaces/FencedItem.html +2 -2
- package/docs/api/interfaces/FerricStoreClientFromUrlOptions.html +6 -2
- package/docs/api/interfaces/FerricStoreClientOptions.html +6 -2
- package/docs/api/interfaces/FetchOrComputeFencedResult.html +9 -0
- package/docs/api/interfaces/FetchOrComputeHitResult.html +6 -0
- package/docs/api/interfaces/FetchOrComputeLegacyResult.html +9 -0
- package/docs/api/interfaces/FlowBatchCompletedItem.html +3 -0
- package/docs/api/interfaces/FlowPolicyOptions.html +6 -2
- package/docs/api/interfaces/FlowRecord.html +3 -2
- package/docs/api/interfaces/FlowStatePolicy.html +2 -2
- package/docs/api/interfaces/FlowStatsOptions.html +6 -0
- package/docs/api/interfaces/GeoMember.html +2 -2
- package/docs/api/interfaces/GovernanceLedgerOptions.html +6 -0
- package/docs/api/interfaces/HistoryOptions.html +16 -0
- package/docs/api/interfaces/InvocationCreateOptions.html +2 -2
- package/docs/api/interfaces/KeyInfo.html +2 -2
- package/docs/api/interfaces/LeaseMutationOptions.html +14 -0
- package/docs/api/interfaces/LimitAmountOptions.html +4 -0
- package/docs/api/interfaces/LimitLeaseOptions.html +6 -0
- package/docs/api/interfaces/LimitListOptions.html +5 -0
- package/docs/api/interfaces/LimitReleaseOptions.html +4 -0
- package/docs/api/interfaces/MutateOptions.html +4 -2
- package/docs/api/interfaces/NamedValueMutation.html +4 -2
- package/docs/api/interfaces/NativeAdapterOptions.html +21 -9
- package/docs/api/interfaces/NativeClientOptions.html +43 -0
- package/docs/api/interfaces/NativeProtocolEvent.html +5 -0
- package/docs/api/interfaces/ProtocolCommand.html +2 -2
- package/docs/api/interfaces/QueueOptions.html +2 -2
- package/docs/api/interfaces/QueueWorkerResult.html +2 -2
- package/docs/api/interfaces/RangeLimit.html +2 -2
- package/docs/api/interfaces/RateLimitResult.html +2 -2
- package/docs/api/interfaces/ReadOptions.html +2 -2
- package/docs/api/interfaces/ReclaimOptions.html +4 -2
- package/docs/api/interfaces/ReconnectOptions.html +8 -2
- package/docs/api/interfaces/RequestContext.html +2 -2
- package/docs/api/interfaces/RequestContextOptions.html +2 -2
- package/docs/api/interfaces/RetryOptions.html +4 -2
- package/docs/api/interfaces/RetryOutcome.html +4 -2
- package/docs/api/interfaces/RetryPolicy.html +2 -2
- package/docs/api/interfaces/RoutingEndpoint.html +2 -2
- package/docs/api/interfaces/RoutingRoute.html +2 -2
- package/docs/api/interfaces/RunStepsItem.html +3 -0
- package/docs/api/interfaces/RunStepsManyOptions.html +11 -0
- package/docs/api/interfaces/ScanOptions.html +4 -2
- package/docs/api/interfaces/ScheduleFireDueOptions.html +5 -0
- package/docs/api/interfaces/ScheduleListOptions.html +9 -0
- package/docs/api/interfaces/ScheduleOptions.html +16 -0
- package/docs/api/interfaces/SearchOptions.html +2 -2
- package/docs/api/interfaces/StartAndClaimOptions.html +17 -0
- package/docs/api/interfaces/StateOptions.html +2 -2
- package/docs/api/interfaces/StateRegistration.html +2 -2
- package/docs/api/interfaces/StepContinueOptions.html +20 -0
- package/docs/api/interfaces/StoreCommandClient.html +3 -2
- package/docs/api/interfaces/TDigestCreateOptions.html +2 -2
- package/docs/api/interfaces/TDigestMergeOptions.html +2 -2
- package/docs/api/interfaces/TopologyNativeAdapterOptions.html +39 -0
- package/docs/api/interfaces/TransitionOptions.html +4 -2
- package/docs/api/interfaces/TransitionOutcome.html +4 -2
- package/docs/api/interfaces/ValueConfig.html +2 -2
- package/docs/api/interfaces/WorkerConfig.html +23 -2
- package/docs/api/interfaces/WorkflowOptions.html +2 -2
- package/docs/api/interfaces/WorkflowWorkerResult.html +2 -2
- package/docs/api/interfaces/XReadStream.html +2 -2
- package/docs/api/interfaces/ZAddMember.html +2 -2
- package/docs/api/media/kv-store.ts +2 -2
- package/docs/api/modules.html +1 -1
- package/docs/api/types/BackoffKind.html +1 -1
- package/docs/api/types/CollectionScanOptions.html +2 -0
- package/docs/api/types/Command.html +1 -1
- package/docs/api/types/CommandArgument.html +1 -1
- package/docs/api/types/ConnectionRequestDisposition.html +2 -0
- package/docs/api/types/EndpointPolicy.html +2 -1
- package/docs/api/types/ExceptionPolicy.html +1 -1
- package/docs/api/types/ExpiryCondition.html +1 -0
- package/docs/api/types/FencingToken.html +2 -0
- package/docs/api/types/FetchOrComputeComputeResult.html +1 -0
- package/docs/api/types/FetchOrComputeResult.html +1 -0
- package/docs/api/types/FlowAdminRecord.html +1 -0
- package/docs/api/types/FlowStateMode.html +1 -1
- package/docs/api/types/FlowStatePolicyLike.html +1 -1
- package/docs/api/types/GeoAddOptions.html +2 -0
- package/docs/api/types/GetExOptions.html +2 -0
- package/docs/api/types/HashScanResult.html +2 -0
- package/docs/api/types/IntegerReply.html +2 -0
- package/docs/api/types/ManagementPairs.html +1 -1
- package/docs/api/types/MaxActiveMs.html +1 -0
- package/docs/api/types/Outcome.html +1 -1
- package/docs/api/types/QueueBatchHandler.html +1 -1
- package/docs/api/types/QueueHandler.html +1 -1
- package/docs/api/types/QueueJob.html +1 -1
- package/docs/api/types/RequestDisposition.html +1 -0
- package/docs/api/types/SearchStateMeta.html +1 -1
- package/docs/api/types/SetOptions.html +2 -0
- package/docs/api/types/SetScanResult.html +2 -0
- package/docs/api/types/SortedSetScanResult.html +2 -0
- package/docs/api/types/StateMeta.html +1 -1
- package/docs/api/types/StateMetaValue.html +1 -1
- package/docs/api/types/TopKReserveOptions.html +1 -0
- package/docs/api/types/WorkerProfile.html +1 -1
- package/docs/api/types/WorkerRefillStrategy.html +1 -0
- package/docs/api/types/WorkflowHandler.html +1 -1
- package/docs/api/types/ZAddOptions.html +2 -0
- package/docs/api/variables/COMMAND_OPCODES.html +1 -1
- package/docs/api/variables/COMPACT_RESPONSE_OPCODES.html +2 -0
- package/docs/python-parity.md +12 -6
- package/package.json +5 -1
- package/docs/api/classes/JsonStore.html +0 -15
- package/docs/api/interfaces/FetchOrComputeResult.html +0 -6
- package/docs/api/interfaces/GeoAddOptions.html +0 -4
- package/docs/api/interfaces/GetExOptions.html +0 -6
- package/docs/api/interfaces/JsonSetOptions.html +0 -3
- package/docs/api/interfaces/SetOptions.html +0 -9
- package/docs/api/interfaces/TopKReserveOptions.html +0 -4
- package/docs/api/interfaces/ZAddOptions.html +0 -6
package/README.md
CHANGED
|
@@ -39,7 +39,15 @@ docker run -p 6388:6388 \
|
|
|
39
39
|
|
|
40
40
|
## Cluster-aware client
|
|
41
41
|
|
|
42
|
-
For a single node, use `fromUrl`. For a FerricStore cluster, pass multiple seed URLs. The SDK fetches the server `SHARDS` topology, routes keyed commands to the current shard leader, and refuses learned hosts outside the seed-host trust set by default.
|
|
42
|
+
For a single node, use `fromUrl`. For a FerricStore cluster, pass multiple seed URLs. The SDK fetches the server `SHARDS` topology, routes keyed commands to the current shard leader, and refuses learned hosts outside the seed-host trust set by default. The creation promise resolves only after startup and authentication succeed; cluster creation also waits for the initial topology, so connection failures reject the corresponding `await` directly.
|
|
43
|
+
|
|
44
|
+
Cross-shard pipelines are grouped into one native pipeline per leader/lane and
|
|
45
|
+
merged back into caller order. Decomposable multi-key commands (`MGET`,
|
|
46
|
+
`EXISTS`, `DEL`, `UNLINK`, and `FLOW.VALUE.MGET`) use the same parallel shard
|
|
47
|
+
fan-out; atomic multi-key commands are never split client-side. Pass
|
|
48
|
+
`{ ordered: true }` as the second argument to `client.pipeline()` when later
|
|
49
|
+
commands depend on earlier ones and the transport may need an individual or
|
|
50
|
+
cross-route fallback.
|
|
43
51
|
|
|
44
52
|
```ts
|
|
45
53
|
const flow = await FerricStoreClient.fromUrls(
|
|
@@ -53,6 +61,8 @@ const flow = await FerricStoreClient.fromUrls(
|
|
|
53
61
|
nativeOptions: {
|
|
54
62
|
// Use "any" only inside a trusted private network.
|
|
55
63
|
endpointPolicy: "seed_hosts",
|
|
64
|
+
// Bound client-side route fan-out; freed slots refill immediately.
|
|
65
|
+
topologyConcurrency: 16,
|
|
56
66
|
warmConnections: true
|
|
57
67
|
}
|
|
58
68
|
}
|
|
@@ -62,6 +72,84 @@ await flow.refreshTopology();
|
|
|
62
72
|
console.log(await flow.route("tenant-a:order-1"));
|
|
63
73
|
```
|
|
64
74
|
|
|
75
|
+
Learned topology endpoints are checked before connection. The default
|
|
76
|
+
`"seed_hosts"` policy permits exact seed endpoints plus `trustedHosts`;
|
|
77
|
+
`"none"` permits exact seed endpoints only. Use `"any"` only when every
|
|
78
|
+
server-advertised endpoint is already inside a trusted network boundary.
|
|
79
|
+
All HA seed URLs must use the same `ferric://` or `ferrics://` transport;
|
|
80
|
+
`tlsOptions` configures a secure transport but does not change a URL's scheme.
|
|
81
|
+
Each seed connection uses only the credentials embedded in its own URL. The
|
|
82
|
+
first complete seed credential pair is reused for learned cluster endpoints,
|
|
83
|
+
but never overrides another seed URL, even when that seed is first reached
|
|
84
|
+
through learned topology. Duplicate seed endpoints with conflicting effective
|
|
85
|
+
credentials are rejected. Explicit `nativeOptions.username` and `password`
|
|
86
|
+
remain an intentional cluster-wide override.
|
|
87
|
+
|
|
88
|
+
The option types follow ownership: `NativeAdapterOptions` contains direct
|
|
89
|
+
connection settings, `TopologyNativeAdapterOptions` adds learned-endpoint
|
|
90
|
+
policy, and `NativeClientOptions` adds reconnect/HA seed selection. Passing a
|
|
91
|
+
higher-layer option to `NativeAdapter.fromUrl()` is rejected instead of being
|
|
92
|
+
silently ignored.
|
|
93
|
+
|
|
94
|
+
`topologyConcurrency` defaults to 16 and bounds client-side per-route work such
|
|
95
|
+
as cross-shard fan-out, split pipelines, warm-up, and shutdown. It uses
|
|
96
|
+
continuous slot filling: when one route finishes, the next waiting route starts
|
|
97
|
+
without waiting for the rest of the current group. This setting is local to one
|
|
98
|
+
client process or pod; it does not configure FerricStore server concurrency.
|
|
99
|
+
|
|
100
|
+
Automatic reconnect retries only an operation rejected before it could be
|
|
101
|
+
written. If a connection closes while a request is in flight, the SDK surfaces
|
|
102
|
+
that error because the server may already have applied the command; it does not
|
|
103
|
+
replay an uncertain mutation. A later request reconnects normally. Use
|
|
104
|
+
FerricFlow fencing or command-level idempotency when the caller needs safe
|
|
105
|
+
application retries. `ConnectionClosedError.requestDisposition` exposes this
|
|
106
|
+
decision as `"unsent"` or `"possibly_sent"` when the transport can classify it;
|
|
107
|
+
unclassified failures are treated conservatively as possibly sent.
|
|
108
|
+
`RequestTimeoutError.requestDisposition` provides the same retry-safety signal:
|
|
109
|
+
timeouts while waiting for a local flow-control or write-queue slot are
|
|
110
|
+
`"unsent"`, while a request whose frame entered the socket is
|
|
111
|
+
`"possibly_sent"`. Do not automatically retry a possibly-sent mutation.
|
|
112
|
+
`autoReconnect` accepts `maxRetries`, `baseDelayMs`, `maxDelayMs`, and
|
|
113
|
+
`jitterPct`; backoff is applied only after a reconnect attempt itself fails.
|
|
114
|
+
|
|
115
|
+
Topology-aware clients retry one routed command or one physical fused pipeline
|
|
116
|
+
after a successful topology refresh only when the server's typed reroute error
|
|
117
|
+
explicitly reports `safe_to_retry: true`. Split or scattered pipelines and
|
|
118
|
+
uncertain connection failures are never replayed.
|
|
119
|
+
|
|
120
|
+
Connection-local state mutations (`AUTH`, `CLIENT SETNAME`, `QUIT`, `RESET`,
|
|
121
|
+
and related native controls) are rejected on reconnecting and topology clients
|
|
122
|
+
because they cannot be applied atomically to every current and future socket.
|
|
123
|
+
Configure `nativeOptions.username`, `password`, `clientName`, and `events` when
|
|
124
|
+
creating those clients, and use `close()` for shutdown. A directly managed
|
|
125
|
+
single `NativeAdapter` retains connection-local command semantics. Native
|
|
126
|
+
`CLIENT TRACKING` and `CLIENT CACHING` are unsupported; use native event
|
|
127
|
+
subscriptions instead.
|
|
128
|
+
|
|
129
|
+
### Deployment integration tests
|
|
130
|
+
|
|
131
|
+
The default integration suite targets one local development server. Real HA,
|
|
132
|
+
TLS, and authentication deployments can be verified with the opt-in deployment
|
|
133
|
+
suite:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
FERRICSTORE_HA_URLS=ferric://fs0:6388,ferric://fs1:6388 npm run test:integration:deployment
|
|
137
|
+
|
|
138
|
+
FERRICSTORE_TLS_URL=ferrics://fs0:6389 \
|
|
139
|
+
FERRICSTORE_TLS_CA_FILE=/path/to/ca.pem \
|
|
140
|
+
npm run test:integration:deployment
|
|
141
|
+
|
|
142
|
+
FERRICSTORE_AUTH_URL=ferric://app:secret@fs0:6388 \
|
|
143
|
+
npm run test:integration:deployment
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The HA fixture must advertise at least two reachable leader endpoints. The auth
|
|
147
|
+
fixture must require credentials even for the default user. Set
|
|
148
|
+
`FERRICSTORE_TLS_PLAINTEXT_URL` as well to verify that a TLS-only deployment
|
|
149
|
+
rejects its plaintext listener. HA TLS/auth options are available through
|
|
150
|
+
`FERRICSTORE_HA_TLS_CA_FILE`, `FERRICSTORE_HA_TLS_SERVERNAME`,
|
|
151
|
+
`FERRICSTORE_HA_USERNAME`, and `FERRICSTORE_HA_PASSWORD`.
|
|
152
|
+
|
|
65
153
|
You can also keep one primary URL and add seeds:
|
|
66
154
|
|
|
67
155
|
```ts
|
|
@@ -73,6 +161,25 @@ const flow = await FerricStoreClient.fromUrl("ferric://fs0.example.com:6388", {
|
|
|
73
161
|
});
|
|
74
162
|
```
|
|
75
163
|
|
|
164
|
+
Native connections honor the flow-control windows advertised by `STARTUP` and
|
|
165
|
+
`WINDOW_UPDATE`. Available data-request slots are refilled immediately as
|
|
166
|
+
responses finish; waiting requests are scheduled fairly across protocol lanes.
|
|
167
|
+
The adapter also caps automatic lanes and same-lane work to the advertised lane
|
|
168
|
+
queue, and caps ordered pipeline chunks and outbound frame bodies to the limits
|
|
169
|
+
negotiated during `STARTUP`.
|
|
170
|
+
Set `nativeOptions.maxQueuedRequests` to bound the local waiter queue (default
|
|
171
|
+
`65_536`, or `0` to reject immediately when all advertised slots are occupied).
|
|
172
|
+
Queue waiting counts toward `nativeOptions.timeoutMs`.
|
|
173
|
+
|
|
174
|
+
Control requests do not consume server data credits. Set
|
|
175
|
+
`nativeOptions.maxPendingControlRequests` to bound correlated control requests
|
|
176
|
+
awaiting responses on each connection (default `4_096`).
|
|
177
|
+
|
|
178
|
+
If Node reports socket backpressure, later encoded frames wait for `drain` in a
|
|
179
|
+
bounded client queue. Set `nativeOptions.maxQueuedWriteBytes` to control that
|
|
180
|
+
queue (default 64 MiB, or `0` to reject subsequent writes immediately). Healthy
|
|
181
|
+
socket writes still go directly to `socket.write` without entering the queue.
|
|
182
|
+
|
|
76
183
|
## Durable Queue
|
|
77
184
|
|
|
78
185
|
```ts
|
|
@@ -89,7 +196,12 @@ await emails.enqueue("email-1", {
|
|
|
89
196
|
payload: { template: "welcome", userId: "user-1" }
|
|
90
197
|
});
|
|
91
198
|
|
|
92
|
-
await emails.
|
|
199
|
+
await emails.enqueueMany([{ id: "email-2", payload: { template: "receipt" } }], {
|
|
200
|
+
autoPartitionBatchSize: 1_000,
|
|
201
|
+
autoPartitionConcurrency: 8
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
await emails.worker({ batchSize: 100, concurrency: 16, worker: "email-worker-1" }).run(async (job) => {
|
|
93
205
|
console.log(job.id, job.payload);
|
|
94
206
|
return { sent: true };
|
|
95
207
|
});
|
|
@@ -126,6 +238,7 @@ await order.start("order-1", {
|
|
|
126
238
|
|
|
127
239
|
await order.worker({
|
|
128
240
|
batchSize: 50,
|
|
241
|
+
concurrency: 8,
|
|
129
242
|
states: ["created", "charged"],
|
|
130
243
|
worker: "order-worker-1"
|
|
131
244
|
}).run();
|
|
@@ -140,6 +253,49 @@ Handlers return explicit durable outcomes:
|
|
|
140
253
|
|
|
141
254
|
FerricFlow does not replay TypeScript handler code. Workers claim a durable state, run normal code, then write the next state through the FerricFlow API.
|
|
142
255
|
|
|
256
|
+
Per-job `run()` workers cap every claim to currently available concurrency. They continuously refill slots by default, so if five of ten jobs finish and their terminal writes are acknowledged, one client-side `claim(limit: 5)` can start five replacements while the other five continue. Queue completions produced in the same event-loop turn remain batched. A slot stays occupied through its `complete`, `retry`, or `fail` acknowledgement; the worker never exceeds its local concurrency limit.
|
|
257
|
+
|
|
258
|
+
Full-record claims across multiple states are returned by the claim command itself, including requested payloads and named values. `FLOW.GET` hydration is retained only for compatibility with a server that unexpectedly returns legacy compact tuples. That fallback preserves result order and is bounded to 16 concurrent reads by default; set `legacyClaimHydrationConcurrency` on the client to tune it. If a fallback read fails, `ClaimHydrationError.claimed` contains every already-leased job, while `hydratedItems` contains the indexed records that finished successfully; `failedIndex` and `cause` identify the first observed failure. Set `jobOnly: true` when compact claim metadata is sufficient; compact state metadata is decoded directly from the claim response without per-job `FLOW.GET` calls.
|
|
259
|
+
|
|
260
|
+
Use `refillStrategy: "wave"` to wait for the entire current claim to settle before claiming again. `refillDelayMs` adds a small coalescing window before a continuous refill; the default `0` still coalesces completions for one event-loop turn. Batchable queue completions and same-route replacement claims share one ordered native pipeline by default; set `fuseCompleteClaim: false` to keep them as separate requests. `runOnce()` and batch-handler APIs remain finite and wave-oriented. These controls are local to one worker instance or pod: two pods configured with `concurrency: 10` can execute up to twenty jobs collectively.
|
|
261
|
+
|
|
262
|
+
Worker claim and terminal-write batches use the client's `flowManyBatchLimit`,
|
|
263
|
+
which defaults to FerricStore's standard 1,000-item limit and should match the
|
|
264
|
+
server's `flow_max_batch_items` setting. Higher handler concurrency remains
|
|
265
|
+
supported and is filled through multiple bounded claims. `completeAsyncDepth`
|
|
266
|
+
is normalized to a finite, non-negative integer; non-finite values use the safe
|
|
267
|
+
worker-mode default. If an asynchronous completion fails after earlier writes
|
|
268
|
+
succeed, `QueueCompletionError.completed` reports every successful completion
|
|
269
|
+
drained by the same call, regardless of where the failed completion appeared.
|
|
270
|
+
|
|
271
|
+
When a worker combines `blockMs` with an `AbortSignal`, native long polls are
|
|
272
|
+
bounded by `abortPollMs` (default `1_000`) so shutdown is observed without
|
|
273
|
+
abandoning an in-flight claim that may already have leased work. Finite server
|
|
274
|
+
blocking time is added to the transport timeout rather than consuming it.
|
|
275
|
+
|
|
276
|
+
Unpartitioned `enqueueMany` calls group items in linear time, preserve caller
|
|
277
|
+
result order, keep chunks for the same auto-partition sequential, and dispatch
|
|
278
|
+
different partitions with bounded concurrency. The defaults above match the
|
|
279
|
+
server's standard 1,000-item Flow batch limit while avoiding unbounded requests.
|
|
280
|
+
Explicit and mixed-partition independent batches use the same hard request cap;
|
|
281
|
+
all Flow many mutations split larger inputs only when `independent: true`.
|
|
282
|
+
`independent: false` is never silently split and rejects oversized inputs before
|
|
283
|
+
dispatch. Set `flowManyBatchLimit` on the client when the server uses a custom
|
|
284
|
+
`flow_max_batch_items` value. If a later independent chunk fails,
|
|
285
|
+
`FlowBatchError.completedItems` reports the exact input indices and values whose
|
|
286
|
+
results were already confirmed; the original failure remains available as
|
|
287
|
+
`cause`.
|
|
288
|
+
|
|
289
|
+
Workers renew active leases every half lease by default and stop renewal before the fenced terminal write. Set `leaseRenewal: false` only when the handler is guaranteed to finish comfortably inside `leaseMs`; use `leaseRenewIntervalMs` to override the renewal interval.
|
|
290
|
+
|
|
291
|
+
`ctx.valueMany(names)` deduplicates shared references and fetches every missing referenced value with one `FLOW.VALUE.MGET`. Inline and locally cached values do not consume network work, and a stored JSON `null` remains distinct from a missing reference.
|
|
292
|
+
|
|
293
|
+
Flow fencing tokens remain `number` values while safe and are returned as
|
|
294
|
+
`bigint` once they exceed JavaScript's safe integer range. Pass the token back
|
|
295
|
+
unchanged; all fenced mutation APIs accept the exported `FencingToken` type,
|
|
296
|
+
and native compact claim and batch paths preserve its signed 64-bit value
|
|
297
|
+
exactly.
|
|
298
|
+
|
|
143
299
|
## Low-Level Flow Commands
|
|
144
300
|
|
|
145
301
|
```ts
|
|
@@ -171,6 +327,51 @@ for (const job of jobs) {
|
|
|
171
327
|
}
|
|
172
328
|
```
|
|
173
329
|
|
|
330
|
+
Flow attributes can be returned without hydrating each record and can be
|
|
331
|
+
updated atomically with the fenced state mutation:
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
const attributed = await flow.claimDue("order", {
|
|
335
|
+
includeAttributes: true,
|
|
336
|
+
jobOnly: true,
|
|
337
|
+
state: "created",
|
|
338
|
+
worker: "worker-1"
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
await flow.transition(attributed[0]!.id, {
|
|
342
|
+
attributesDelete: ["temporary"],
|
|
343
|
+
attributesMerge: { processor: "payments-v2" },
|
|
344
|
+
fencingToken: attributed[0]!.fencingToken,
|
|
345
|
+
fromState: "created",
|
|
346
|
+
leaseToken: attributed[0]!.leaseToken,
|
|
347
|
+
toState: "charged"
|
|
348
|
+
});
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
The low-level client also exposes the fused `startAndClaim`, `stepContinue`,
|
|
352
|
+
and `runStepsMany` operations, schedule administration, Flow statistics and
|
|
353
|
+
attribute queries, effects, approvals, circuits, budgets, and distributed
|
|
354
|
+
limits. History supports the complete server filter surface, including event,
|
|
355
|
+
time, and version bounds plus cold/consistent reads and payload hydration:
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
const events = await flow.history("order-1", {
|
|
359
|
+
consistentProjection: true,
|
|
360
|
+
fromVersion: 2,
|
|
361
|
+
includeCold: true,
|
|
362
|
+
payloadMaxBytes: 64_000,
|
|
363
|
+
toVersion: 8,
|
|
364
|
+
values: true
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
await flow.scheduleCreate("orders-every-five-minutes", {
|
|
368
|
+
cron: "*/5 * * * *",
|
|
369
|
+
kind: "cron",
|
|
370
|
+
target: { state: "created", type: "order" },
|
|
371
|
+
timezone: "UTC"
|
|
372
|
+
});
|
|
373
|
+
```
|
|
374
|
+
|
|
174
375
|
FIFO Flow state policy is opt-in per state:
|
|
175
376
|
|
|
176
377
|
```ts
|
|
@@ -207,10 +408,16 @@ await client.lists.lpush("jobs", { id: "job-1" });
|
|
|
207
408
|
await client.sets.sadd("seen-users", "user:1");
|
|
208
409
|
await client.zset.zadd("leaderboard", [{ score: 42, member: "user:1" }]);
|
|
209
410
|
await client.stream.xadd("events", "*", { type: "created", id: "user:1" });
|
|
210
|
-
await client.json.set("user:1:json", "$", { name: "Ada" });
|
|
211
411
|
await client.bloom.add("seen-filter", "user:1");
|
|
212
412
|
```
|
|
213
413
|
|
|
414
|
+
Large unambiguous scalar batches accept an array without spreading, for example
|
|
415
|
+
`client.kv.del(keys)` and `client.tdigest.add(key, values)`. Codec-backed APIs,
|
|
416
|
+
where an array may itself be one stored value, expose explicit methods such as
|
|
417
|
+
`lpushMany`, `saddMany`, `zremMany`, `maddMany`, and `queryMany`. These forms
|
|
418
|
+
avoid JavaScript's variadic-call limit and build the command in one linear pass;
|
|
419
|
+
the existing rest-argument forms retain their original meaning.
|
|
420
|
+
|
|
214
421
|
Available store helpers:
|
|
215
422
|
|
|
216
423
|
- `client.kv` — strings, key expiry, key management, scans.
|
|
@@ -223,9 +430,13 @@ Available store helpers:
|
|
|
223
430
|
- `client.hyperloglog` — HyperLogLog commands.
|
|
224
431
|
- `client.geo` — geospatial commands.
|
|
225
432
|
- `client.bloom`, `client.cuckoo`, `client.cms`, `client.topk`, `client.tdigest` — probabilistic data structures.
|
|
226
|
-
- `client.json` — RedisJSON-compatible JSON commands.
|
|
227
433
|
|
|
228
|
-
|
|
434
|
+
`JsonCodec` serializes ordinary FerricStore values as JSON; FerricStore does not expose RedisJSON `JSON.*` commands.
|
|
435
|
+
|
|
436
|
+
Transactions and raw subscription flows require an exclusive pinned connection
|
|
437
|
+
session, which the multiplexed native client does not currently expose. The SDK
|
|
438
|
+
rejects those commands before dispatch so a failed transaction cannot partially
|
|
439
|
+
apply mutations.
|
|
229
440
|
|
|
230
441
|
## Auto-Batching
|
|
231
442
|
|
|
@@ -249,17 +460,17 @@ await Promise.all([
|
|
|
249
460
|
]);
|
|
250
461
|
```
|
|
251
462
|
|
|
252
|
-
Auto-batching groups eligible concurrent commands into native `PIPELINE` frames and resolves each original promise independently. Blocking/session commands such as `FLOW.CLAIM_DUE`, `AUTH`, `
|
|
463
|
+
Auto-batching groups eligible concurrent commands into native `PIPELINE` frames and resolves each original promise independently. Across frames and individual-request fallbacks, same-key write dependencies retain invocation order, while read-only and disjoint-key work remains concurrent. Commands whose direct native representation uses a custom binary body are safely wrapped as typed `COMMAND_EXEC` pipeline items, preserving one pipeline request instead of issuing each command separately. Blocking/session and control commands such as `FLOW.CLAIM_DUE`, `BLPOP`, `XREAD`, `AUTH`, `PING`, `OPTIONS`, and `QUIT` bypass auto-batching. Explicit pipelines issue unsupported or connection-blocking items individually; blocking fallbacks and state-changing controls are sequenced with dependent data commands. Other fallbacks remain concurrent unless `client.pipeline(commands, { ordered: true })` is requested. Individual fallbacks continuously refill a bounded pool instead of starting every request at once; the default limit is 64 and `fallbackConcurrency` on the pipeline options can tune it per call. Native pipeline paths are unchanged. Reconnecting and topology executors reject connection-local mutations before dispatch, and an uncertain native pipeline is never replayed automatically.
|
|
253
464
|
|
|
254
465
|
Queue workers are latency-first by default. For high-throughput queue workers, use one profile flag:
|
|
255
466
|
|
|
256
467
|
```ts
|
|
257
|
-
await emails.worker({ profile: "throughput" }).run(async (job) => {
|
|
468
|
+
await emails.worker({ profile: "throughput", concurrency: 32 }).run(async (job) => {
|
|
258
469
|
await sendEmail(job.id);
|
|
259
470
|
});
|
|
260
471
|
```
|
|
261
472
|
|
|
262
|
-
The throughput profile uses compact claims, larger
|
|
473
|
+
The throughput profile uses compact claims, a larger batch ceiling, and concurrent completion batching. Per-job claim credit follows currently available `concurrency` (or its `workers` alias), capped by `batchSize`; explicit worker options override profile defaults.
|
|
263
474
|
|
|
264
475
|
## Examples
|
|
265
476
|
|