duroxide 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/index.d.ts +32 -0
- package/index.js +2 -1
- package/lib/duroxide.js +21 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -15,8 +15,10 @@ Node.js/TypeScript SDK for the [Duroxide](https://github.com/affandar/duroxide)
|
|
|
15
15
|
- **Fan-out/fan-in** — run tasks in parallel with `ctx.all()` (supports all task types)
|
|
16
16
|
- **Race conditions** — wait for the first of multiple tasks with `ctx.race()` (supports all task types)
|
|
17
17
|
- **Cooperative cancellation** — activities detect when they're no longer needed via `ctx.isCancelled()`
|
|
18
|
+
- **Activity client access** — activities can start new orchestrations via `ctx.getClient()`
|
|
18
19
|
- **Continue-as-new** — restart orchestrations with fresh history for eternal workflows
|
|
19
20
|
- **Structured tracing** — orchestration and activity logs route through Rust's `tracing` crate
|
|
21
|
+
- **Runtime metrics** — `metricsSnapshot()` for orchestration/activity counters
|
|
20
22
|
- **SQLite & PostgreSQL** — pluggable storage backends
|
|
21
23
|
|
|
22
24
|
## Quick Start
|
|
@@ -146,11 +148,11 @@ RUST_LOG=duroxide::activity=info node app.js # Activity traces only
|
|
|
146
148
|
Requires PostgreSQL (see `.env.example`):
|
|
147
149
|
|
|
148
150
|
```bash
|
|
149
|
-
npm test # e2e tests (
|
|
151
|
+
npm test # e2e tests (25 PG + 1 SQLite smoketest)
|
|
150
152
|
npm run test:races # Race/join composition tests (7 tests)
|
|
151
153
|
npm run test:admin # Admin API tests (14 tests)
|
|
152
154
|
npm run test:scenarios # Scenario tests (6 tests)
|
|
153
|
-
npm run test:all # Everything (
|
|
155
|
+
npm run test:all # Everything (52 tests)
|
|
154
156
|
```
|
|
155
157
|
|
|
156
158
|
## License
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,14 @@ export interface JsRuntimeOptions {
|
|
|
16
16
|
* manager renews locks, which affects cancellation detection speed.
|
|
17
17
|
*/
|
|
18
18
|
workerLockTimeoutMs?: number
|
|
19
|
+
/** Log format: "json", "pretty", or "compact" (default) */
|
|
20
|
+
logFormat?: string
|
|
21
|
+
/** Log level filter: "info", "debug", "warn", "error", etc. */
|
|
22
|
+
logLevel?: string
|
|
23
|
+
/** Service name for identification in logs/metrics */
|
|
24
|
+
serviceName?: string
|
|
25
|
+
/** Optional service version */
|
|
26
|
+
serviceVersion?: string
|
|
19
27
|
}
|
|
20
28
|
/** Orchestration status returned to JS. */
|
|
21
29
|
export interface JsOrchestrationStatus {
|
|
@@ -89,6 +97,26 @@ export interface JsInstanceFilter {
|
|
|
89
97
|
completedBefore?: number
|
|
90
98
|
limit?: number
|
|
91
99
|
}
|
|
100
|
+
/** Runtime metrics snapshot returned to JS. */
|
|
101
|
+
export interface JsMetricsSnapshot {
|
|
102
|
+
orchStarts: number
|
|
103
|
+
orchCompletions: number
|
|
104
|
+
orchFailures: number
|
|
105
|
+
orchApplicationErrors: number
|
|
106
|
+
orchInfrastructureErrors: number
|
|
107
|
+
orchConfigurationErrors: number
|
|
108
|
+
orchPoison: number
|
|
109
|
+
activitySuccess: number
|
|
110
|
+
activityAppErrors: number
|
|
111
|
+
activityInfraErrors: number
|
|
112
|
+
activityConfigErrors: number
|
|
113
|
+
activityPoison: number
|
|
114
|
+
orchDispatcherItemsFetched: number
|
|
115
|
+
workerDispatcherItemsFetched: number
|
|
116
|
+
orchContinueAsNew: number
|
|
117
|
+
suborchestrationCalls: number
|
|
118
|
+
providerErrors: number
|
|
119
|
+
}
|
|
92
120
|
/** A single history event returned to JS. */
|
|
93
121
|
export interface JsEvent {
|
|
94
122
|
eventId: number
|
|
@@ -113,6 +141,8 @@ export declare function orchestrationTraceLog(instanceId: string, level: string,
|
|
|
113
141
|
* Returns true if the activity has been cancelled (e.g., due to losing a race/select).
|
|
114
142
|
*/
|
|
115
143
|
export declare function activityIsCancelled(token: string): boolean
|
|
144
|
+
/** Get a Client from an activity context, allowing activities to start new orchestrations. */
|
|
145
|
+
export declare function activityGetClient(token: string): JsClient | null
|
|
116
146
|
/** Wraps duroxide's Client for use from JavaScript. */
|
|
117
147
|
export declare class JsClient {
|
|
118
148
|
constructor(provider: JsSqliteProvider)
|
|
@@ -210,6 +240,8 @@ export declare class JsRuntime {
|
|
|
210
240
|
* This is async and takes &mut self. napi-rs requires async &mut methods to be marked unsafe.
|
|
211
241
|
*/
|
|
212
242
|
start(): Promise<void>
|
|
243
|
+
/** Get a snapshot of runtime metrics. */
|
|
244
|
+
metricsSnapshot(): JsMetricsSnapshot | null
|
|
213
245
|
/**
|
|
214
246
|
* Shutdown the runtime gracefully.
|
|
215
247
|
*
|
package/index.js
CHANGED
|
@@ -310,7 +310,7 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { JsClient, JsPostgresProvider, JsSqliteProvider, JsRuntime, activityTraceLog, orchestrationTraceLog, activityIsCancelled } = nativeBinding
|
|
313
|
+
const { JsClient, JsPostgresProvider, JsSqliteProvider, JsRuntime, activityTraceLog, orchestrationTraceLog, activityIsCancelled, activityGetClient } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.JsClient = JsClient
|
|
316
316
|
module.exports.JsPostgresProvider = JsPostgresProvider
|
|
@@ -319,3 +319,4 @@ module.exports.JsRuntime = JsRuntime
|
|
|
319
319
|
module.exports.activityTraceLog = activityTraceLog
|
|
320
320
|
module.exports.orchestrationTraceLog = orchestrationTraceLog
|
|
321
321
|
module.exports.activityIsCancelled = activityIsCancelled
|
|
322
|
+
module.exports.activityGetClient = activityGetClient
|
package/lib/duroxide.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// Load native bindings from the auto-generated napi-rs loader
|
|
9
|
-
const { JsSqliteProvider, JsPostgresProvider, JsClient, JsRuntime, activityTraceLog, orchestrationTraceLog, activityIsCancelled } = require('../index.js');
|
|
9
|
+
const { JsSqliteProvider, JsPostgresProvider, JsClient, JsRuntime, activityTraceLog, orchestrationTraceLog, activityIsCancelled, activityGetClient } = require('../index.js');
|
|
10
10
|
|
|
11
11
|
// ─── Generator Driver ────────────────────────────────────────────
|
|
12
12
|
|
|
@@ -673,6 +673,14 @@ class Runtime {
|
|
|
673
673
|
async shutdown(timeoutMs) {
|
|
674
674
|
await this._native.shutdown(timeoutMs);
|
|
675
675
|
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Get a snapshot of runtime metrics.
|
|
679
|
+
* @returns {object|null}
|
|
680
|
+
*/
|
|
681
|
+
metricsSnapshot() {
|
|
682
|
+
return this._native.metricsSnapshot();
|
|
683
|
+
}
|
|
676
684
|
}
|
|
677
685
|
|
|
678
686
|
/**
|
|
@@ -713,6 +721,18 @@ class ActivityContext {
|
|
|
713
721
|
isCancelled() {
|
|
714
722
|
return activityIsCancelled(this._traceToken);
|
|
715
723
|
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Get a Client from the activity context, allowing activities to start new orchestrations.
|
|
727
|
+
* @returns {Client|null}
|
|
728
|
+
*/
|
|
729
|
+
getClient() {
|
|
730
|
+
const native = activityGetClient(this._traceToken);
|
|
731
|
+
if (!native) return null;
|
|
732
|
+
const client = Object.create(Client.prototype);
|
|
733
|
+
client._native = native;
|
|
734
|
+
return client;
|
|
735
|
+
}
|
|
716
736
|
}
|
|
717
737
|
|
|
718
738
|
// ─── Exports ─────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "duroxide",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Durable execution runtime for Node.js, powered by Rust",
|
|
5
5
|
"main": "lib/duroxide.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"node": ">= 18"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"duroxide-win32-x64-msvc": "0.1.
|
|
38
|
-
"duroxide-darwin-x64": "0.1.
|
|
39
|
-
"duroxide-linux-x64-gnu": "0.1.
|
|
40
|
-
"duroxide-darwin-arm64": "0.1.
|
|
37
|
+
"duroxide-win32-x64-msvc": "0.1.2",
|
|
38
|
+
"duroxide-darwin-x64": "0.1.2",
|
|
39
|
+
"duroxide-linux-x64-gnu": "0.1.2",
|
|
40
|
+
"duroxide-darwin-arm64": "0.1.2"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"index.js",
|