Make async for loops performant using Promise.all
This commit is contained in:
@@ -21,15 +21,16 @@ class Poller {
|
||||
async pollAll() {
|
||||
console.log(`[Poller] Polling all subscriptions`);
|
||||
const subscriptions = await subscriptionManager.all();
|
||||
for (const s of subscriptions) {
|
||||
try {
|
||||
// TODO(eslint): Switch to Promise.all
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await this.poll(s);
|
||||
} catch (e) {
|
||||
console.log(`[Poller] Error polling ${s.id}`, e);
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
subscriptions.map(async (s) => {
|
||||
try {
|
||||
await this.poll(s);
|
||||
} catch (e) {
|
||||
console.log(`[Poller] Error polling ${s.id}`, e);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
async poll(subscription) {
|
||||
|
||||
Reference in New Issue
Block a user