rivetkit 0.0.0-feat-sqlite-sync.32022a9 → 0.0.0-feat-sqlite-sync-3x.a00b07f
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/dist/browser/client.d.ts +58 -9
- package/dist/browser/client.js +193 -23
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -5
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/agent-os/index.cjs +3 -2652
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -2758
- package/dist/tsup/agent-os/index.d.ts +1 -2758
- package/dist/tsup/agent-os/index.js +3 -2652
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-6ZHUGY2E.cjs → chunk-3JPXBFED.cjs} +4 -4
- package/dist/tsup/{chunk-6ZHUGY2E.cjs.map → chunk-3JPXBFED.cjs.map} +1 -1
- package/dist/tsup/{chunk-6VNQCLKF.js → chunk-5X35FD2T.js} +4 -4
- package/dist/tsup/{chunk-BJGWUWNE.js → chunk-6QNBANXM.js} +3 -3
- package/dist/tsup/{chunk-Z6IVW2Y5.js → chunk-7HILY7QU.js} +188 -28
- package/dist/tsup/chunk-7HILY7QU.js.map +1 -0
- package/dist/tsup/{chunk-JI6GZ2C2.js → chunk-A2CF6PFH.js} +18 -1
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-7XBDAFGQ.cjs → chunk-CT6GQRUN.cjs} +3 -3
- package/dist/tsup/{chunk-7XBDAFGQ.cjs.map → chunk-CT6GQRUN.cjs.map} +1 -1
- package/dist/tsup/{chunk-M27XAZNI.js → chunk-DRZTELHJ.js} +10 -14
- package/dist/tsup/chunk-DRZTELHJ.js.map +1 -0
- package/dist/tsup/{chunk-EDJKDOI2.js → chunk-DUGEPEJO.js} +2 -2
- package/dist/tsup/{chunk-PMU5EDGT.cjs → chunk-EA6P3N4I.cjs} +3 -3
- package/dist/tsup/{chunk-PMU5EDGT.cjs.map → chunk-EA6P3N4I.cjs.map} +1 -1
- package/dist/tsup/{chunk-WE7D64FW.cjs → chunk-ERZDCOQ3.cjs} +10 -10
- package/dist/tsup/{chunk-WE7D64FW.cjs.map → chunk-ERZDCOQ3.cjs.map} +1 -1
- package/dist/tsup/{chunk-UZ5O42HF.js → chunk-GHTA76HT.js} +2 -2
- package/dist/tsup/{chunk-IAVZH6HH.js → chunk-ID5VJNZY.js} +2 -2
- package/dist/tsup/{chunk-2LRKNNQJ.cjs → chunk-PXIOH445.cjs} +327 -167
- package/dist/tsup/chunk-PXIOH445.cjs.map +1 -0
- package/dist/tsup/{chunk-MYWZCDML.cjs → chunk-RTWH3AX3.cjs} +19 -2
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-5LBUG2IK.cjs → chunk-UV4KDO4W.cjs} +3 -3
- package/dist/tsup/{chunk-5LBUG2IK.cjs.map → chunk-UV4KDO4W.cjs.map} +1 -1
- package/dist/tsup/{chunk-HHALUH4L.js → chunk-VI2S336K.js} +2 -2
- package/dist/tsup/{chunk-6BRDJRCZ.cjs → chunk-W7NPIYWC.cjs} +10 -14
- package/dist/tsup/chunk-W7NPIYWC.cjs.map +1 -0
- package/dist/tsup/{chunk-4SIQMCXI.cjs → chunk-ZZQM77UA.cjs} +7 -7
- package/dist/tsup/{chunk-4SIQMCXI.cjs.map → chunk-ZZQM77UA.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +15 -3
- package/dist/tsup/client/mod.d.ts +15 -3
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-DfVrAigH.d.ts → config-B4erdavw.d.ts} +43 -12
- package/dist/tsup/{config-BaUctMNL.d.cts → config-BfG1qpYz.d.cts} +7 -1
- package/dist/tsup/{config-BaUctMNL.d.ts → config-BfG1qpYz.d.ts} +7 -1
- package/dist/tsup/{config-D6T6Ud_V.d.cts → config-DK144OAw.d.cts} +43 -12
- package/dist/tsup/{context-CowF_zyQ.d.cts → context-Cvnf3BRe.d.cts} +2 -2
- package/dist/tsup/{context-BsFWwi3i.d.ts → context-Oxi6YWcG.d.ts} +2 -2
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.js +3 -3
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/mod.cjs +256 -174
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +170 -88
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +17 -17
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +9 -13
- package/src/actor/keys.ts +86 -0
- package/src/agent-os/index.ts +5 -65
- package/src/client/actor-conn.ts +92 -6
- package/src/client/actor-handle.ts +24 -4
- package/src/client/client.ts +14 -4
- package/src/client/config.ts +12 -1
- package/src/client/lifecycle-errors.ts +16 -1
- package/src/client/retry-budget.ts +78 -0
- package/src/client/utils.ts +13 -2
- package/src/common/database/config.ts +7 -1
- package/src/common/database/native-database.ts +17 -9
- package/src/common/router.ts +1 -1
- package/src/engine-api/actors.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +4 -2
- package/src/engine-client/api-endpoints.ts +44 -14
- package/src/engine-client/mod.ts +2 -2
- package/src/registry/config/envoy.ts +1 -1
- package/src/registry/config/index.ts +28 -31
- package/src/registry/index.ts +51 -19
- package/src/registry/napi-runtime.ts +3 -2
- package/src/registry/native.ts +129 -40
- package/src/registry/runtime.ts +27 -10
- package/src/registry/wasm-runtime.ts +6 -3
- package/src/utils/env-vars.ts +15 -10
- package/dist/tsup/chunk-2LRKNNQJ.cjs.map +0 -1
- package/dist/tsup/chunk-6BRDJRCZ.cjs.map +0 -1
- package/dist/tsup/chunk-JI6GZ2C2.js.map +0 -1
- package/dist/tsup/chunk-M27XAZNI.js.map +0 -1
- package/dist/tsup/chunk-MYWZCDML.cjs.map +0 -1
- package/dist/tsup/chunk-Z6IVW2Y5.js.map +0 -1
- package/src/actor/config.test.ts +0 -78
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/agent-os/actor/cron.ts +0 -84
- package/src/agent-os/actor/db.ts +0 -54
- package/src/agent-os/actor/filesystem.ts +0 -131
- package/src/agent-os/actor/index.ts +0 -285
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -190
- package/src/agent-os/actor/process.ts +0 -177
- package/src/agent-os/actor/session.ts +0 -518
- package/src/agent-os/actor/shell.ts +0 -60
- package/src/agent-os/config.ts +0 -79
- package/src/agent-os/fs/database-vfs.ts +0 -624
- package/src/agent-os/types.ts +0 -148
- package/src/client/test.ts +0 -44
- package/src/client/token-provider.test.ts +0 -86
- package/src/common/database/mod.test.ts +0 -364
- package/src/common/database/native-database.test.ts +0 -241
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/db/drizzle.test.ts +0 -164
- package/src/registry/config/index.test.ts +0 -25
- package/src/registry/run-handler-coordinator.test.ts +0 -252
- package/src/registry/runtime.test.ts +0 -124
- package/src/unstable/migrations.test.ts +0 -170
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils.test.ts +0 -34
- package/src/workflow/driver.test.ts +0 -62
- /package/dist/tsup/{chunk-6VNQCLKF.js.map → chunk-5X35FD2T.js.map} +0 -0
- /package/dist/tsup/{chunk-BJGWUWNE.js.map → chunk-6QNBANXM.js.map} +0 -0
- /package/dist/tsup/{chunk-EDJKDOI2.js.map → chunk-DUGEPEJO.js.map} +0 -0
- /package/dist/tsup/{chunk-UZ5O42HF.js.map → chunk-GHTA76HT.js.map} +0 -0
- /package/dist/tsup/{chunk-IAVZH6HH.js.map → chunk-ID5VJNZY.js.map} +0 -0
- /package/dist/tsup/{chunk-HHALUH4L.js.map → chunk-VI2S336K.js.map} +0 -0
|
@@ -167,17 +167,6 @@ export interface RunnerConfigsResponse {
|
|
|
167
167
|
runner_configs: Record<string, RunnerConfigDatacenters>;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
export async function getRunnerConfig(
|
|
171
|
-
config: ClientConfig,
|
|
172
|
-
name: string,
|
|
173
|
-
): Promise<RunnerConfigsResponse> {
|
|
174
|
-
return apiCall<never, RunnerConfigsResponse>(
|
|
175
|
-
config,
|
|
176
|
-
"GET",
|
|
177
|
-
`/runner-configs?runner_name=${name}`,
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
170
|
// MARK: Update runner config
|
|
182
171
|
export interface RegistryConfigRequest {
|
|
183
172
|
datacenters: Record<
|
|
@@ -212,11 +201,11 @@ export async function updateRunnerConfig(
|
|
|
212
201
|
runnerName: string,
|
|
213
202
|
request: RegistryConfigRequest,
|
|
214
203
|
): Promise<void> {
|
|
215
|
-
return apiCall<
|
|
204
|
+
return apiCall<unknown, void>(
|
|
216
205
|
config,
|
|
217
206
|
"PUT",
|
|
218
|
-
`/
|
|
219
|
-
request,
|
|
207
|
+
`/pools/${encodeURIComponent(runnerName)}`,
|
|
208
|
+
Object.values(request.datacenters)[0],
|
|
220
209
|
);
|
|
221
210
|
}
|
|
222
211
|
|
|
@@ -237,3 +226,44 @@ export async function kvGet(
|
|
|
237
226
|
`/actors/${encodeURIComponent(actorId)}/kv/keys/${encodeURIComponent(key)}`,
|
|
238
227
|
);
|
|
239
228
|
}
|
|
229
|
+
|
|
230
|
+
/** Pool changes apply when each node next connects. */
|
|
231
|
+
export interface PoolConfig {
|
|
232
|
+
drain_on_version_upgrade?: boolean;
|
|
233
|
+
actor_eviction_delay?: number;
|
|
234
|
+
actor_eviction_period?: number;
|
|
235
|
+
actor_eviction_rate?: number;
|
|
236
|
+
metadata?: unknown;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export function upsertPool(
|
|
240
|
+
config: ClientConfig,
|
|
241
|
+
name: string,
|
|
242
|
+
pool: PoolConfig,
|
|
243
|
+
): Promise<{ pool: PoolConfig & { name: string } }> {
|
|
244
|
+
return apiCall(config, "PUT", `/pools/${encodeURIComponent(name)}`, pool);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function getPool(
|
|
248
|
+
config: ClientConfig,
|
|
249
|
+
name: string,
|
|
250
|
+
): Promise<{ pool: PoolConfig & { name: string } }> {
|
|
251
|
+
return apiCall(config, "GET", `/pools/${encodeURIComponent(name)}`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function listPools(
|
|
255
|
+
config: ClientConfig,
|
|
256
|
+
page?: { limit?: number; cursor?: string },
|
|
257
|
+
): Promise<{
|
|
258
|
+
pools: Array<PoolConfig & { name: string }>;
|
|
259
|
+
pagination: { cursor: string | null };
|
|
260
|
+
}> {
|
|
261
|
+
const query = new URLSearchParams();
|
|
262
|
+
if (page?.limit !== undefined) query.set("limit", String(page.limit));
|
|
263
|
+
if (page?.cursor !== undefined) query.set("cursor", page.cursor);
|
|
264
|
+
return apiCall(config, "GET", `/pools?${query}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function deletePool(config: ClientConfig, name: string): Promise<void> {
|
|
268
|
+
return apiCall(config, "DELETE", `/pools/${encodeURIComponent(name)}`);
|
|
269
|
+
}
|
package/src/engine-client/mod.ts
CHANGED
|
@@ -254,7 +254,7 @@ export class RemoteEngineControlClient implements EngineControlClient {
|
|
|
254
254
|
datacenter: region,
|
|
255
255
|
name,
|
|
256
256
|
key: serializeActorKey(key),
|
|
257
|
-
|
|
257
|
+
pool: poolName ?? this.#config.poolName,
|
|
258
258
|
input: actorInput
|
|
259
259
|
? uint8ArrayToBase64(
|
|
260
260
|
encodeCborCompat(actorInput as JsonCompatValue),
|
|
@@ -325,7 +325,7 @@ export class RemoteEngineControlClient implements EngineControlClient {
|
|
|
325
325
|
createActor(config, {
|
|
326
326
|
datacenter: region,
|
|
327
327
|
name,
|
|
328
|
-
|
|
328
|
+
pool: poolName ?? this.#config.poolName,
|
|
329
329
|
key: serializeActorKey(key),
|
|
330
330
|
input: input
|
|
331
331
|
? uint8ArrayToBase64(
|
|
@@ -11,7 +11,7 @@ export const EnvoyConfigSchema = z.object({
|
|
|
11
11
|
|
|
12
12
|
// Deprecated.
|
|
13
13
|
totalSlots: z.number().default(() => getRivetTotalSlots() ?? 100000),
|
|
14
|
-
|
|
14
|
+
nodeKey: z.string().optional(),
|
|
15
15
|
});
|
|
16
16
|
export type EnvoyConfigInput = z.input<typeof EnvoyConfigSchema>;
|
|
17
17
|
export type EnvoyConfig = z.infer<typeof EnvoyConfigSchema>;
|
|
@@ -158,7 +158,7 @@ export const RegistryConfigSchema = z
|
|
|
158
158
|
// // created or must be imported async using `await import(...)`
|
|
159
159
|
// getUpgradeWebSocket: z.custom<GetUpgradeWebSocket>().optional(),
|
|
160
160
|
|
|
161
|
-
// MARK:
|
|
161
|
+
// MARK: Node Configuration
|
|
162
162
|
/**
|
|
163
163
|
* Endpoint to connect to for Rivet Engine.
|
|
164
164
|
*
|
|
@@ -251,14 +251,14 @@ export const RegistryConfigSchema = z
|
|
|
251
251
|
.default(() => getRivetRunEngineVersion() ?? VERSION),
|
|
252
252
|
/**
|
|
253
253
|
* Starts the first-party Services actor host when RivetKit manages
|
|
254
|
-
* a local engine.
|
|
255
|
-
*
|
|
254
|
+
* a local engine. Disabled by default. Set RIVET_RUN_SERVICES=1
|
|
255
|
+
* or startServices: true to enable it.
|
|
256
256
|
*/
|
|
257
257
|
startServices: z.boolean().optional(),
|
|
258
258
|
/**
|
|
259
259
|
* @experimental
|
|
260
260
|
*
|
|
261
|
-
* Automatically configure serverless
|
|
261
|
+
* Automatically configure serverless nodes in the engine.
|
|
262
262
|
*/
|
|
263
263
|
configurePool: ConfigurePoolSchema.optional(),
|
|
264
264
|
|
|
@@ -266,7 +266,7 @@ export const RegistryConfigSchema = z
|
|
|
266
266
|
serverless: ServerlessConfigSchema.optional().default(() =>
|
|
267
267
|
ServerlessConfigSchema.parse({}),
|
|
268
268
|
),
|
|
269
|
-
|
|
269
|
+
node: EnvoyConfigSchema.optional().default(() =>
|
|
270
270
|
EnvoyConfigSchema.parse({}),
|
|
271
271
|
),
|
|
272
272
|
|
|
@@ -274,9 +274,9 @@ export const RegistryConfigSchema = z
|
|
|
274
274
|
/**
|
|
275
275
|
* Graceful shutdown configuration for SIGINT/SIGTERM.
|
|
276
276
|
*
|
|
277
|
-
* When a persistent
|
|
277
|
+
* When a persistent node is running (Mode A, started via `registry.start()`),
|
|
278
278
|
* rivetkit installs Node SIGINT/SIGTERM handlers that call into core's
|
|
279
|
-
* `shutdown()` and wait up to `gracePeriodMs` for the
|
|
279
|
+
* `shutdown()` and wait up to `gracePeriodMs` for the node to drain
|
|
280
280
|
* before re-raising the signal to let Node exit via its default path.
|
|
281
281
|
*
|
|
282
282
|
* Handlers are NOT installed when `handler(request)` is used alone
|
|
@@ -289,9 +289,11 @@ export const RegistryConfigSchema = z
|
|
|
289
289
|
/**
|
|
290
290
|
* Wait this many milliseconds for the serve promise to resolve
|
|
291
291
|
* after calling `CoreRegistry::shutdown()`. Defaults to the
|
|
292
|
-
* engine-provided actor stop threshold once the
|
|
292
|
+
* engine-provided actor stop threshold once the node connects. A
|
|
293
|
+
* signal-driven shutdown of a managed local development engine waits
|
|
294
|
+
* one second by default so a file watcher can restart promptly.
|
|
293
295
|
*
|
|
294
|
-
*
|
|
296
|
+
* Set a longer period when a complete graceful node drain is required.
|
|
295
297
|
*/
|
|
296
298
|
gracePeriodMs: z.number().int().min(1_000).optional(),
|
|
297
299
|
/**
|
|
@@ -348,12 +350,12 @@ export const RegistryConfigSchema = z
|
|
|
348
350
|
});
|
|
349
351
|
}
|
|
350
352
|
|
|
351
|
-
//
|
|
352
|
-
if (config.configurePool
|
|
353
|
+
// Serverless pool configuration is disabled for v3.
|
|
354
|
+
if (config.configurePool) {
|
|
353
355
|
ctx.addIssue({
|
|
354
356
|
code: "custom",
|
|
355
|
-
message:
|
|
356
|
-
|
|
357
|
+
message: "serverless is disabled in this version",
|
|
358
|
+
path: ["configurePool"],
|
|
357
359
|
});
|
|
358
360
|
}
|
|
359
361
|
|
|
@@ -366,13 +368,7 @@ export const RegistryConfigSchema = z
|
|
|
366
368
|
? localEngineEndpoint
|
|
367
369
|
: (parsedEndpoint?.endpoint ??
|
|
368
370
|
(isDevEnv ? localEngineEndpoint : undefined));
|
|
369
|
-
|
|
370
|
-
// follows the same local-endpoint decision that causes core to manage the
|
|
371
|
-
// Engine, while explicit config and RIVET_RUN_SERVICES take precedence.
|
|
372
|
-
const startServices =
|
|
373
|
-
config.startServices ??
|
|
374
|
-
getRivetRunServices() ??
|
|
375
|
-
Boolean(endpoint && isLocalEngineEndpoint(endpoint));
|
|
371
|
+
const startServices = config.startServices ?? getRivetRunServices();
|
|
376
372
|
const validateServerlessEndpoint = Boolean(
|
|
377
373
|
config.startEngine || parsedEndpoint,
|
|
378
374
|
);
|
|
@@ -422,6 +418,7 @@ export const RegistryConfigSchema = z
|
|
|
422
418
|
...config,
|
|
423
419
|
sqlite,
|
|
424
420
|
endpoint,
|
|
421
|
+
engineSpawn: !parsedEndpoint && Boolean(endpoint),
|
|
425
422
|
startServices,
|
|
426
423
|
namespace,
|
|
427
424
|
token,
|
|
@@ -468,10 +465,10 @@ export function buildActorNames(
|
|
|
468
465
|
|
|
469
466
|
export const DocConfigurePoolSchema = z
|
|
470
467
|
.object({
|
|
471
|
-
name: z.string().optional().describe("Name of the
|
|
468
|
+
name: z.string().optional().describe("Name of the node pool."),
|
|
472
469
|
url: z
|
|
473
470
|
.string()
|
|
474
|
-
.describe("URL of the serverless platform to configure
|
|
471
|
+
.describe("URL of the serverless platform to configure nodes."),
|
|
475
472
|
headers: z
|
|
476
473
|
.record(z.string(), z.string())
|
|
477
474
|
.optional()
|
|
@@ -504,7 +501,7 @@ export const DocConfigurePoolSchema = z
|
|
|
504
501
|
.boolean()
|
|
505
502
|
.optional()
|
|
506
503
|
.describe(
|
|
507
|
-
"Drain
|
|
504
|
+
"Drain nodes when a new version is deployed. Defaults to true.",
|
|
508
505
|
),
|
|
509
506
|
})
|
|
510
507
|
.optional();
|
|
@@ -547,17 +544,17 @@ export const DocEnvoyConfigSchema = z
|
|
|
547
544
|
poolName: z
|
|
548
545
|
.string()
|
|
549
546
|
.optional()
|
|
550
|
-
.describe("Name of this
|
|
551
|
-
|
|
547
|
+
.describe("Name of this node pool. Default: 'default'"),
|
|
548
|
+
nodeKey: z
|
|
552
549
|
.string()
|
|
553
550
|
.optional()
|
|
554
|
-
.describe("Deprecated. Authentication key for the
|
|
551
|
+
.describe("Deprecated. Authentication key for the node."),
|
|
555
552
|
version: z
|
|
556
553
|
.number()
|
|
557
554
|
.optional()
|
|
558
|
-
.describe("Version number of this
|
|
555
|
+
.describe("Version number of this node. Default: 1"),
|
|
559
556
|
})
|
|
560
|
-
.describe("Configuration for
|
|
557
|
+
.describe("Configuration for node mode.");
|
|
561
558
|
|
|
562
559
|
export const DocSqliteConfigSchema = z
|
|
563
560
|
.object({
|
|
@@ -658,12 +655,12 @@ export const DocRegistryConfigSchema = z
|
|
|
658
655
|
.boolean()
|
|
659
656
|
.optional()
|
|
660
657
|
.describe(
|
|
661
|
-
"Starts Services when RivetKit manages a local Engine.
|
|
658
|
+
"Starts Services when RivetKit manages a local Engine. Disabled by default. Set RIVET_RUN_SERVICES=1 or startServices: true to enable.",
|
|
662
659
|
),
|
|
663
660
|
configurePool: DocConfigurePoolSchema.describe(
|
|
664
|
-
"Automatically configure serverless
|
|
661
|
+
"Automatically configure serverless nodes in the engine.",
|
|
665
662
|
),
|
|
666
663
|
serverless: DocServerlessConfigSchema.optional(),
|
|
667
|
-
|
|
664
|
+
node: DocEnvoyConfigSchema.optional(),
|
|
668
665
|
})
|
|
669
666
|
.describe("RivetKit registry configuration.");
|
package/src/registry/index.ts
CHANGED
|
@@ -30,6 +30,11 @@ type ShutdownSignal = "SIGINT" | "SIGTERM";
|
|
|
30
30
|
|
|
31
31
|
const REGISTRY_READY_TIMEOUT_MS = 30_000;
|
|
32
32
|
|
|
33
|
+
// Serverless is disabled for v3; keep the implementation for a later release.
|
|
34
|
+
function rejectServerless(): void {
|
|
35
|
+
throw new Error("serverless is disabled in this version");
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
function signalExitCode(signal: ShutdownSignal): number {
|
|
34
39
|
switch (signal) {
|
|
35
40
|
case "SIGINT":
|
|
@@ -190,6 +195,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
190
195
|
config: RegistryConfig,
|
|
191
196
|
): Promise<void> | undefined {
|
|
192
197
|
if (!config.configurePool) return undefined;
|
|
198
|
+
rejectServerless();
|
|
193
199
|
|
|
194
200
|
if (!this.#configureServerlessPoolPromise) {
|
|
195
201
|
this.#configureServerlessPoolPromise = configureServerlessPool(
|
|
@@ -215,6 +221,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
215
221
|
* ```
|
|
216
222
|
*/
|
|
217
223
|
public async handler(request: Request): Promise<Response> {
|
|
224
|
+
rejectServerless();
|
|
218
225
|
const config = this.parseConfig();
|
|
219
226
|
this.#printWelcome(config, "serverless");
|
|
220
227
|
|
|
@@ -413,6 +420,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
413
420
|
* ```
|
|
414
421
|
*/
|
|
415
422
|
public serve(): ServerlessHandler {
|
|
423
|
+
rejectServerless();
|
|
416
424
|
return {
|
|
417
425
|
fetch: (request) => this.handler(request),
|
|
418
426
|
};
|
|
@@ -438,6 +446,9 @@ export class Registry<A extends RegistryActors> {
|
|
|
438
446
|
* ```
|
|
439
447
|
*/
|
|
440
448
|
public async listen(opts: RegistryListenOptions = {}): Promise<void> {
|
|
449
|
+
if (!opts.application) {
|
|
450
|
+
rejectServerless();
|
|
451
|
+
}
|
|
441
452
|
const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3000;
|
|
442
453
|
const publicDir = opts.publicDir ?? getRivetkitPublicDir();
|
|
443
454
|
const config = this.parseConfig();
|
|
@@ -554,6 +565,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
554
565
|
* Returns serverless metadata suitable for mounting in a user-owned router.
|
|
555
566
|
*/
|
|
556
567
|
async #metadataRoute(): Promise<Response> {
|
|
568
|
+
rejectServerless();
|
|
557
569
|
const configured = await this.#activeConfiguredRegistry();
|
|
558
570
|
if (!configured) {
|
|
559
571
|
return new Response("registry not started\n", {
|
|
@@ -626,7 +638,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
626
638
|
*/
|
|
627
639
|
#startEnvoy(config: RegistryConfig, printWelcome: boolean) {
|
|
628
640
|
if (!this.#runtimeServePromise) {
|
|
629
|
-
const configuredEnvoyVersion = this.#config.
|
|
641
|
+
const configuredEnvoyVersion = this.#config.node?.version;
|
|
630
642
|
const envoyVersionSource =
|
|
631
643
|
configuredEnvoyVersion !== undefined
|
|
632
644
|
? "config"
|
|
@@ -637,7 +649,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
637
649
|
logger().info({
|
|
638
650
|
msg: "starting rivetkit envoy",
|
|
639
651
|
rivetkitVersion: VERSION,
|
|
640
|
-
envoyVersion: config.
|
|
652
|
+
envoyVersion: config.node.version,
|
|
641
653
|
envoyVersionSource,
|
|
642
654
|
});
|
|
643
655
|
|
|
@@ -646,8 +658,8 @@ export class Registry<A extends RegistryActors> {
|
|
|
646
658
|
getNodeEnv() === "production"
|
|
647
659
|
) {
|
|
648
660
|
logger().error({
|
|
649
|
-
msg: "
|
|
650
|
-
envoyVersion: config.
|
|
661
|
+
msg: "node version defaulted because neither config.node.version nor RIVET_NODE_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
|
|
662
|
+
envoyVersion: config.node.version,
|
|
651
663
|
envoyVersionSource,
|
|
652
664
|
});
|
|
653
665
|
}
|
|
@@ -666,7 +678,13 @@ export class Registry<A extends RegistryActors> {
|
|
|
666
678
|
// rejection unhandled. Downstream awaits (e.g. #runShutdown's
|
|
667
679
|
// Promise.race) attach their own catches and still observe
|
|
668
680
|
// resolution via the race.
|
|
669
|
-
logger().
|
|
681
|
+
logger().error({ error }, "runtime registry serve errored");
|
|
682
|
+
if (
|
|
683
|
+
typeof process !== "undefined" &&
|
|
684
|
+
typeof process.exit === "function"
|
|
685
|
+
) {
|
|
686
|
+
process.exit(1);
|
|
687
|
+
}
|
|
670
688
|
});
|
|
671
689
|
// Install signal handlers once an envoy lifecycle has begun. Only
|
|
672
690
|
// Mode A ever reaches here. Mode B (handler(request)) intentionally
|
|
@@ -714,7 +732,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
714
732
|
finishShutdownSignal(signal);
|
|
715
733
|
return;
|
|
716
734
|
}
|
|
717
|
-
this.#shutdownInFlight = this.#drain(config)
|
|
735
|
+
this.#shutdownInFlight = this.#drain(config, true)
|
|
718
736
|
.catch((err) => {
|
|
719
737
|
logger().warn({ err }, "shutdown error");
|
|
720
738
|
})
|
|
@@ -757,18 +775,28 @@ export class Registry<A extends RegistryActors> {
|
|
|
757
775
|
return this.#shutdownInFlight;
|
|
758
776
|
}
|
|
759
777
|
|
|
760
|
-
async #drain(config: RegistryConfig): Promise<void> {
|
|
778
|
+
async #drain(config: RegistryConfig, signalDriven = false): Promise<void> {
|
|
761
779
|
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
762
780
|
const modeBPromise = this.#runtimeServerlessPromise;
|
|
763
781
|
const runtimes = new Set<CoreRuntime>();
|
|
764
782
|
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
(
|
|
768
|
-
|
|
783
|
+
const localDevSignal =
|
|
784
|
+
signalDriven &&
|
|
785
|
+
getNodeEnv() !== "production" &&
|
|
786
|
+
config.engineSpawn &&
|
|
787
|
+
config.endpoint !== undefined &&
|
|
788
|
+
isLocalEngineEndpoint(config.endpoint);
|
|
789
|
+
let gracePeriodMs = config.shutdown?.gracePeriodMs;
|
|
790
|
+
if (gracePeriodMs === undefined) {
|
|
791
|
+
gracePeriodMs = localDevSignal
|
|
792
|
+
? 1_000
|
|
793
|
+
: ((await this.#actorStopThresholdMs(
|
|
794
|
+
modeAPromise ?? modeBPromise,
|
|
795
|
+
)) ?? 30 * 60 * 1000);
|
|
796
|
+
}
|
|
769
797
|
// Race the entire drain sequence (both modes + serve promise) against
|
|
770
|
-
// a single grace ceiling.
|
|
771
|
-
//
|
|
798
|
+
// a single grace ceiling. Local dev signal shutdowns allow the watcher
|
|
799
|
+
// to restart promptly; other shutdowns use the engine's actor stop threshold.
|
|
772
800
|
const drain = async () => {
|
|
773
801
|
// Shut down every live `CoreRegistry` we know about. Mode A
|
|
774
802
|
// (`start()`) and Mode B (`handler()`) each build a separate
|
|
@@ -887,12 +915,16 @@ export class Registry<A extends RegistryActors> {
|
|
|
887
915
|
);
|
|
888
916
|
}
|
|
889
917
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
918
|
+
try {
|
|
919
|
+
if (getRivetkitRuntimeMode() === "serverless") {
|
|
920
|
+
return Promise.reject(
|
|
921
|
+
new Error(
|
|
922
|
+
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request",
|
|
923
|
+
),
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
} catch (error) {
|
|
927
|
+
return Promise.reject(error);
|
|
896
928
|
}
|
|
897
929
|
|
|
898
930
|
const config = this.parseConfig();
|
|
@@ -481,8 +481,9 @@ export class NapiCoreRuntime implements CoreRuntime {
|
|
|
481
481
|
onCancellationTokenCancelled(
|
|
482
482
|
token: CancellationTokenHandle,
|
|
483
483
|
callback: (...args: unknown[]) => unknown,
|
|
484
|
-
): void {
|
|
485
|
-
asNativeCancellationToken(token).onCancelled(callback);
|
|
484
|
+
): () => void {
|
|
485
|
+
const listener = asNativeCancellationToken(token).onCancelled(callback);
|
|
486
|
+
return () => listener.release();
|
|
486
487
|
}
|
|
487
488
|
|
|
488
489
|
actorState(ctx: ActorContextHandle): Buffer {
|