-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delay queued jobs using a random window (#87)
to prevent excessive call at time from all existing SeAT instances in the world, add some randomness to token update batches. also queue jobs related to corporation only for token having a Director role. most of corporation endpoints are requiring that role and that should reduce the amount of calls by the meantime. seed scheduler using random values overriding default scheduler at every time it's ran. to ensure all existing instance benefits of the change, we force scheduler to be seeded even if commands already exist. Related to eveseat/seat#731
- Loading branch information
Showing
9 changed files
with
214 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of SeAT | ||
* | ||
* Copyright (C) 2015 to 2020 Leon Jacobs | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
namespace Seat\Console\Bus; | ||
|
||
use Seat\Eveapi\Jobs\Alliances\Info; | ||
use Seat\Eveapi\Jobs\Alliances\Members; | ||
use Seat\Eveapi\Jobs\Contacts\Alliance\Contacts; | ||
use Seat\Eveapi\Jobs\Contacts\Alliance\Labels; | ||
use Seat\Eveapi\Models\RefreshToken; | ||
|
||
/** | ||
* Class Alliance. | ||
* | ||
* @package Seat\Console\Bus | ||
*/ | ||
class Alliance extends BusCommand | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
private $alliance_id; | ||
|
||
/** | ||
* @var \Seat\Eveapi\Models\RefreshToken | ||
*/ | ||
private $token; | ||
|
||
/** | ||
* Alliance constructor. | ||
* | ||
* @param int $alliance_id | ||
* @param \Seat\Eveapi\Models\RefreshToken $token | ||
*/ | ||
public function __construct(int $alliance_id, RefreshToken $token) | ||
{ | ||
$this->token = $token; | ||
$this->alliance_id = $alliance_id; | ||
} | ||
|
||
public function fire() | ||
{ | ||
Info::withChain([ | ||
new Members($this->alliance_id), | ||
new Labels($this->alliance_id, $this->token), | ||
new Contacts($this->alliance_id, $this->token), | ||
])->dispatch($this->alliance_id)->delay(now()->addSeconds(rand(120, 600))); | ||
// in order to prevent ESI to receive massive income of all existing SeAT instances in the world | ||
// add a bit of randomize when job can be processed - we use seconds here, so we have more flexibility | ||
// https://github.com/eveseat/seat/issues/731 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.