Merge branch 'develop' into trunk
This commit is contained in:
commit
4a90b4bc22
6 changed files with 9 additions and 73 deletions
|
|
@ -10,7 +10,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Spatie\RateLimitedMiddleware\RateLimited;
|
||||
|
||||
class SetServiceStats implements ShouldQueue
|
||||
{
|
||||
|
|
@ -19,6 +18,8 @@ class SetServiceStats implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private const KEY = '2202020';
|
||||
|
||||
// Set high max tries as using prevent overlap
|
||||
public $tries = 40;
|
||||
|
||||
|
|
@ -64,13 +65,8 @@ class SetServiceStats implements ShouldQueue
|
|||
|
||||
public function middleware()
|
||||
{
|
||||
$rateLimitedMiddleware = (new RateLimited())
|
||||
->allow(4)
|
||||
->everySeconds(1)
|
||||
->releaseAfterSeconds(rand(90, 180));
|
||||
return [
|
||||
$rateLimitedMiddleware,
|
||||
(new WithoutOverlapping($this->service->id))
|
||||
(new WithoutOverlapping(self::KEY))
|
||||
->releaseAfter(rand(90, 180))
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ class StartStatJobs implements ShouldQueue
|
|||
$brands = Brand::all();
|
||||
foreach ($brands as $brand) {
|
||||
\dispatch(new StatJob($brand))
|
||||
->onConnection('redis')
|
||||
->onQueue('stats')->delay(rand(0, 90));
|
||||
->delay(rand(0, 90));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class Service extends Model
|
|||
public function incrementStat(): void
|
||||
{
|
||||
SetServiceStats::dispatch($this)->afterResponse()
|
||||
->onConnection('redis')->onQueue('stats');
|
||||
->onConnection('database')->onQueue('stats');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@
|
|||
"league/csv": "^9.7",
|
||||
"propaganistas/laravel-phone": "^4.3",
|
||||
"rennokki/laravel-eloquent-query-cache": "^3.0",
|
||||
"spatie/laravel-mix-preload": "^1.2",
|
||||
"spatie/laravel-rate-limited-job-middleware": "^1.5"
|
||||
"spatie/laravel-mix-preload": "^1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"facade/ignition": "^2.5",
|
||||
|
|
|
|||
62
composer.lock
generated
62
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "cac9cff057e02f69a5e32aa8ca5174d4",
|
||||
"content-hash": "b30f8f73c987d9919c31de484b03b3ef",
|
||||
"packages": [
|
||||
{
|
||||
"name": "arondeparon/laravel-request-sanitizer",
|
||||
|
|
@ -4058,66 +4058,6 @@
|
|||
],
|
||||
"time": "2021-01-04T08:01:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/laravel-rate-limited-job-middleware",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-rate-limited-job-middleware.git",
|
||||
"reference": "7b72592e0d823e2948c413f5e661de0fd3431db5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-rate-limited-job-middleware/zipball/7b72592e0d823e2948c413f5e661de0fd3431db5",
|
||||
"reference": "7b72592e0d823e2948c413f5e661de0fd3431db5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/redis": "^6.0|^7.0|^8.0",
|
||||
"php": "^7.3|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.4",
|
||||
"orchestra/testbench": "^4.0|^5.0|^6.0",
|
||||
"phpunit/phpunit": "^8.2|^9.0",
|
||||
"symfony/var-dumper": "^4.3|^5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\RateLimitedMiddleware\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A middleware that can rate limit jobs",
|
||||
"homepage": "https://github.com/spatie/laravel-rate-limited-job-middleware",
|
||||
"keywords": [
|
||||
"laravel-rate-limited-job-middleware",
|
||||
"spatie"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/laravel-rate-limited-job-middleware/issues",
|
||||
"source": "https://github.com/spatie/laravel-rate-limited-job-middleware/tree/1.5.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.patreon.com/spatie",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2020-11-27T09:36:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v6.2.7",
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class RepairStatsJobs extends Migration
|
|||
foreach ($jobs as $job) {
|
||||
$payload = json_decode($job->payload);
|
||||
if ($payload->displayName === SetServiceStats::class) {
|
||||
$jobIDS[] = $job->id;
|
||||
|
||||
$ref = new ReflectionProperty(SetServiceStats::class, 'service');
|
||||
$ref->setAccessible(true);
|
||||
$service = $ref->getValue(unserialize($payload->data->command));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue