本文整理匯總了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;
}