Skip to content

Commit

Permalink
Rework Discord Rate Limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
CalumTowers committed Jun 29, 2024
1 parent 4d5128d commit b1c0159
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/Jobs/Mship/SyncToDiscord.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class SyncToDiscord extends Job implements ShouldQueue

public $tries = 3;

public $backoff = 60;

public $queue = 'discord';

public function __construct(Account $account)
{
$this->account = $account;
Expand Down
4 changes: 3 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public function boot()
});

RateLimiter::for('discord-sync', function (object $job) {
return Limit::perHour(1)->by($job->getAccountId());
return Limit::perMinute(100)
->perHour(1000)
->by('discord-api-call');
});

Cookies::essentials()
Expand Down
4 changes: 2 additions & 2 deletions config/horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
'production' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['high', 'default'],
'queue' => ['high', 'default', 'discord'],
'balance' => 'auto',
'min-processes' => 2,
'max-processes' => 14,
Expand All @@ -184,7 +184,7 @@
'local' => [
'1' => [
'connection' => 'redis',
'queue' => ['high', 'default'],
'queue' => ['high', 'default', 'discord'],
'balance' => 'simple',
'processes' => 1,
'tries' => 10,
Expand Down

0 comments on commit b1c0159

Please sign in to comment.