0.0.1 • Published 4 years ago

workerpool-plugin v0.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

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)
0.0.1

4 years ago