Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function mapBucket(Bucket: string, keyFilter: (key: string) => boolean) {
const faastModule = await faast("aws", m, {
memorySize: 2048,
timeout: 300,
mode: "queue",
concurrency: 2000,
childProcess: true,
gc: "off"
// awsLambdaOptions: { TracingConfig: { Mode: "Active" } }
});
console.log(`Logs: ${faastModule.logUrl()} `);
faastModule.on("stats", s => {
console.log(`${s}`);
});
const bandwidth = new Statistics();
try {
(async () => {
const m = await faast("aws", funcs);
await m.functions.hello("world");
const cost = await m.costSnapshot();
console.log(`hello world cost: $${cost.total()}`);
// hello world cost: $0.0000030596957398557663
await m.cleanup();
})();
(async () => {
const m = await faast("aws", funcs);
const promises = [];
// Summon 1000 cores
for (let i = 0; i < 1000; i++) {
promises.push(m.functions.hello("world " + i));
}
await Promise.all(promises);
await m.cleanup();
})();
async function main() {
const m = await faast("aws", funcs, {
packageJson: {
dependencies: {
sharp: "latest"
}
}
});
try {
const rv = await m.functions.runSharp();
writeFileSync("output.png", rv);
console.log(`wrote output.png`);
} finally {
await m.cleanup();
}
}
async function main() {
const m = await faast("local", funcs);
try {
const result = await m.functions.hello("world");
console.log(result);
} finally {
await m.cleanup();
}
}
export async function emptyBucket(Bucket: string) {
const faastModule = await faast("aws", m, {
memorySize: 256,
timeout: 300,
mode: "https",
concurrency: 1
});
const objects = await listAllObjects(Bucket);
console.log(`Emptying Bucket ${Bucket} with ${objects.length} keys`);
const promises: Promise[] = [];
while (true) {
const keys = objects.splice(0, 100).map(obj => obj.Key!);
if (keys.length === 0) {
break;
}
promises.push(faastModule.functions.deleteObjects(Bucket, keys));
}
await Promise.all(promises);
export async function mapObjects(Bucket: string, Keys: string[]) {
const faastModule = await faast("aws", m, {
memorySize: 1728,
timeout: 300,
mode: "https",
concurrency: 1
});
for (const Key of Keys) {
await faastModule.functions
.processBucketObject(Bucket, Key)
.catch(err => console.error(err));
console.log(`Processed ${Bucket}/${Key}`);
}
await faastModule.cleanup();
}