@rip-lang/swarm 1.2.9 → 1.2.11
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 +5 -1
- package/package.json +2 -2
- package/swarm.rip +3 -9
package/README.md
CHANGED
|
@@ -83,7 +83,11 @@ rip jobs.rip -w 40 # 40 workers for I/O-heavy jobs
|
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
1. **`setup()`** runs once in the main thread — creates task files and
|
|
86
|
-
returns an optional context object (auth tokens, config, paths)
|
|
86
|
+
returns an optional context object (auth tokens, config, paths).
|
|
87
|
+
**Important:** the context must be plain data (strings, numbers,
|
|
88
|
+
booleans, arrays, plain objects). Class instances, functions, HTTP
|
|
89
|
+
clients, sockets, and other complex objects cannot be cloned for
|
|
90
|
+
worker threads — use `fetch` inside `perform()` instead
|
|
87
91
|
2. **N worker threads** are spawned — each loads your script and gets
|
|
88
92
|
the `perform` function. Workers are long-lived and process many tasks
|
|
89
93
|
3. Tasks are dispatched from `.swarm/todo/` to workers via message passing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rip-lang/swarm",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "Parallel job runner with worker threads — setup once, swarm many",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "swarm.rip",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"author": "Steve Shreeve <steve.shreeve@gmail.com>",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"rip-lang": "^3.13.
|
|
38
|
+
"rip-lang": "^3.13.5"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"swarm.rip",
|
package/swarm.rip
CHANGED
|
@@ -202,17 +202,12 @@ export swarm = (opts = {}) ->
|
|
|
202
202
|
workerPath = join(dirname(new URL(import.meta.url).pathname), 'lib', 'worker.mjs')
|
|
203
203
|
scriptPath = resolve(process.argv[1] or '')
|
|
204
204
|
|
|
205
|
-
# find rip-loader for workers (
|
|
205
|
+
# find rip-loader for workers (NODE_PATH ensures require.resolve works)
|
|
206
206
|
loaderPath = null
|
|
207
207
|
try
|
|
208
208
|
loaderPath = join(dirname(require.resolve('rip-lang')), '..', 'rip-loader.js')
|
|
209
209
|
catch
|
|
210
|
-
|
|
211
|
-
try
|
|
212
|
-
globalDir = join(process.env.HOME or '', '.bun', 'install', 'global', 'node_modules', 'rip-lang')
|
|
213
|
-
loaderPath = join(globalDir, 'rip-loader.js') if existsSync(join(globalDir, 'rip-loader.js'))
|
|
214
|
-
catch
|
|
215
|
-
null
|
|
210
|
+
null
|
|
216
211
|
|
|
217
212
|
# state
|
|
218
213
|
live = 0
|
|
@@ -284,8 +279,7 @@ export swarm = (opts = {}) ->
|
|
|
284
279
|
cursor(true) unless quiet
|
|
285
280
|
write go(workers + 5, 1) unless quiet
|
|
286
281
|
console.error "\nswarm: #{msg.error}"
|
|
287
|
-
|
|
288
|
-
exit 1
|
|
282
|
+
exit(1)
|
|
289
283
|
when 'ready'
|
|
290
284
|
dispatchNext(w, slot)
|
|
291
285
|
when 'done'
|