How to use the @cumulus/ingest/lock.proceed function in @cumulus/ingest

To help you get started, we’ve selected a few @cumulus/ingest 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 nasa / cumulus / tasks / sync-granule / index.js View on Github external
async function download(ingest, bucket, provider, granules) {
  log.debug(`awaiting lock.proceed in download() bucket: ${bucket}, `
            + `provider: ${JSON.stringify(provider)}, granuleID: ${granules[0].granuleId}`);
  const proceed = await lock.proceed(bucket, provider, granules[0].granuleId);

  if (!proceed) {
    const err = new errors.ResourcesLockedError('Download lock remained in place after multiple tries');
    log.error(err);
    throw err;
  }

  const ingestGranule = async (granule) => {
    try {
      const startTime = Date.now();
      const r = await ingest.ingest(granule, bucket);
      const endTime = Date.now();

      return {
        ...r,
        sync_granule_duration: endTime - startTime
github nasa / cumulus / cumulus / tasks / sync-granule / index.js View on Github external
async function download(ingest, bucket, provider, granules) {
  const updatedGranules = [];

  const proceed = await lock.proceed(bucket, provider, granules[0].granuleId);

  if (!proceed) {
    const err = new errors.ResourcesLockedError(
      'Download lock remained in place after multiple tries'
    );
    log.error(err);
    throw err;
  }

  for (const g of granules) {
    try {
      const r = await ingest.ingest(g);
      updatedGranules.push(r);
    }
    catch (e) {
      await lock.removeLock(bucket, provider.id, g.granuleId);