当前位置: 首页>>代码示例>>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;未经允许,请勿转载。