Skip to content

Commit

Permalink
Change the delay so that we don't change the delay every 4 entities b…
Browse files Browse the repository at this point in the history
…ut instead every 240
  • Loading branch information
loevgaard committed Nov 27, 2024
1 parent 9441c0f commit 1e28702
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Processor/UploadProductVariantRequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ public function process(): void
++$i;

// According to https://api.peakwms.com/api/documentation/index.html the rate limit is 240 requests per minute
// So we will increase the delay by 1 second every 4 iterations (240 / 60 = 4)
if ($i % 4 === 0) {
$delay += 1000;
if ($i % 240 === 0) {
$delay += 60_000;
}

$this->commandBus->dispatch(new ProcessUploadProductVariantRequest($uploadProductVariantRequest), [new DelayStamp($delay)]);
$stamps = [];
if ($delay > 0) {
$stamps[] = new DelayStamp($delay);
}

$this->commandBus->dispatch(new ProcessUploadProductVariantRequest($uploadProductVariantRequest), $stamps);
}
}
}

0 comments on commit 1e28702

Please sign in to comment.