rivetkit 0.0.0-sqlite-sync-3-0-1-final.5663d2f → 0.0.0-sqlite-sync-3-0-6-final.cf8679c
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 +103 -27
- package/dist/browser/client.js +2 -2
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-DGU2H5IJ.cjs → chunk-275ZGRSG.cjs} +3 -3
- package/dist/tsup/{chunk-DGU2H5IJ.cjs.map → chunk-275ZGRSG.cjs.map} +1 -1
- package/dist/tsup/{chunk-X567WA3N.cjs → chunk-E54YPM4V.cjs} +10 -10
- package/dist/tsup/{chunk-X567WA3N.cjs.map → chunk-E54YPM4V.cjs.map} +1 -1
- package/dist/tsup/{chunk-6UDO6UYM.cjs → chunk-I26AW6BG.cjs} +2 -2
- package/dist/tsup/{chunk-6UDO6UYM.cjs.map → chunk-I26AW6BG.cjs.map} +1 -1
- package/dist/tsup/{chunk-C2NON6V4.cjs → chunk-JHHUCWBC.cjs} +7 -7
- package/dist/tsup/{chunk-C2NON6V4.cjs.map → chunk-JHHUCWBC.cjs.map} +1 -1
- package/dist/tsup/{chunk-XLD6TRSE.cjs → chunk-LYXPQB6H.cjs} +3 -3
- package/dist/tsup/{chunk-XLD6TRSE.cjs.map → chunk-LYXPQB6H.cjs.map} +1 -1
- package/dist/tsup/{chunk-DU7V4SDK.js → chunk-M72ZKQ7R.js} +2 -2
- package/dist/tsup/{chunk-DU7V4SDK.js.map → chunk-M72ZKQ7R.js.map} +1 -1
- package/dist/tsup/{chunk-3ZKCK6NL.js → chunk-ME74LHJM.js} +7 -7
- package/dist/tsup/chunk-ME74LHJM.js.map +1 -0
- package/dist/tsup/{chunk-UXDASKP6.js → chunk-PBIQPYE5.js} +12 -13
- package/dist/tsup/chunk-PBIQPYE5.js.map +1 -0
- package/dist/tsup/{chunk-TTMWSZZA.js → chunk-R4QCQBB4.js} +2 -2
- package/dist/tsup/{chunk-GAFMEUAL.js → chunk-RJ7WDGOJ.js} +3 -3
- package/dist/tsup/{chunk-YJ2X5STT.cjs → chunk-SJJWJU26.cjs} +145 -145
- package/dist/tsup/chunk-SJJWJU26.cjs.map +1 -0
- package/dist/tsup/{chunk-SEKTNJU6.js → chunk-SSMFNH4N.js} +4 -4
- package/dist/tsup/{chunk-EKERHPCE.cjs → chunk-TKCX6KNZ.cjs} +4 -4
- package/dist/tsup/{chunk-EKERHPCE.cjs.map → chunk-TKCX6KNZ.cjs.map} +1 -1
- package/dist/tsup/{chunk-G26OT2Q6.cjs → chunk-TVBQQXQE.cjs} +3 -3
- package/dist/tsup/{chunk-G26OT2Q6.cjs.map → chunk-TVBQQXQE.cjs.map} +1 -1
- package/dist/tsup/{chunk-YNAEH775.js → chunk-VXVJHTW6.js} +2 -2
- package/dist/tsup/{chunk-MT4SROQM.js → chunk-XATHAIZX.js} +2 -2
- package/dist/tsup/{chunk-T7DJZSPH.js → chunk-Y5TV6V5Z.js} +2 -2
- package/dist/tsup/{chunk-SSF2XC33.cjs → chunk-YWWDUC6D.cjs} +12 -13
- package/dist/tsup/chunk-YWWDUC6D.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +4 -4
- 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-RMLak20L.d.cts → config-5K0rzjv1.d.cts} +57 -25
- package/dist/tsup/{config-BfG1qpYz.d.ts → config-Df5jOcde.d.cts} +50 -8
- package/dist/tsup/{config-BfG1qpYz.d.cts → config-Df5jOcde.d.ts} +50 -8
- package/dist/tsup/{config-CASGH-5t.d.ts → config-DsAjIyfZ.d.ts} +57 -25
- package/dist/tsup/{context-C1tMYvV-.d.ts → context-B19Rx5Zg.d.cts} +5 -2
- package/dist/tsup/{context-CxNE2KvK.d.cts → context-BEh8x4jn.d.ts} +5 -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.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/dynamic/mod.js +1 -1
- 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.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +255 -135
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +6 -4
- package/dist/tsup/mod.d.ts +6 -4
- package/dist/tsup/mod.js +152 -32
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +4 -4
- 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 +13 -10
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +8 -5
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +9 -9
- package/src/actor/config.ts +41 -29
- package/src/actor/contexts/index.ts +2 -0
- package/src/actor/definition.ts +33 -1
- package/src/actor/schema.ts +4 -0
- package/src/client/actor-common.ts +4 -0
- package/src/client/actor-conn.ts +2 -0
- package/src/client/actor-handle.ts +2 -0
- package/src/client/config.ts +1 -1
- package/src/client/queue.ts +2 -0
- package/src/common/database/config.ts +50 -7
- package/src/db/mod.ts +1 -0
- package/src/registry/index.ts +142 -1
- package/src/registry/napi-runtime.ts +15 -4
- package/src/registry/native.ts +4 -11
- package/src/registry/runtime.ts +6 -8
- package/src/registry/wasm-runtime.ts +0 -14
- package/src/workflow/context.ts +3 -0
- package/dist/tsup/chunk-3ZKCK6NL.js.map +0 -1
- package/dist/tsup/chunk-SSF2XC33.cjs.map +0 -1
- package/dist/tsup/chunk-UXDASKP6.js.map +0 -1
- package/dist/tsup/chunk-YJ2X5STT.cjs.map +0 -1
- package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +0 -848
- /package/dist/tsup/{chunk-TTMWSZZA.js.map → chunk-R4QCQBB4.js.map} +0 -0
- /package/dist/tsup/{chunk-GAFMEUAL.js.map → chunk-RJ7WDGOJ.js.map} +0 -0
- /package/dist/tsup/{chunk-SEKTNJU6.js.map → chunk-SSMFNH4N.js.map} +0 -0
- /package/dist/tsup/{chunk-YNAEH775.js.map → chunk-VXVJHTW6.js.map} +0 -0
- /package/dist/tsup/{chunk-MT4SROQM.js.map → chunk-XATHAIZX.js.map} +0 -0
- /package/dist/tsup/{chunk-T7DJZSPH.js.map → chunk-Y5TV6V5Z.js.map} +0 -0
package/src/actor/definition.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type ActorConfig,
|
|
11
11
|
type ActorConfigInput,
|
|
12
12
|
ActorConfigSchema,
|
|
13
|
+
getRunInspectorKind,
|
|
13
14
|
} from "./config";
|
|
14
15
|
import { loggerWithoutContext } from "./log";
|
|
15
16
|
import type { EventSchemaConfig, QueueSchemaConfig } from "./schema";
|
|
@@ -34,12 +35,42 @@ function warnDeprecatedOptionKeys(options: unknown) {
|
|
|
34
35
|
if (opts[key] !== undefined && !warnedDeprecatedOptionKeys.has(key)) {
|
|
35
36
|
warnedDeprecatedOptionKeys.add(key);
|
|
36
37
|
loggerWithoutContext().warn({
|
|
37
|
-
msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in
|
|
38
|
+
msg: `actor option \`${key}\` is deprecated and is now ignored. ${detail} Will be removed in 3.2.0.`,
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
let warnedDeprecatedRun = false;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Warns once per process when `run` is a plain function. `run: workflow(...)`
|
|
48
|
+
* is the supported way to use `run` and does not warn.
|
|
49
|
+
*/
|
|
50
|
+
function warnDeprecatedRun(input: unknown) {
|
|
51
|
+
if (warnedDeprecatedRun || !input || typeof input !== "object") return;
|
|
52
|
+
|
|
53
|
+
const run = (input as { run?: unknown }).run;
|
|
54
|
+
if (run === undefined) return;
|
|
55
|
+
|
|
56
|
+
const runFunction =
|
|
57
|
+
typeof run === "object" && run !== null
|
|
58
|
+
? (run as { run?: unknown }).run
|
|
59
|
+
: run;
|
|
60
|
+
if (
|
|
61
|
+
typeof runFunction === "function" &&
|
|
62
|
+
getRunInspectorKind(runFunction as (...args: any[]) => any) ===
|
|
63
|
+
"workflow"
|
|
64
|
+
) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
warnedDeprecatedRun = true;
|
|
69
|
+
loggerWithoutContext().warn({
|
|
70
|
+
msg: "actor option `run` with a plain function was deprecated in 3.0 and will be removed in a future version. Start background work from `onWake` with `c.keepAwake` and track it in `c.vars`. `run: workflow(...)` is not deprecated. See https://rivet.dev/actors/docs/deprecated/run",
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
43
74
|
export interface BaseActorDefinition<
|
|
44
75
|
S,
|
|
45
76
|
CP,
|
|
@@ -200,6 +231,7 @@ export function actor<
|
|
|
200
231
|
warnDeprecatedOptionKeys(
|
|
201
232
|
(input as { options?: unknown } | undefined)?.options,
|
|
202
233
|
);
|
|
234
|
+
warnDeprecatedRun(input);
|
|
203
235
|
const config = ActorConfigSchema.parse(input) as ActorConfig<
|
|
204
236
|
TState,
|
|
205
237
|
TConnParams,
|
package/src/actor/schema.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface EventTypeToken<T, TContext = any> {
|
|
|
14
14
|
export interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
|
|
15
15
|
readonly _queueMessage?: TMessage;
|
|
16
16
|
readonly _queueComplete?: TComplete;
|
|
17
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
17
18
|
readonly canPublish?: SchemaHook<TContext>;
|
|
18
19
|
readonly message?: PrimitiveSchema;
|
|
19
20
|
readonly complete?: PrimitiveSchema;
|
|
@@ -28,6 +29,7 @@ interface EventOptions<TContext = any> {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
interface QueueOptions<TContext = any> {
|
|
32
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
31
33
|
canPublish?: SchemaHook<TContext>;
|
|
32
34
|
message?: PrimitiveSchema;
|
|
33
35
|
complete?: PrimitiveSchema;
|
|
@@ -39,6 +41,7 @@ export function event<T, TContext = any>(
|
|
|
39
41
|
return (options ?? {}) as EventTypeToken<T, TContext>;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
42
45
|
export function queue<TMessage, TComplete = never, TContext = any>(
|
|
43
46
|
options?: QueueOptions<TContext>,
|
|
44
47
|
): QueueTypeToken<TMessage, TComplete, TContext> {
|
|
@@ -55,6 +58,7 @@ export interface EventSchemaDefinition<TContext = any> {
|
|
|
55
58
|
export interface QueueSchemaDefinition<TContext = any> {
|
|
56
59
|
message: PrimitiveSchema;
|
|
57
60
|
complete?: PrimitiveSchema;
|
|
61
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
58
62
|
canPublish?: SchemaHook<TContext>;
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -92,21 +92,25 @@ export type ActorDefinitionActions<AD extends AnyActorDefinition> =
|
|
|
92
92
|
: ActorActionMap<ActionsOf<AD>>;
|
|
93
93
|
|
|
94
94
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
95
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
95
96
|
<K extends keyof TQueues & string>(
|
|
96
97
|
name: K,
|
|
97
98
|
body: InferSchemaMap<TQueues>[K],
|
|
98
99
|
options: QueueSendWaitOptions,
|
|
99
100
|
): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
|
|
101
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
100
102
|
<K extends keyof TQueues & string>(
|
|
101
103
|
name: K,
|
|
102
104
|
body: InferSchemaMap<TQueues>[K],
|
|
103
105
|
options?: QueueSendNoWaitOptions,
|
|
104
106
|
): Promise<void>;
|
|
107
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
105
108
|
(
|
|
106
109
|
name: keyof TQueues extends never ? string : never,
|
|
107
110
|
body: unknown,
|
|
108
111
|
options: QueueSendWaitOptions,
|
|
109
112
|
): Promise<QueueSendResult>;
|
|
113
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
110
114
|
(
|
|
111
115
|
name: keyof TQueues extends never ? string : never,
|
|
112
116
|
body: unknown,
|
package/src/client/actor-conn.ts
CHANGED
|
@@ -304,11 +304,13 @@ export class ActorConnRaw {
|
|
|
304
304
|
);
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
307
308
|
send(
|
|
308
309
|
name: string,
|
|
309
310
|
body: unknown,
|
|
310
311
|
options: QueueSendWaitOptions,
|
|
311
312
|
): Promise<QueueSendResult>;
|
|
313
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
312
314
|
send(
|
|
313
315
|
name: string,
|
|
314
316
|
body: unknown,
|
|
@@ -138,11 +138,13 @@ export class ActorHandleRaw {
|
|
|
138
138
|
return this.#params;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
141
142
|
send(
|
|
142
143
|
name: string,
|
|
143
144
|
body: unknown,
|
|
144
145
|
options: QueueSendWaitOptions,
|
|
145
146
|
): Promise<QueueSendResult>;
|
|
147
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
146
148
|
send(
|
|
147
149
|
name: string,
|
|
148
150
|
body: unknown,
|
package/src/client/config.ts
CHANGED
|
@@ -42,7 +42,7 @@ export const ClientConfigSchemaBase = z.object({
|
|
|
42
42
|
hasWarnedMissingEndpoint = true;
|
|
43
43
|
console.warn(
|
|
44
44
|
`[rivetkit] No endpoint provided to client. Defaulting to ${DEFAULT_ENDPOINT}. ` +
|
|
45
|
-
`Starting in
|
|
45
|
+
`Starting in 3.2.0, an explicit endpoint will be required. ` +
|
|
46
46
|
`Pass an endpoint to createClient() or createRivetKit(), ` +
|
|
47
47
|
`or set the RIVET_ENDPOINT environment variable.`,
|
|
48
48
|
);
|
package/src/client/queue.ts
CHANGED
|
@@ -20,11 +20,13 @@ import { bufferToArrayBuffer } from "@/utils";
|
|
|
20
20
|
import { sendHttpRequest } from "./utils";
|
|
21
21
|
|
|
22
22
|
export interface QueueSender {
|
|
23
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
23
24
|
send(
|
|
24
25
|
name: string,
|
|
25
26
|
body: unknown,
|
|
26
27
|
options: QueueSendWaitOptions,
|
|
27
28
|
): Promise<QueueSendResult>;
|
|
29
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
28
30
|
send(
|
|
29
31
|
name: string,
|
|
30
32
|
body: unknown,
|
|
@@ -52,13 +52,16 @@ export interface SqliteTransactionOptions {
|
|
|
52
52
|
* to change without notice.
|
|
53
53
|
*/
|
|
54
54
|
export interface SqliteProfilingOptions {
|
|
55
|
-
/** Exact SQL
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
/** Exact SQL filter. Union with filterQueryFingerprints; both empty means all queries. */
|
|
56
|
+
filterQueries?: string[];
|
|
57
|
+
/** Fingerprint filter, including transaction fingerprints. Filters metrics, not diagnostic logs. */
|
|
58
|
+
filterQueryFingerprints?: string[];
|
|
59
|
+
/** Metric defaults apply even when omitted. Disabled metrics allocate no series. */
|
|
60
|
+
metrics?: SqliteProfilingMetricsOptions;
|
|
61
|
+
/** Duration buckets in seconds. Default [0.01, 0.1, 1]. Positive, finite, strictly increasing.
|
|
62
|
+
* All actors in a process enabling the duration histogram must use identical buckets. */
|
|
63
|
+
durationHistogramBucketsSeconds?: number[];
|
|
64
|
+
/** Maximum distinct statement fingerprints per process. Default: 512. */
|
|
62
65
|
maxTrackedStatementFingerprints?: number;
|
|
63
66
|
maxTrackedTransactionFingerprints?: number;
|
|
64
67
|
maxPrometheusSeries?: number;
|
|
@@ -71,6 +74,46 @@ export interface SqliteProfilingOptions {
|
|
|
71
74
|
diagnosticEventQueueCapacity?: number;
|
|
72
75
|
}
|
|
73
76
|
|
|
77
|
+
/** SQLite profiling metrics. Physical-request metrics and gauges have no query labels. */
|
|
78
|
+
export interface SqliteProfilingMetricsOptions {
|
|
79
|
+
/** Execution count and cumulative seconds. Uses histogram count/sum when enabled, otherwise counters. Default: true. */
|
|
80
|
+
duration?: boolean;
|
|
81
|
+
/** Execution duration histogram. Only applies when duration is enabled. Default: true. */
|
|
82
|
+
durationHistogram?: boolean;
|
|
83
|
+
/** Outcome counters, including success and errors. Default: true. */
|
|
84
|
+
outcomes?: boolean;
|
|
85
|
+
/** Per-query timing phase histograms. Default: false. */
|
|
86
|
+
phaseDurationHistogram?: boolean;
|
|
87
|
+
/** Storage round trips per operation histogram. Default: false. */
|
|
88
|
+
getPagesRoundTripsHistogram?: boolean;
|
|
89
|
+
/** Statements per transaction histogram. Default: false. */
|
|
90
|
+
transactionStatementCountHistogram?: boolean;
|
|
91
|
+
/** Per-query pages returned from storage, including returned prefetch pages. Default: true. */
|
|
92
|
+
pagesFetched?: boolean;
|
|
93
|
+
/** Actor-level page counters by page kind (no query labels). Default: false. */
|
|
94
|
+
localPages?: boolean;
|
|
95
|
+
/** Actor-level byte counters by byte kind (no query labels). Default: false. */
|
|
96
|
+
localBytes?: boolean;
|
|
97
|
+
/** Actor-level physical storage request duration histogram. Default: false. */
|
|
98
|
+
getPagesDurationHistogram?: boolean;
|
|
99
|
+
/** Actor-level pages per storage request histograms, by page kind. Default: false. */
|
|
100
|
+
getPagesPagesHistogram?: boolean;
|
|
101
|
+
/** Actor-level storage response byte histogram. Default: false. */
|
|
102
|
+
getPagesResponseBytesHistogram?: boolean;
|
|
103
|
+
/** Actor-level missing response page counter. Default: false. */
|
|
104
|
+
getPagesMissingPages?: boolean;
|
|
105
|
+
/** Queued SQLite work, aggregated by actor name. Default: true. */
|
|
106
|
+
workerQueueDepth?: boolean;
|
|
107
|
+
/** Executing SQLite work, aggregated by actor name. Default: true. */
|
|
108
|
+
workerInflight?: boolean;
|
|
109
|
+
/** Transaction waiters, aggregated by actor name. Default: true. */
|
|
110
|
+
coordinatorQueueDepth?: boolean;
|
|
111
|
+
/** Counts observations exceeding fingerprint or series limits. Default: true. */
|
|
112
|
+
fingerprintOverflow?: boolean;
|
|
113
|
+
/** Counts diagnostic events dropped by rate limits or backpressure. Default: true. */
|
|
114
|
+
eventDropped?: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
74
117
|
export interface SqliteNativeMetrics {
|
|
75
118
|
requestBuildNs: number;
|
|
76
119
|
serializeNs: number;
|
package/src/db/mod.ts
CHANGED
package/src/registry/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { logger } from "./log";
|
|
|
20
20
|
import { buildConfiguredRegistry } from "./native";
|
|
21
21
|
import { convertNativeHttpResponse } from "./native-http";
|
|
22
22
|
import type {
|
|
23
|
+
CancellationTokenHandle,
|
|
23
24
|
CoreRuntime,
|
|
24
25
|
RuntimeApplicationFetch,
|
|
25
26
|
RuntimeHttpResponseBodyStream,
|
|
@@ -28,6 +29,8 @@ import type {
|
|
|
28
29
|
|
|
29
30
|
type ShutdownSignal = "SIGINT" | "SIGTERM";
|
|
30
31
|
|
|
32
|
+
type ConfiguredRegistry = Awaited<ReturnType<typeof buildConfiguredRegistry>>;
|
|
33
|
+
|
|
31
34
|
const REGISTRY_READY_TIMEOUT_MS = 30_000;
|
|
32
35
|
// A managed Engine restart can wait for the old process to release storage and
|
|
33
36
|
// for its worker lease to expire before the replacement can register.
|
|
@@ -36,6 +39,9 @@ const LOCAL_ENGINE_READY_TIMEOUT_MS = 60_000;
|
|
|
36
39
|
// reports. Leave time to close the node connection after that, while staying
|
|
37
40
|
// below the five-second force-kill ceiling used by tsx watch.
|
|
38
41
|
const LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS = 4_000;
|
|
42
|
+
// Matches the engine's default `pegboard.actor_stop_threshold`. Used only when the
|
|
43
|
+
// node has not received the engine's advertised threshold before shutdown begins.
|
|
44
|
+
const DEFAULT_ACTOR_STOP_THRESHOLD_MS = 30_000;
|
|
39
45
|
|
|
40
46
|
// Serverless is disabled for v3; keep the implementation for a later release.
|
|
41
47
|
function rejectServerless(): void {
|
|
@@ -176,6 +182,11 @@ export class Registry<A extends RegistryActors> {
|
|
|
176
182
|
#shutdownInstalled = false;
|
|
177
183
|
#shutdownInFlight: Promise<void> | null = null;
|
|
178
184
|
#signalHandlers: Partial<Record<ShutdownSignal, () => void>> = {};
|
|
185
|
+
#envoyConfiguredRegistry?: ConfiguredRegistry;
|
|
186
|
+
#activeActorCountListeners = new Set<(count: number) => void>();
|
|
187
|
+
#activeActorCountToken?: CancellationTokenHandle;
|
|
188
|
+
#lastActiveActorCount?: number;
|
|
189
|
+
#activeActorCountSupported?: boolean;
|
|
179
190
|
|
|
180
191
|
constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>) {
|
|
181
192
|
this.#config = config;
|
|
@@ -674,6 +685,21 @@ export class Registry<A extends RegistryActors> {
|
|
|
674
685
|
const configuredRegistryPromise =
|
|
675
686
|
this.#buildConfiguredRegistry(config);
|
|
676
687
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
688
|
+
configuredRegistryPromise.then(
|
|
689
|
+
(configured) => {
|
|
690
|
+
this.#envoyConfiguredRegistry = configured;
|
|
691
|
+
try {
|
|
692
|
+
this.#syncActiveActorCountSubscription();
|
|
693
|
+
} catch (error) {
|
|
694
|
+
logger().error(
|
|
695
|
+
{ error },
|
|
696
|
+
"failed to subscribe to the active actor count",
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
// The serve lifecycle below reports build failures.
|
|
701
|
+
() => undefined,
|
|
702
|
+
);
|
|
677
703
|
this.#runtimeServeLifecyclePromise = configuredRegistryPromise.then(
|
|
678
704
|
async ({ runtime, registry, serveConfig }) => {
|
|
679
705
|
await runtime.serveRegistry(registry, serveConfig);
|
|
@@ -799,7 +825,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
799
825
|
? LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS
|
|
800
826
|
: ((await this.#actorStopThresholdMs(
|
|
801
827
|
modeAPromise ?? modeBPromise,
|
|
802
|
-
)) ??
|
|
828
|
+
)) ?? DEFAULT_ACTOR_STOP_THRESHOLD_MS);
|
|
803
829
|
}
|
|
804
830
|
// Race the entire drain sequence (both modes + serve promise) against
|
|
805
831
|
// a single grace ceiling. Local dev signal shutdowns allow the watcher
|
|
@@ -1026,6 +1052,121 @@ export class Registry<A extends RegistryActors> {
|
|
|
1026
1052
|
this.#startEnvoy(config, true);
|
|
1027
1053
|
}
|
|
1028
1054
|
|
|
1055
|
+
/**
|
|
1056
|
+
* Returns the number of actors hosted by this process's envoy, which is zero
|
|
1057
|
+
* while it is not serving. Requires the native runtime.
|
|
1058
|
+
*/
|
|
1059
|
+
public activeActorCount(): number {
|
|
1060
|
+
this.#assertActiveActorCountSupported("activeActorCount");
|
|
1061
|
+
const configured = this.#envoyConfiguredRegistry;
|
|
1062
|
+
if (!configured) return 0;
|
|
1063
|
+
const { runtime, registry } = configured;
|
|
1064
|
+
if (!runtime.registryActiveActorCount) {
|
|
1065
|
+
throw new Error(
|
|
1066
|
+
"registry.activeActorCount() is not supported by this runtime",
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
return runtime.registryActiveActorCount(registry);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Calls `callback` with the number of actors hosted by this process's envoy
|
|
1074
|
+
* and again whenever it changes. Rapid changes may coalesce.
|
|
1075
|
+
* Returns a function that unsubscribes. Requires the native runtime.
|
|
1076
|
+
*
|
|
1077
|
+
* @example
|
|
1078
|
+
* ```ts
|
|
1079
|
+
* const unsubscribe = registry.onActiveActorCountChange((count) => {
|
|
1080
|
+
* setTaskProtection(count > 0);
|
|
1081
|
+
* });
|
|
1082
|
+
* ```
|
|
1083
|
+
*/
|
|
1084
|
+
public onActiveActorCountChange(
|
|
1085
|
+
callback: (count: number) => void,
|
|
1086
|
+
): () => void {
|
|
1087
|
+
this.#assertActiveActorCountSupported("onActiveActorCountChange");
|
|
1088
|
+
// Wrap so the same callback can subscribe twice and unsubscribe independently.
|
|
1089
|
+
const listener = (count: number) => callback(count);
|
|
1090
|
+
this.#activeActorCountListeners.add(listener);
|
|
1091
|
+
this.#syncActiveActorCountSubscription();
|
|
1092
|
+
|
|
1093
|
+
// Start late listeners from the stream, not a direct read, which could see a
|
|
1094
|
+
// change the stream coalesced away and never corrects.
|
|
1095
|
+
const lastCount = this.#lastActiveActorCount;
|
|
1096
|
+
if (lastCount !== undefined) {
|
|
1097
|
+
queueMicrotask(() => {
|
|
1098
|
+
if (this.#activeActorCountListeners.has(listener)) {
|
|
1099
|
+
this.#deliverActiveActorCount(listener, lastCount);
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
return () => {
|
|
1105
|
+
this.#activeActorCountListeners.delete(listener);
|
|
1106
|
+
this.#syncActiveActorCountSubscription();
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
#assertActiveActorCountSupported(method: string): void {
|
|
1111
|
+
this.#activeActorCountSupported ??=
|
|
1112
|
+
this.parseConfig().runtime !== "wasm";
|
|
1113
|
+
if (!this.#activeActorCountSupported) {
|
|
1114
|
+
throw new Error(
|
|
1115
|
+
`registry.${method}() requires the native runtime; WebAssembly registries do not host an envoy`,
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/** Holds one native subscription while any listener is registered. */
|
|
1121
|
+
#syncActiveActorCountSubscription(): void {
|
|
1122
|
+
const configured = this.#envoyConfiguredRegistry;
|
|
1123
|
+
if (!configured) return;
|
|
1124
|
+
const { runtime, registry } = configured;
|
|
1125
|
+
const token = this.#activeActorCountToken;
|
|
1126
|
+
|
|
1127
|
+
if (this.#activeActorCountListeners.size === 0) {
|
|
1128
|
+
if (token !== undefined) {
|
|
1129
|
+
this.#activeActorCountToken = undefined;
|
|
1130
|
+
this.#lastActiveActorCount = undefined;
|
|
1131
|
+
runtime.cancelCancellationToken(token);
|
|
1132
|
+
}
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
if (token !== undefined) return;
|
|
1136
|
+
|
|
1137
|
+
if (!runtime.onRegistryActiveActorCountChange) {
|
|
1138
|
+
throw new Error(
|
|
1139
|
+
"active actor count subscriptions are not supported by this runtime",
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
const nextToken = runtime.createCancellationToken();
|
|
1143
|
+
this.#activeActorCountToken = nextToken;
|
|
1144
|
+
runtime.onRegistryActiveActorCountChange(
|
|
1145
|
+
registry,
|
|
1146
|
+
(count) => {
|
|
1147
|
+
// Drop calls still queued from a released subscription.
|
|
1148
|
+
if (this.#activeActorCountToken !== nextToken) return;
|
|
1149
|
+
this.#lastActiveActorCount = count;
|
|
1150
|
+
// Iterate a copy so listeners added by a callback are not called twice.
|
|
1151
|
+
for (const listener of [...this.#activeActorCountListeners]) {
|
|
1152
|
+
this.#deliverActiveActorCount(listener, count);
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
nextToken,
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
#deliverActiveActorCount(
|
|
1160
|
+
listener: (count: number) => void,
|
|
1161
|
+
count: number,
|
|
1162
|
+
): void {
|
|
1163
|
+
try {
|
|
1164
|
+
listener(count);
|
|
1165
|
+
} catch (error) {
|
|
1166
|
+
logger().error({ error }, "active actor count listener threw");
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1029
1170
|
#printWelcome(
|
|
1030
1171
|
config: RegistryConfig,
|
|
1031
1172
|
kind: "serverless" | "serverful",
|
|
@@ -354,6 +354,21 @@ export class NapiCoreRuntime implements CoreRuntime {
|
|
|
354
354
|
);
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
+
registryActiveActorCount(registry: RegistryHandle): number {
|
|
358
|
+
return asNativeRegistry(registry).activeActorCount();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
onRegistryActiveActorCountChange(
|
|
362
|
+
registry: RegistryHandle,
|
|
363
|
+
callback: (count: number) => void,
|
|
364
|
+
cancelToken: CancellationTokenHandle,
|
|
365
|
+
): void {
|
|
366
|
+
asNativeRegistry(registry).onActiveActorCountChange(
|
|
367
|
+
callback,
|
|
368
|
+
asNativeCancellationToken(cancelToken),
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
357
372
|
async registryHealth(
|
|
358
373
|
registry: RegistryHandle,
|
|
359
374
|
): Promise<RuntimeRegistryRouteResponse> {
|
|
@@ -1072,10 +1087,6 @@ export class NapiCoreRuntime implements CoreRuntime {
|
|
|
1072
1087
|
await nativeCtx.sql().close();
|
|
1073
1088
|
}
|
|
1074
1089
|
|
|
1075
|
-
async actorRuntimeSocketProvision(ctx: ActorContextHandle) {
|
|
1076
|
-
return await asNativeActorContext(ctx).provisionActorRuntimeSocket();
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
1090
|
async actorQueueSend(
|
|
1080
1091
|
ctx: ActorContextHandle,
|
|
1081
1092
|
name: string,
|
package/src/registry/native.ts
CHANGED
|
@@ -2888,12 +2888,6 @@ export class ActorContextHandleAdapter {
|
|
|
2888
2888
|
return this.#kv;
|
|
2889
2889
|
}
|
|
2890
2890
|
|
|
2891
|
-
async actorRuntimeSocket(): Promise<{ path: string }> {
|
|
2892
|
-
return await callNative(() =>
|
|
2893
|
-
this.#runtime.actorRuntimeSocketProvision(this.#ctx),
|
|
2894
|
-
);
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
2891
|
get db() {
|
|
2898
2892
|
if (!this.#databaseProvider) {
|
|
2899
2893
|
throw databaseNotConfiguredError();
|
|
@@ -3561,17 +3555,17 @@ export class ActorContextHandleAdapter {
|
|
|
3561
3555
|
// need to keep an actor awake should use `keepAwake(promise)` or
|
|
3562
3556
|
// `waitUntil(promise)` so the native counter machinery in rivetkit-core
|
|
3563
3557
|
// owns the lifecycle.
|
|
3564
|
-
/** @deprecated Use `keepAwake(promise)` or `waitUntil(promise)
|
|
3558
|
+
/** @deprecated `setPreventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
|
|
3565
3559
|
setPreventSleep(_preventSleep: boolean): void {
|
|
3566
3560
|
logger().warn({
|
|
3567
|
-
msg: "setPreventSleep
|
|
3561
|
+
msg: "setPreventSleep was deprecated in 3.0 and will be removed in a future version. It is a no-op; use keepAwake(promise) or waitUntil(promise) instead. See https://rivet.dev/actors/docs/deprecated/prevent-sleep",
|
|
3568
3562
|
});
|
|
3569
3563
|
}
|
|
3570
3564
|
|
|
3571
|
-
/** @deprecated Use `keepAwake(promise)` or `waitUntil(promise)
|
|
3565
|
+
/** @deprecated `preventSleep` was deprecated in 3.0 and will be removed in a future version. It is a no-op that always returns `false`. Use `c.keepAwake(promise)` or `c.waitUntil(promise)`. See https://rivet.dev/actors/docs/deprecated/prevent-sleep */
|
|
3572
3566
|
get preventSleep(): boolean {
|
|
3573
3567
|
logger().warn({
|
|
3574
|
-
msg: "preventSleep
|
|
3568
|
+
msg: "preventSleep was deprecated in 3.0 and will be removed in a future version. It always returns false; use keepAwake(promise) or waitUntil(promise) instead. See https://rivet.dev/actors/docs/deprecated/prevent-sleep",
|
|
3575
3569
|
});
|
|
3576
3570
|
return false;
|
|
3577
3571
|
}
|
|
@@ -4049,7 +4043,6 @@ function buildActorConfig(
|
|
|
4049
4043
|
definition.config.actions,
|
|
4050
4044
|
definition.config.tracing,
|
|
4051
4045
|
),
|
|
4052
|
-
enableActorRuntimeSocket: options.enableActorRuntimeSocket === true,
|
|
4053
4046
|
hasState:
|
|
4054
4047
|
config.state !== undefined ||
|
|
4055
4048
|
typeof config.createState === "function",
|
package/src/registry/runtime.ts
CHANGED
|
@@ -248,10 +248,6 @@ export type RuntimeSqlBindParam =
|
|
|
248
248
|
|
|
249
249
|
export type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
250
250
|
|
|
251
|
-
export interface RuntimeActorRuntimeSocketEndpointInfo {
|
|
252
|
-
path: string;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
251
|
export interface RuntimeSqlQueryResult {
|
|
256
252
|
columns: string[];
|
|
257
253
|
rows: unknown[][];
|
|
@@ -352,7 +348,6 @@ export interface RuntimeActorConfig {
|
|
|
352
348
|
sqliteDeferredCommits?: boolean;
|
|
353
349
|
sqliteProfiling?: SqliteProfilingOptions;
|
|
354
350
|
tracing?: RuntimeActorTracingConfig;
|
|
355
|
-
enableActorRuntimeSocket?: boolean;
|
|
356
351
|
hasState?: boolean;
|
|
357
352
|
canHibernateWebsocket?: boolean;
|
|
358
353
|
stateSaveIntervalMs?: number;
|
|
@@ -520,6 +515,12 @@ export interface CoreRuntime {
|
|
|
520
515
|
registryActorStopThresholdMs?(
|
|
521
516
|
registry: RegistryHandle,
|
|
522
517
|
): Promise<number | undefined>;
|
|
518
|
+
registryActiveActorCount?(registry: RegistryHandle): number;
|
|
519
|
+
onRegistryActiveActorCountChange?(
|
|
520
|
+
registry: RegistryHandle,
|
|
521
|
+
callback: (count: number) => void,
|
|
522
|
+
cancelToken: CancellationTokenHandle,
|
|
523
|
+
): void;
|
|
523
524
|
handleServerlessRequest(
|
|
524
525
|
registry: RegistryHandle,
|
|
525
526
|
req: RuntimeServerlessRequest,
|
|
@@ -806,9 +807,6 @@ export interface CoreRuntime {
|
|
|
806
807
|
actorSqlWhenDurable(ctx: ActorContextHandle, ticket: number): Promise<void>;
|
|
807
808
|
actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void;
|
|
808
809
|
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
809
|
-
actorRuntimeSocketProvision(
|
|
810
|
-
ctx: ActorContextHandle,
|
|
811
|
-
): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
|
|
812
810
|
|
|
813
811
|
actorQueueSend(
|
|
814
812
|
ctx: ActorContextHandle,
|
|
@@ -1058,20 +1058,6 @@ export class WasmCoreRuntime implements CoreRuntime {
|
|
|
1058
1058
|
await callWasm(() => database.close());
|
|
1059
1059
|
}
|
|
1060
1060
|
|
|
1061
|
-
async actorRuntimeSocketProvision(
|
|
1062
|
-
_ctx: ActorContextHandle,
|
|
1063
|
-
): Promise<never> {
|
|
1064
|
-
throw new RivetError(
|
|
1065
|
-
"actor_runtime_socket",
|
|
1066
|
-
"unsupported",
|
|
1067
|
-
"Actor Runtime Socket is only available on Unix native runtimes.",
|
|
1068
|
-
{
|
|
1069
|
-
public: true,
|
|
1070
|
-
metadata: { runtime: "wasm" },
|
|
1071
|
-
},
|
|
1072
|
-
);
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
1061
|
async actorQueueSend(
|
|
1076
1062
|
ctx: ActorContextHandle,
|
|
1077
1063
|
name: string,
|
package/src/workflow/context.ts
CHANGED
|
@@ -361,6 +361,7 @@ export class WorkflowStepContext<
|
|
|
361
361
|
return this.#runCtx.abortSignal;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
/** @deprecated Actor state was deprecated in 3.0 and will be removed in a future version. Store durable data in SQLite (`c.db`) and in-memory data in `c.vars`. See https://rivet.dev/actors/docs/deprecated/state */
|
|
364
365
|
get state(): TState extends never ? never : TState {
|
|
365
366
|
this.#ensureActive("state");
|
|
366
367
|
return this.#runCtx.state as TState extends never ? never : TState;
|
|
@@ -399,6 +400,7 @@ export class WorkflowStepContext<
|
|
|
399
400
|
);
|
|
400
401
|
}
|
|
401
402
|
|
|
403
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
402
404
|
get queue() {
|
|
403
405
|
const self = this;
|
|
404
406
|
function send<K extends keyof TQueues & string>(
|
|
@@ -510,6 +512,7 @@ export class WorkflowContext<
|
|
|
510
512
|
return this.#runCtx.log;
|
|
511
513
|
}
|
|
512
514
|
|
|
515
|
+
/** @deprecated Queues were deprecated in 3.0 and will be removed in a future version. Use actions and store pending work in SQLite (`c.db`). See https://rivet.dev/actors/docs/deprecated/queues */
|
|
513
516
|
get queue() {
|
|
514
517
|
const self = this;
|
|
515
518
|
function next<
|