Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pullImageWrapper(payload) { // eslint-disable-line class-methods-use-this
common.services.dockerManager.pullImage(payload.img)
.then((stream) => {
return new Promise((res) => {
stream.on('data', (data) => {
let output = compact(data.toString().split('\r\n'));
output = output.map(JSON.parse);
payload.window.webContents.send('docker-out', output);
});
stream.on('close', (code) => {
res(code);
});
});
})
.catch(console.log);
}
}
pullImageWrapper(payload) { // eslint-disable-line class-methods-use-this
common.services.dockerManager.pullImage(payload.img)
.then((stream) => {
return new Promise((res) => {
stream.pipe(process.stdout);
stream.on('close', (code) => {
res(code);
});
});
})
.catch(console.log);
}
}
init(opts) {
// Unfortunately necessary for sinon spying
const dbRegistryFactory = common.services.dbRegistry;
const config = opts ? cloneDeep(opts) : {};
const dbRegistryOptions = cloneDeep(DB_REGISTRY_DEFAULTS);
if (config.dbUrl) {
dbRegistryOptions.remote.db = url.parse(config.dbUrl);
}
if (config.inMemory) {
dbRegistryFactory.DBRegistry.Pouchy.plugin(pouchDBAdapterMemory);
dbRegistryOptions.pouchConfig.adapter = 'memory';
} else {
dbRegistryFactory.DBRegistry.Pouchy.plugin(pouchDbAdapterLevelDB);
dbRegistryOptions.pouchConfig.adapter = 'leveldb';
}
dbRegistryOptions.path = this.getDBPath();
module.exports = function getPoolConfig(params) {
const computationPath = params.computationPath;
const isLocal = ('isLocal' in params && typeof params.isLocal === 'boolean') ?
params.isLocal :
true;
const computationDir = path.dirname(computationPath);
const dbRegistry = common.services.dbRegistry({
isLocal,
isRemote: !isLocal,
local: {
pouchConfig: {
adapter: 'memory',
},
},
noURLPrefix: true, // disable db pre-fixing (e.g. no `up/`, `down/`)
path: path.join(__dirname, '..', '.tmp'),
remote: {
db: {
hostname: 'localhost',
port: pouchDBServerConfig.port,
protocol: 'http',
},
pouchConfig: {
*/
require('./utils/handle-errors');
const CoinstacClient = require('coinstac-client-core');
const coinstacCommon = require('coinstac-common');
const path = require('path');
const pouchDBAdapterMemory = require('pouchdb-adapter-memory');
const retry = require('retry');
const config = require('./utils/config.js');
const getComputationRegistryStub =
require('./utils/get-computation-registry-stub.js');
const { getChildProcessLogger } = require('./utils/logging.js');
const dbRegistry = coinstacCommon.services.dbRegistry;
const logger = getChildProcessLogger();
const pouchDBServerConfig = config['pouch-db-server'];
dbRegistry.DBRegistry.Pouchy.plugin(pouchDBAdapterMemory);
let initiate = false;
let client;
let username;
/**
* Get all documents.
*
* This function attempts to combat latency and an undetermined race condition
* with two methods:
*
* 1. Retrieving a 'synced' Pouchy instance with the `getSyncedDatabase` utility
function computationRegistryFactory(options) {
const localOptions = options || {};
const isLocal = localOptions.isLocal;
const dbRegistry = localOptions.dbRegistry;
let registry;
if (
isLocal &&
(
!dbRegistry ||
!(dbRegistry instanceof coinstacCommon.services.dbRegistry.DBRegistry)
)
) {
return Promise.reject(
new Error('Computation registry requires DB registry')
);
}
if (localOptions.registry) {
registry = localOptions.registry;
} else if (isLocal) {
registry = [];
} else {
registry = defaultRegistry;
}
const instance = new ComputationRegistry({
'use strict';
const pdbsConfig = require('./.pouchdb-server-config');
const common = require('coinstac-common');
const DBRegistry = require('coinstac-common').services.dbRegistry.DBRegistry;
DBRegistry.Pouchy.plugin(require('pouchdb-adapter-memory'));
const dbRegistryFactory = common.services.dbRegistry;
const computationRegistryFactory = common.services.computationRegistry;
const path = require('path');
/**
* @private
* @module pool-initializer
* @description utility to generate PipelineRunnerPool inputs, used by
* compute client and compute servers
*/
module.exports = {
/**
* get a functional set of constructor opts for a PipelineRunnerPool
* @returns {Promise}
*/
getPoolOpts(opts) {
if (!opts) {
'use strict';
const coinstacComputationRegistry = require('coinstac-computation-registry');
const config = require('./config');
const common = require('coinstac-common');
const DBRegistry = require('coinstac-common').services.dbRegistry.DBRegistry;
DBRegistry.Pouchy.plugin(require('pouchdb-adapter-memory'));
const path = require('path');
const pouchDBServerConfig = config['pouch-db-server'];
/**
* Get pool configuration.
* @private
*
* @description utility to generate PipelineRunnerPool inputs, used by local and
* remote processes.
*
* @param {Object} params
* @param {string} params.computationPath
* @param {boolean} [params.isLocal=true]
* @returns {Promise} Resolves to a PipelineRunnerPool
'use strict';
const pdbsConfig = require('./.pouchdb-server-config');
const common = require('coinstac-common');
const DBRegistry = require('coinstac-common').services.dbRegistry.DBRegistry;
DBRegistry.Pouchy.plugin(require('pouchdb-adapter-memory'));
const dbRegistryFactory = common.services.dbRegistry;
const computationRegistryFactory = common.services.computationRegistry;
const path = require('path');
/**
* @private
* @module pool-initializer
* @description utility to generate PipelineRunnerPool inputs, used by
* compute client and compute servers
*/
module.exports = {
/**
* get a functional set of constructor opts for a PipelineRunnerPool
* @returns {Promise}
'use strict';
const pdbsConfig = require('./.pouchdb-server-config');
const common = require('coinstac-common');
const DBRegistry = require('coinstac-common').services.dbRegistry.DBRegistry;
DBRegistry.Pouchy.plugin(require('pouchdb-adapter-memory'));
const dbRegistryFactory = common.services.dbRegistry;
const computationRegistryFactory = common.services.computationRegistry;
const path = require('path');
/**
* @private
* @module pool-initializer
* @description utility to generate PipelineRunnerPool inputs, used by
* compute client and compute servers
*/
module.exports = {
/**
* get a functional set of constructor opts for a PipelineRunnerPool
* @returns {Promise}
*/
getPoolOpts(opts) {