tywrap 0.1.2 → 0.2.1
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 +11 -4
- package/dist/index.d.ts +20 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime/base.d.ts +17 -7
- package/dist/runtime/base.d.ts.map +1 -1
- package/dist/runtime/base.js +18 -1
- package/dist/runtime/base.js.map +1 -1
- package/dist/runtime/bounded-context.d.ts +252 -0
- package/dist/runtime/bounded-context.d.ts.map +1 -0
- package/dist/runtime/bounded-context.js +454 -0
- package/dist/runtime/bounded-context.js.map +1 -0
- package/dist/runtime/bridge-protocol.d.ts +167 -0
- package/dist/runtime/bridge-protocol.d.ts.map +1 -0
- package/dist/runtime/bridge-protocol.js +247 -0
- package/dist/runtime/bridge-protocol.js.map +1 -0
- package/dist/runtime/disposable.d.ts +40 -0
- package/dist/runtime/disposable.d.ts.map +1 -0
- package/dist/runtime/disposable.js +49 -0
- package/dist/runtime/disposable.js.map +1 -0
- package/dist/runtime/http-io.d.ts +91 -0
- package/dist/runtime/http-io.d.ts.map +1 -0
- package/dist/runtime/http-io.js +195 -0
- package/dist/runtime/http-io.js.map +1 -0
- package/dist/runtime/http.d.ts +47 -13
- package/dist/runtime/http.d.ts.map +1 -1
- package/dist/runtime/http.js +55 -74
- package/dist/runtime/http.js.map +1 -1
- package/dist/runtime/node.d.ts +142 -28
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +321 -168
- package/dist/runtime/node.js.map +1 -1
- package/dist/runtime/optimized-node.d.ts +19 -125
- package/dist/runtime/optimized-node.d.ts.map +1 -1
- package/dist/runtime/optimized-node.js +19 -550
- package/dist/runtime/optimized-node.js.map +1 -1
- package/dist/runtime/pooled-transport.d.ts +131 -0
- package/dist/runtime/pooled-transport.d.ts.map +1 -0
- package/dist/runtime/pooled-transport.js +175 -0
- package/dist/runtime/pooled-transport.js.map +1 -0
- package/dist/runtime/process-io.d.ts +204 -0
- package/dist/runtime/process-io.d.ts.map +1 -0
- package/dist/runtime/process-io.js +695 -0
- package/dist/runtime/process-io.js.map +1 -0
- package/dist/runtime/pyodide-io.d.ts +155 -0
- package/dist/runtime/pyodide-io.d.ts.map +1 -0
- package/dist/runtime/pyodide-io.js +397 -0
- package/dist/runtime/pyodide-io.js.map +1 -0
- package/dist/runtime/pyodide.d.ts +51 -19
- package/dist/runtime/pyodide.d.ts.map +1 -1
- package/dist/runtime/pyodide.js +57 -186
- package/dist/runtime/pyodide.js.map +1 -1
- package/dist/runtime/safe-codec.d.ts +81 -0
- package/dist/runtime/safe-codec.d.ts.map +1 -0
- package/dist/runtime/safe-codec.js +345 -0
- package/dist/runtime/safe-codec.js.map +1 -0
- package/dist/runtime/transport.d.ts +186 -0
- package/dist/runtime/transport.d.ts.map +1 -0
- package/dist/runtime/transport.js +86 -0
- package/dist/runtime/transport.js.map +1 -0
- package/dist/runtime/validators.d.ts +131 -0
- package/dist/runtime/validators.d.ts.map +1 -0
- package/dist/runtime/validators.js +219 -0
- package/dist/runtime/validators.js.map +1 -0
- package/dist/runtime/worker-pool.d.ts +196 -0
- package/dist/runtime/worker-pool.d.ts.map +1 -0
- package/dist/runtime/worker-pool.js +371 -0
- package/dist/runtime/worker-pool.js.map +1 -0
- package/dist/utils/codec.d.ts.map +1 -1
- package/dist/utils/codec.js +120 -1
- package/dist/utils/codec.js.map +1 -1
- package/package.json +2 -2
- package/runtime/python_bridge.py +30 -3
- package/runtime/safe_codec.py +344 -0
- package/src/index.ts +48 -5
- package/src/runtime/base.ts +18 -26
- package/src/runtime/bounded-context.ts +608 -0
- package/src/runtime/bridge-protocol.ts +319 -0
- package/src/runtime/disposable.ts +65 -0
- package/src/runtime/http-io.ts +244 -0
- package/src/runtime/http.ts +71 -117
- package/src/runtime/node.ts +460 -217
- package/src/runtime/optimized-node.ts +19 -761
- package/src/runtime/pooled-transport.ts +252 -0
- package/src/runtime/process-io.ts +902 -0
- package/src/runtime/pyodide-io.ts +485 -0
- package/src/runtime/pyodide.ts +75 -215
- package/src/runtime/safe-codec.ts +443 -0
- package/src/runtime/transport.ts +273 -0
- package/src/runtime/validators.ts +241 -0
- package/src/runtime/worker-pool.ts +498 -0
- package/src/utils/codec.ts +126 -1
|
@@ -1,128 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* @deprecated Import from './node.js' instead.
|
|
3
|
+
*
|
|
4
|
+
* OptimizedNodeBridge has been unified with NodeBridge. The NodeBridge class
|
|
5
|
+
* now supports both single-process mode (default) and multi-process pooling
|
|
6
|
+
* via the minProcesses/maxProcesses options.
|
|
7
|
+
*
|
|
8
|
+
* Migration:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Before
|
|
11
|
+
* import { OptimizedNodeBridge, ProcessPoolOptions } from './optimized-node.js';
|
|
12
|
+
* const bridge = new OptimizedNodeBridge({ minProcesses: 2, maxProcesses: 4 });
|
|
13
|
+
*
|
|
14
|
+
* // After
|
|
15
|
+
* import { NodeBridge, NodeBridgeOptions } from './node.js';
|
|
16
|
+
* const bridge = new NodeBridge({ minProcesses: 2, maxProcesses: 4 });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* This file is maintained for backward compatibility only.
|
|
4
20
|
*/
|
|
5
|
-
|
|
6
|
-
interface ProcessPoolOptions {
|
|
7
|
-
minProcesses?: number;
|
|
8
|
-
maxProcesses?: number;
|
|
9
|
-
maxIdleTime?: number;
|
|
10
|
-
maxRequestsPerProcess?: number;
|
|
11
|
-
pythonPath?: string;
|
|
12
|
-
scriptPath?: string;
|
|
13
|
-
virtualEnv?: string | undefined;
|
|
14
|
-
cwd?: string;
|
|
15
|
-
timeoutMs?: number;
|
|
16
|
-
maxLineLength?: number;
|
|
17
|
-
enableJsonFallback?: boolean;
|
|
18
|
-
enableCache?: boolean;
|
|
19
|
-
env?: Record<string, string | undefined>;
|
|
20
|
-
warmupCommands?: Array<{
|
|
21
|
-
method: string;
|
|
22
|
-
params: unknown;
|
|
23
|
-
}>;
|
|
24
|
-
}
|
|
25
|
-
interface OptimizedBridgeStats {
|
|
26
|
-
totalRequests: number;
|
|
27
|
-
totalTime: number;
|
|
28
|
-
cacheHits: number;
|
|
29
|
-
poolHits: number;
|
|
30
|
-
poolMisses: number;
|
|
31
|
-
processSpawns: number;
|
|
32
|
-
processDeaths: number;
|
|
33
|
-
memoryPeak: number;
|
|
34
|
-
averageTime: number;
|
|
35
|
-
cacheHitRate: number;
|
|
36
|
-
}
|
|
37
|
-
interface OptimizedBridgeStatsSnapshot extends OptimizedBridgeStats {
|
|
38
|
-
poolSize: number;
|
|
39
|
-
busyWorkers: number;
|
|
40
|
-
memoryUsage: NodeJS.MemoryUsage;
|
|
41
|
-
workerStats: Array<{
|
|
42
|
-
id: string;
|
|
43
|
-
requestCount: number;
|
|
44
|
-
averageTime: number;
|
|
45
|
-
errorCount: number;
|
|
46
|
-
busy: boolean;
|
|
47
|
-
pendingRequests: number;
|
|
48
|
-
}>;
|
|
49
|
-
}
|
|
50
|
-
export declare class OptimizedNodeBridge extends RuntimeBridge {
|
|
51
|
-
private processPool;
|
|
52
|
-
private roundRobinIndex;
|
|
53
|
-
private cleanupTimer?;
|
|
54
|
-
private options;
|
|
55
|
-
private emitter;
|
|
56
|
-
private disposed;
|
|
57
|
-
private stats;
|
|
58
|
-
constructor(options?: ProcessPoolOptions);
|
|
59
|
-
init(): Promise<void>;
|
|
60
|
-
call<T = unknown>(module: string, functionName: string, args: unknown[], kwargs?: Record<string, unknown>): Promise<T>;
|
|
61
|
-
instantiate<T = unknown>(module: string, className: string, args: unknown[], kwargs?: Record<string, unknown>): Promise<T>;
|
|
62
|
-
callMethod<T = unknown>(handle: string, methodName: string, args: unknown[], kwargs?: Record<string, unknown>): Promise<T>;
|
|
63
|
-
disposeInstance(handle: string): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Execute request with intelligent process selection
|
|
66
|
-
*/
|
|
67
|
-
private executeRequest;
|
|
68
|
-
/**
|
|
69
|
-
* Select optimal worker based on load and performance
|
|
70
|
-
*/
|
|
71
|
-
private selectOptimalWorker;
|
|
72
|
-
/**
|
|
73
|
-
* Wait for any worker to become available
|
|
74
|
-
*/
|
|
75
|
-
private waitForAvailableWorker;
|
|
76
|
-
/**
|
|
77
|
-
* Send request to specific worker
|
|
78
|
-
*/
|
|
79
|
-
private sendToWorker;
|
|
80
|
-
private quarantineWorker;
|
|
81
|
-
/**
|
|
82
|
-
* Spawn new worker process with optimizations
|
|
83
|
-
*/
|
|
84
|
-
private spawnProcess;
|
|
85
|
-
/**
|
|
86
|
-
* Setup event handlers for worker process
|
|
87
|
-
*/
|
|
88
|
-
private setupProcessHandlers;
|
|
89
|
-
/**
|
|
90
|
-
* Handle worker process exit
|
|
91
|
-
*/
|
|
92
|
-
private handleWorkerExit;
|
|
93
|
-
/**
|
|
94
|
-
* Warm up processes with configured commands
|
|
95
|
-
*/
|
|
96
|
-
private warmupProcesses;
|
|
97
|
-
private safeCacheKey;
|
|
98
|
-
/**
|
|
99
|
-
* Heuristic to determine if function result should be cached
|
|
100
|
-
*/
|
|
101
|
-
private isPureFunctionCandidate;
|
|
102
|
-
/**
|
|
103
|
-
* Update performance statistics
|
|
104
|
-
*/
|
|
105
|
-
private updateStats;
|
|
106
|
-
/**
|
|
107
|
-
* Get performance statistics
|
|
108
|
-
*/
|
|
109
|
-
getStats(): OptimizedBridgeStatsSnapshot;
|
|
110
|
-
/**
|
|
111
|
-
* Cleanup idle processes
|
|
112
|
-
*/
|
|
113
|
-
private cleanup;
|
|
114
|
-
/**
|
|
115
|
-
* Gracefully terminate a worker
|
|
116
|
-
*/
|
|
117
|
-
private terminateWorker;
|
|
118
|
-
/**
|
|
119
|
-
* Start cleanup scheduler
|
|
120
|
-
*/
|
|
121
|
-
private startCleanupScheduler;
|
|
122
|
-
/**
|
|
123
|
-
* Dispose all resources
|
|
124
|
-
*/
|
|
125
|
-
dispose(): Promise<void>;
|
|
126
|
-
}
|
|
127
|
-
export {};
|
|
21
|
+
export { NodeBridge as OptimizedNodeBridge, type NodeBridgeOptions as ProcessPoolOptions } from './node.js';
|
|
128
22
|
//# sourceMappingURL=optimized-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimized-node.d.ts","sourceRoot":"","sources":["../../src/runtime/optimized-node.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"optimized-node.d.ts","sourceRoot":"","sources":["../../src/runtime/optimized-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,KAAK,iBAAiB,IAAI,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|