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();
'use strict';
const Consortium = require('coinstac-common').models.Consortium;
const dbRegistryService = require('./db-registry');
const logger = require('./logger.js');
/**
* @module service/seed-consortia
*/
/**
* conditionally seeds consortia db
* @param {object} config server config
* @returns {Promise} resolves to boolean indicating whether seeding happened or not
*/
/* istanbul ignore next */
module.exports = function seedConsortia(config) {
let seedDocs;
if (config.seed && typeof config.seed === 'string') {
'use strict';
const Pouchy = require('pouchy');
const dbConf = require('./.pouchdb-server-config');
const url = require('url');
const common = require('coinstac-common');
const Consortium = common.models.Consortium;
/**
* @private
* @module seed-central-db
* @description stubs a dummy consortium and a dummy computation into the
* infrastructure DBs, which will be consumed by the server and client processes
* @returns {Promise}
*/
module.exports = {
seed(declPath) {
const decl = require(declPath); // eslint-disable-line global-require
return Promise.all([
this._seedConsortia(decl),
this._seedComputations(decl),
])
'use strict';
/**
* @module consortia-service
*/
const common = require('coinstac-common');
const uuid = require('uuid');
const toArray = require('lodash/toArray');
const Consortium = common.models.Consortium;
const ModelService = require('../model-service');
class ConsortiaService extends ModelService {
constructor(opts) {
super(opts);
this.auth = opts.client.auth;
/* istanbul ignore next */
if (!this.auth) {
throw new ReferenceError('auth instance');
}
}
modelServiceHooks() { // eslint-disable-line class-methods-use-this
return {
dbName: 'consortia',
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: {
'use strict';
/**
* @module computation-service
*/
const common = require('coinstac-common');
const Computation = common.models.computation.Computation;
const crypto = require('crypto');
const deepEqual = require('deep-equal');
const getSyncedDatabase = common.utils.getSyncedDatabase;
const ModelService = require('../model-service');
const RemoteComputationResult = common.models.computation.RemoteComputationResult;
/**
* @extends ModelService
*/
class ComputationService extends ModelService {
modelServiceHooks() { // eslint-disable-line class-methods-use-this
return {
dbName: 'computations',
ModelType: Computation,
};
}
/**
getDBListener({ callback, consortiumId, projectId }) {
if (!consortiumId) {
throw new Error('Consortium ID required');
} else if (!callback || !(callback instanceof Function)) {
throw new Error('Callback function required');
}
// Deep props are unfortunately necessary for testing:
const dbListener = new coinstacCommon.helpers.DBListener(
this.dbRegistry.get(`remote-consortium-${consortiumId}`)
);
dbListener.on('change', ({ doc }) => {
ProjectService.handleRemoteResultChange({
callback,
consortiumId,
doc,
projectId,
});
});
dbListener.on('delete', ({ doc }) => {
ProjectService.handleRemoteResultDelete({
callback,
consortiumId,
doc,
'use strict';
/**
* @module service/remote-pipeline-runner-pool
*/
const coinstacCommon = require('coinstac-common');
const computationRegistryService = require('./computation-registry');
const dbRegistryService = require('./db-registry');
const logger = require('./logger');
const RemotePipelineRunnerPool =
coinstacCommon.models.pipeline.runner.pool.RemotePipelineRunnerPool;
/**
* @property pool RemotePipelineRunnerPool
* {@link http://mrn-code.github.io/coinstac-common/PipelineRunnerPool.html RemotePipelineRunnerPool}
*/
module.exports = {
pool: null,
/**
* initializes the server pipeline runner pool.
* @returns {Promise}
*/
init() {
const dbRegistry = dbRegistryService.get();
const computationRegistry = computationRegistryService.get();