當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript retryx.default函數代碼示例

本文整理匯總了TypeScript中retryx.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: retryx

  return await Promise.all(imageDeletionPlans.map(async (imageDeletionPlan, index) => {
    const snapshotIds = imageDeletionPlan.image.BlockDeviceMappings!.filter(bd => bd.Ebs)!.map(bd => bd.Ebs!.SnapshotId!);

    if (process.env.sleepBeforeEach) {
      const ms = parseInt(process.env.sleepBeforeEach, 10) * index;
      if (ms > 0) await sleep(ms);
    }

    await retryx(() => ec2.deregisterImage({ImageId: imageDeletionPlan.image.ImageId!}).promise());

    if (process.env.sleepBeforeDeleteSnapshots) {
      const ms = parseInt(process.env.sleepBeforeDeleteSnapshots, 10);
      if (ms > 0) await sleep(ms);
    }

    await Promise.all(snapshotIds.map(snapshotId =>
      retryx(() => ec2.deleteSnapshot({SnapshotId: snapshotId}).promise())
    ));

    return {
      imageId:   imageDeletionPlan.image.ImageId!,
      reason:    imageDeletionPlan.reason,
      snapshots: snapshotIds.map(snapshotId => ({snapshotId})),
    };
  }));
開發者ID:y13i,項目名稱:amirotate,代碼行數:25,代碼來源:delete.ts

示例2: retryx

  return await Promise.all(instances.map(async (instance, index) => {
    const instanceId = instance.InstanceId!;
    const option     = getOption(instance, tagKey)!;

    const tags = instance.Tags!.filter(tag => {
      if (tag.Key!.startsWith('aws:')) {
        return false;
      }

      if (tag.Key! !== tagKey && tag.Key!.startsWith('amirotate:')) {
        return false;
      }

      return true;
    });

    if (process.env.sleepBeforeEach) {
      const ms = parseInt(process.env.sleepBeforeEach, 10) * index;
      if (ms > 0) await sleep(ms);
    }

    const createImageResult = await retryx(() => ec2.createImage({
      InstanceId: instanceId,
      Name:       `${instanceId}_${Date.now()}`,
      NoReboot:   option.NoReboot,
    }).promise());

    const imageId = createImageResult.ImageId!;

    await retryx(() => ec2.createTags({
      Resources: [imageId],
      Tags:      tags,
    }).promise());

    return {
      instanceId,
      imageId,
      tags,
    };
  }));
開發者ID:y13i,項目名稱:amirotate,代碼行數:40,代碼來源:create.ts

示例3: getImages

async function getImages(ec2: EC2, tagKey: string): Promise<EC2.Image[]> {
  const describeImagesResult = await retryx(() => ec2.describeImages({
    Owners: ['self'],

    Filters: [
      {
        Name:   'state',
        Values: ['available'],
      },

      {
        Name:   'tag-key',
        Values: [tagKey],
      }
    ],
  }).promise());

  return describeImagesResult.Images!;
}
開發者ID:y13i,項目名稱:amirotate,代碼行數:19,代碼來源:delete.ts

示例4: getInstances

async function getInstances(ec2: EC2, tagKey: string): Promise<EC2.Instance[]> {
  const instances: EC2.Instance[] = [];

  let nextToken: string | undefined;

  do {
    const describeInstancesResult = await retryx(() => ec2.describeInstances({
      NextToken: nextToken,

      Filters: [
        {
          Name: 'instance-state-name',

          Values: [
            'running',
            'stopping',
            'stopped',
          ],
        },

        {
          Name:   'tag-key',
          Values: [tagKey],
        },
      ]
    }).promise());

    describeInstancesResult.Reservations!.forEach(
      reservation => instances.push(...reservation.Instances!)
    );

    nextToken = describeInstancesResult.NextToken;
  } while (nextToken);

  return instances;
}
開發者ID:y13i,項目名稱:amirotate,代碼行數:36,代碼來源:create.ts


注:本文中的retryx.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。