Use a queue for fixing missing matches

This commit is contained in:
Jonathan Cremin 2018-04-08 22:39:50 +01:00
parent 3428986268
commit 3876a85a73
3 changed files with 30 additions and 33 deletions

View file

@ -22,7 +22,7 @@ export function* lookupId(id, type) {
const result = results[0];
if (!result || !result.Error) {
if (!result || result.Error) {
return { service: 'amazon' };
}
@ -68,7 +68,7 @@ export function* lookupId(id, type) {
return { service: 'amazon' };
}
export function* search(data, original = {}) {
export function* search(data) {
try {
const type = data.type;
const results = yield client.itemSearch({
@ -80,7 +80,7 @@ export function* search(data, original = {}) {
const result = results[0];
if (!result || !result.Error) {
if (!result || result.Error) {
return { service: 'amazon' };
}
@ -122,6 +122,10 @@ export function* search(data, original = {}) {
}
} catch (err) {
debug(inspect(err, { depth: 4 }));
if (err[0].Error[0].Code[0] === 'RequestThrottled') {
debug('Rate Limited');
throw err;
}
}
return { service: 'amazon' };
}