workerpool-plugin

0.0.1 • Public • Published

Workerpool plugin for wire.js

Installation

npm i workerpool-plugin

Usage

Install wire from git://github.com/cujojs/wire.git#0.10.11

import wire from 'wire';
import workerpoolPlugin from 'workerpool-plugin';

const spec = {
    $plugins: [
        workerpool
    ],

    wpool: {
        createWorkerPool: {
            workers: [
                {name: 'fibonacci', path: __dirname + '/assets/worker.js'}
            ]
        }
    },

    poolInvocationResult: {
        create: {
            module: (wpool) => wpool['fibonacci'].proxy()
                .then(function (worker) {
                    return worker.run(8);
                })
                .then(function (result) {
                    wpool['fibonacci'].terminate();
                    return result;
                })
                .catch(function (error) {
                    console.error('Smth went wrong:', error);
                }),
            args: [
                {$ref: 'wpool'}
            ]
        }
    }
}

wire(spec)

Readme

Keywords

none

Package Sidebar

Install

npm i workerpool-plugin

Weekly Downloads

3

Version

0.0.1

License

ISC

Unpacked Size

4.01 kB

Total Files

5

Last publish

Collaborators

  • designeng