{"_id":"@buzuli/transport","_rev":"1-1a720423de8b6d71209874699e27e709","name":"@buzuli/transport","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@buzuli/transport","version":"1.0.0","description":"subprocess coordination for Node.js","main":"lib/index.js","scripts":{"build":"npm run lint && npm run test","lint":"standard","lint:fix":"standard --fix","release":"standard-version","test":"tap test/*.test.js"},"keywords":["transport","parallel","multiprocessing","subprocess"],"author":{"name":"Joel Edwards","email":"joeledwards@gmail.com"},"license":"ISC","dependencies":{"@buzuli/meter":"^1.0.1"},"devDependencies":{"standard":"^14.2.0","standard-version":"^7.0.0","tap":"^14.6.2"},"gitHead":"37c61db7bbc75d9318b61de605f77d2593725cc3","_id":"@buzuli/transport@1.0.0","_nodeVersion":"10.17.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-h3EeBDkuOQPGJABaxZHWXAffUqKlBAMG5NwhUloCtNUFisUIAu2DidSF5oSi2brQUCYum4cRc7k8/KIZuKaHeA==","shasum":"e8a3e1b658c650bdd60ea1da4ab729fdfd795479","tarball":"https://registry.npmjs.org/@buzuli/transport/-/transport-1.0.0.tgz","fileCount":7,"unpackedSize":8834,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeT/OfCRA9TVsSAnZWagAAzOYQAJnJ/+i9RC7yJfLEJwUz\n9ExYs6lAC2zLjL/RriebYhvsM/hNlVgzFOGv6/F/wPUrNU9Lpmyf7sId1PNi\n7zJZo9jomMYkmvwt6Esv4bybtIDWGXG4hGtPl4ufDJYu8TvZ2AgBkDYz5ot7\nfILHpuSW+vrdSXarylUmf2OeixHmnRY81u21jByPPrVMi8/aVVshL+tOCaE6\nlvMTae2ECenEKh4RejuxeJvV2zx98+ahuBWm6Ake4/4uRR+zdqZoaBMgl4I/\nMd8UwO3+OCj3lXUwUmAdU/Ky7T10xzhjBP35yeLao1ptxWWX0S+bCIfUVUSr\nIxXNZUnORyivhBnzjMutpqrKm6Kz6y/rNdKk3pwqV1e5ABy902Xer6a4DeXC\nbOEj+u0ASH4I1Fr0X3fd0rvczEXEJyqwPRuAVId0pV7r3Iz4tvsEjDxSrW8L\nLT9IQXGDYgnT1T+YjOBuYKdtldpIMrg92QxJUjVbcaNaXQoQ5VJbiCg8I5LP\n50fB5oR8HLe6lABoFN/4MdjLUtF55zcN71+ngXC9Eaxj/vyinscnzlN2aGc/\np1PiEHzAOjZelDOvtXwUS/MzTF+A/dKb+w55rnT2TWJEge9Bys41t+N8toGL\nKOlAlnoyu6bmOy22t0cHcCRKZS9Z07L0kWTI41BDnToyhXn9dHLrM+zOj049\nCwvy\r\n=XL3d\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICLEwzUYtVt3Jw3nR0OX87QSNdAKBblx/xNrH7HglaNlAiAiIGvb2eetj/7O+sW/c+YEPcbl3HCILQWhg06Y8vSyUA=="}]},"maintainers":[{"name":"buzuli","email":"joeledwards@gmail.com"}],"_npmUser":{"name":"buzuli","email":"joeledwards@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/transport_1.0.0_1582298015400_0.005786343261010796"},"_hasShrinkwrap":false}},"time":{"created":"2020-02-21T15:13:35.371Z","1.0.0":"2020-02-21T15:13:35.497Z","modified":"2022-04-04T21:11:24.122Z"},"maintainers":[{"name":"buzuli","email":"joeledwards@gmail.com"}],"description":"subprocess coordination for Node.js","keywords":["transport","parallel","multiprocessing","subprocess"],"author":{"name":"Joel Edwards","email":"joeledwards@gmail.com"},"license":"ISC","readme":"# transport\n\nTransport system for use by parent and child processes forked via `child_process.fork()`.\n\n## transport.coordinator\n\nCreates a transport for a coordinator (parent process) to direct its workers (child processes).\n\n`transport.coordinator(options)`\n- `options.logger`: `object` = `console` | The logger which this coordinator tranport should use.\n\nReturns `{ addWorker, removeWorker, setLogger, shutdown, sendConfig, sendPing, sendTask, sendCollect, sendEnd } extends EventEmitter`:\n- `addWorker`: `(proc) => id` | Adds a worker process handle to the transport and returns the generated worker ID.\n- `removeWorker`: `(id) => proc` | Removes and returns the identified worker if found.\n- `setLogger`: `(logger) => nil` | Replaces the transport's logger.\n- `shutdown`: `() => nil` | Removes all listeners and handlers (permit the process to exit cleanly).\n- `sendConfig`: `(id, config) => nil` | Sends a config object to a worker (should happen after the `online` event).\n- `sendPing`: `(id) => nil` | Pings a worker (response event is `online`).\n- `sendTask`: `(id, task) => nil` | Sends a task object to a worker.\n- `sendCollect`: `(id) => nil` | Sends a collect request to a worker.\n- `sendEnd`: `(id) => nil` | Directs a worker to halt.\n\nEvents:\n- `online` | A worker has started and its transport is online. Is also emitted in response to a `ping`.\n- `ready` | A worker is ready to receive a task (should be after config has been received and all initialization work is completed).\n- `result` | A worker has sent result data (should be emitted in response to a coordinator's `collect` request).\n- `done` | A worker is halting and will not respond to any futher communication. The worker should be removed from this transport.\n- `log` | Should be used to transmit log data to the coordinator.\n\nAll events emit `{ id, data? }`:\n- `id`: `number` | The ID of the worker which emitted the event.\n- `data`: `object` | The payload associated with the event (should be present in `result` and `log` events).\n\n## transport.worker\n\nCreates a transport for a worker (child process) to receive instruction from its coordinator (parent process).\n\n`transport.worker(options)`\n- `options.logger`: `object` = `console` | The logger which this worker transport should use.\n\nReturns `{ setLogger, shutdown, sendOnline, sendReady, sendResult, sendDone, sendLog } extends EventEmitter`:\n- `setLogger`: `(logger) => nil` | Replaces the transport's logger.\n- `shutdown`: `() => nil` | Removes all listeners and handlers (permit the process to exit cleanly).\n- `sendOnline`: `(data?) => nil` | Indicate that this worker's transport is active.\n- `sendReady`: `(data?) => nil` | Indicate that this worker is ready to receive a task (typically on completion of the prior task).\n- `sendResult`: `(data) => nil` | Send a result to the coordinator (should be in response to a `collect` event).\n- `sendDone`: `(data?) => nil` | Indicate that this worker is halting and will not respond to any further communcation from the coordinator.\n- `sendLog`: `(data) => nil` | Sends a log record to the the coordinator.\n\nEvents:\n- `config` | The coordinator has sent configuration.\n- `task` | The coordinator has assigned a new task to this worker.\n- `collect` | The coordinator has requested that the worker deliver any cached results.\n- `end` | The coordinator has requested that the worker halt.\n\nSome events emit a data field:\n- `data`: `object` | The payload associated with the event (should be present in `config` and `task` events).\n\n## transport.run\n\nRuns an action, with configurable handling of the outcome.\n\n`transport.run(action, options)`\n- `action`: `() => Promise | any` | The function which should be run and awaited.\n- `options.logger`: `object` = `console` | The logger to which errors should be sent.\n- `options.rethrow`: `boolean` = `true` | Rethrow if an exception is caught while awaiting `action()`.\n\nReturns a promise which indicates the outcome of the `action()` function.\n\n","readmeFilename":"README.md"}