Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const DEFAULT_OPTIONS = {
maxCallsPerWorker: Infinity,
maxConcurrentWorkers: require('os').cpus().length,
maxConcurrentCallsPerWorker: 10,
maxConcurrentCalls: Infinity,
maxCallTime: Infinity, // exceed this and the whole worker is terminated
maxRetries: Infinity,
forcedKillTime: 100,
autoStart: false,
};
const extend = require('xtend'),
fork = require('./fork'),
TimeoutError = require('errno').create('TimeoutError'),
ProcessTerminatedError = require('errno').create('ProcessTerminatedError'),
MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError');
const mergeStream = require('merge-stream');
function Farm(options: {+execArgv: Array}, path: string) {
this.options = extend(DEFAULT_OPTIONS, options);
this.path = path;
this.activeCalls = 0;
this.stdout = mergeStream();
this.stderr = mergeStream();
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function(method) {
return function() {
var args = Array.prototype.slice.call(arguments);
if (this.activeCalls >= this.options.maxConcurrentCalls) {
/* eslint-disable */
const DEFAULT_OPTIONS = {
maxCallsPerWorker: Infinity,
maxConcurrentWorkers: require('os').cpus().length,
maxConcurrentCallsPerWorker: 10,
maxConcurrentCalls: Infinity,
maxCallTime: Infinity, // exceed this and the whole worker is terminated
maxRetries: Infinity,
forcedKillTime: 100,
autoStart: false,
};
const extend = require('xtend'),
fork = require('./fork'),
TimeoutError = require('errno').create('TimeoutError'),
ProcessTerminatedError = require('errno').create('ProcessTerminatedError'),
MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError');
const mergeStream = require('merge-stream');
function Farm(options: {+execArgv: Array}, path: string) {
this.options = extend(DEFAULT_OPTIONS, options);
this.path = path;
this.activeCalls = 0;
this.stdout = mergeStream();
this.stderr = mergeStream();
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function(method) {
return function() {
const DEFAULT_OPTIONS = {
workerOptions : {}
, maxCallsPerWorker : Infinity
, maxConcurrentWorkers : (require('os').cpus() || { length: 1 }).length
, maxConcurrentCallsPerWorker : 10
, maxConcurrentCalls : Infinity
, maxCallTime : Infinity // exceed this and the whole worker is terminated
, maxRetries : Infinity
, forcedKillTime : 100
, autoStart : false
, onChild : function() {}
}
const fork = require('./fork')
, TimeoutError = require('errno').create('TimeoutError')
, ProcessTerminatedError = require('errno').create('ProcessTerminatedError')
, MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError')
function Farm (options, path) {
this.options = Object.assign({}, DEFAULT_OPTIONS, options)
this.path = path
this.activeCalls = 0
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function (method) {
return function () {
let args = Array.prototype.slice.call(arguments)
if (this.activeCalls + this.callQueue.length >= this.options.maxConcurrentCalls) {
let err = new MaxConcurrentCallsError('Too many concurrent calls (active: ' + this.activeCalls + ', queued: ' + this.callQueue.length + ')')
'use strict'
const DEFAULT_OPTIONS = {
workerOptions: {}
, maxCallsPerWorker: Infinity
, maxConcurrentWorkers: (require('os').cpus() || {length: 1}).length
, maxConcurrentCallsPerWorker: 10
, maxConcurrentCalls: Infinity
, maxCallTime: Infinity // exceed this and the whole worker is terminated
, maxRetries: Infinity
, forcedKillTime: 100
, autoStart: false
}
const fork = require('./fork')
, TimeoutError = require('errno').create('TimeoutError')
, ProcessTerminatedError = require('errno').create('ProcessTerminatedError')
, MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError')
function Farm(options, path) {
this.options = Object.assign({}, DEFAULT_OPTIONS, options)
this.path = path
this.activeCalls = 0
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function (method) {
return function () {
let args = Array.prototype.slice.call(arguments)
if (this.activeCalls >= this.options.maxConcurrentCalls) {
const DEFAULT_OPTIONS = {
workerOptions : {}
, maxCallsPerWorker : Infinity
, maxConcurrentWorkers : (require('os').cpus() || { length: 1 }).length
, maxConcurrentCallsPerWorker : 10
, maxConcurrentCalls : Infinity
, maxCallTime : Infinity // exceed this and the whole worker is terminated
, maxRetries : Infinity
, forcedKillTime : 100
, autoStart : false
, onChild : function() {}
}
const fork = require('./fork')
, TimeoutError = require('errno').create('TimeoutError')
, ProcessTerminatedError = require('errno').create('ProcessTerminatedError')
, MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError')
function Farm (options, path) {
this.options = Object.assign({}, DEFAULT_OPTIONS, options)
this.path = path
this.activeCalls = 0
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function (method) {
return function () {
let args = Array.prototype.slice.call(arguments)
if (this.activeCalls + this.callQueue.length >= this.options.maxConcurrentCalls) {
const DEFAULT_OPTIONS = {
workerOptions: {}
, maxCallsPerWorker: Infinity
, maxConcurrentWorkers: (require('os').cpus() || {length: 1}).length
, maxConcurrentCallsPerWorker: 10
, maxConcurrentCalls: Infinity
, maxCallTime: Infinity // exceed this and the whole worker is terminated
, maxRetries: Infinity
, forcedKillTime: 100
, autoStart: false
}
const fork = require('./fork')
, TimeoutError = require('errno').create('TimeoutError')
, ProcessTerminatedError = require('errno').create('ProcessTerminatedError')
, MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError')
function Farm(options, path) {
this.options = Object.assign({}, DEFAULT_OPTIONS, options)
this.path = path
this.activeCalls = 0
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function (method) {
return function () {
let args = Array.prototype.slice.call(arguments)
if (this.activeCalls >= this.options.maxConcurrentCalls) {
let err = new MaxConcurrentCallsError('Too many concurrent calls (' + this.activeCalls + ')')
const DEFAULT_OPTIONS = {
maxCallsPerWorker: Infinity,
maxConcurrentWorkers: require('os').cpus().length,
maxConcurrentCallsPerWorker: 10,
maxConcurrentCalls: Infinity,
maxCallTime: Infinity, // exceed this and the whole worker is terminated
maxRetries: Infinity,
forcedKillTime: 100,
autoStart: false
};
const extend = require('xtend'),
fork = require('./fork'),
TimeoutError = require('errno').create('TimeoutError'),
ProcessTerminatedError = require('errno').create('ProcessTerminatedError'),
MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError');
const mergeStream = require('merge-stream');
function Farm(options, path) {
this.options = extend(DEFAULT_OPTIONS, options);
this.path = path;
this.activeCalls = 0;
this.stdout = mergeStream();
this.stderr = mergeStream();
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function (method) {
return function () {
var args = Array.prototype.slice.call(arguments);
/* Copyright (c) 2012-2017 LevelUP contributors
* See list at
* MIT License
*
*/
var createError = require('errno').create
, LevelUPError = createError('LevelUPError')
, NotFoundError = createError('NotFoundError', LevelUPError)
NotFoundError.prototype.notFound = true
NotFoundError.prototype.status = 404
module.exports = {
LevelUPError : LevelUPError
, InitializationError : createError('InitializationError', LevelUPError)
, OpenError : createError('OpenError', LevelUPError)
, ReadError : createError('ReadError', LevelUPError)
, WriteError : createError('WriteError', LevelUPError)
, NotFoundError : NotFoundError
, EncodingError : createError('EncodingError', LevelUPError)
}
var createError = require('errno').create
, LevelUPError = createError('LevelUPError')
, NotFoundError = createError('NotFoundError', LevelUPError)
NotFoundError.prototype.notFound = true
NotFoundError.prototype.status = 404
module.exports = {
LevelUPError : LevelUPError
, InitializationError : createError('InitializationError', LevelUPError)
, OpenError : createError('OpenError', LevelUPError)
, ReadError : createError('ReadError', LevelUPError)
, WriteError : createError('WriteError', LevelUPError)
, NotFoundError : NotFoundError
, EncodingError : createError('EncodingError', LevelUPError)
}
* MIT License
*
*/
var createError = require('errno').create
, LevelUPError = createError('LevelUPError')
, NotFoundError = createError('NotFoundError', LevelUPError)
NotFoundError.prototype.notFound = true
NotFoundError.prototype.status = 404
module.exports = {
LevelUPError : LevelUPError
, InitializationError : createError('InitializationError', LevelUPError)
, OpenError : createError('OpenError', LevelUPError)
, ReadError : createError('ReadError', LevelUPError)
, WriteError : createError('WriteError', LevelUPError)
, NotFoundError : NotFoundError
, EncodingError : createError('EncodingError', LevelUPError)
}