How to use the coinstac-common.services function in coinstac-common

To help you get started, we’ve selected a few coinstac-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trendscenter / coinstac / packages / coinstac-computation-registry-new / src / adapters / ui-adapter.js View on Github external
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);
  }
}
github trendscenter / coinstac / packages / coinstac-computation-registry-new / src / adapters / cli-adapter.js View on Github external
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);
  }
}
github trendscenter / coinstac / packages / coinstac-server-core / src / services / db-registry.js View on Github external
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();
github trendscenter / coinstac / packages / coinstac-simulator / src / utils / get-pool-config.js View on Github external
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: {
github trendscenter / coinstac / packages / coinstac-simulator / src / local.js View on Github external
*/

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
github trendscenter / coinstac / packages / coinstac-computation-registry / src / factory.js View on Github external
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({
github trendscenter / coinstac / packages / coinstac-simulator / src / pool-initializer.js View on Github external
'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) {
github trendscenter / coinstac / packages / coinstac-simulator / src / utils / get-pool-config.js View on Github external
'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
github trendscenter / coinstac / packages / coinstac-simulator / src / pool-initializer.js View on Github external
'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}
github trendscenter / coinstac / packages / coinstac-simulator / src / pool-initializer.js View on Github external
'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) {

coinstac-common

COINSTAC core functionality.

MIT
Latest version published 29 days ago

Package Health Score

73 / 100
Full package analysis

Similar packages