Skip to content

Commit

Permalink
[#] Timeout exponentially and throw error for old aio API
Browse files Browse the repository at this point in the history
  • Loading branch information
cubehouse committed May 17, 2024
1 parent 087ba5c commit 21c3054
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lib/parks/attractionsio/attractionsio.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ export class AttractionsIO extends Destination {

// give up after 5 tries...
if (depth < 5) {
// wait 10 seconds
this.log('Status Code 202 receieved. Data is still being generated, waiting 10 seconds and trying again...');
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
// wait 10 x depth seconds
const seconds = 10 * depth;
this.log(`Status Code 202 receieved. Data is still being generated, waiting ${seconds} seconds before trying again...`);
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
// try again
return this.getPOIData(depth++);
} else {
throw new Error('Data generation still in progress after 5 attempts');
}
}

Expand Down Expand Up @@ -694,3 +697,17 @@ export class HeidePark extends AttractionsIO {
super(config);
}
}

export class Knoebels extends AttractionsIO {
constructor(config = {}) {
config.timezone = config.timezone || 'America/New_York';
config.destinationId = config.destinationId || 'knoebels';
config.parkId = config.parkId || 'knoebelspark';
config.initialDataVersion = config.initialDataVersion || '2024-05-05T15:08:58Z';

config.appBuild = config.appBuild || 48;
config.appVersion = config.appVersion || '1.1.2';

super(config);
}
}

0 comments on commit 21c3054

Please sign in to comment.