本文整理汇总了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})),
};
}));
示例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,
};
}));
示例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!;
}
示例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;
}