Skip to content

Commit

Permalink
return RateLimiter after test
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Aug 20, 2024
1 parent e955229 commit c633997
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/Jobs/RunMdaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Jobs;

use App\Models\Federation;
use App\Services\FederationService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
Expand Down Expand Up @@ -71,11 +72,11 @@ public function handle(): void
* Get the middleware the job should pass through.
*
* @return array<int, object>
* @throws \Exception
*/
public function middleware(): array
{
$diskName = config('storageCfg.name');
$pathToDirectory = Storage::disk($diskName)->path($this->federation->name);
$pathToDirectory = FederationService::getFederationFolder($this->federation);
$lockKey = 'directory-'.md5($pathToDirectory).'-lock';

return [
Expand Down
9 changes: 4 additions & 5 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Jobs\RunMdaScript;
use App\Services\CategoryTagService;
use App\Services\FederationService;
use App\Services\HfdTagService;
use App\Services\RsTagService;
use Illuminate\Cache\RateLimiting\Limit;
Expand Down Expand Up @@ -47,13 +48,11 @@ public function boot()
// Mail::alwaysTo('[email protected]');
Model::preventLazyLoading();
}
//TODO comment this for testing part
/* RateLimiter::for('mda-run-limit', function (RunMdaScript $job) {
$diskName = config('storageCfg.name');
$pathToDirectory = Storage::disk($diskName)->path($job->federation->name);
RateLimiter::for('mda-run-limit', function (RunMdaScript $job) {
$pathToDirectory = FederationService::getFederationFolder($job->federation);
$lockKey = 'directory-'.md5($pathToDirectory).'-lock';
return Limit::perMinute(1)->by($lockKey);
});*/
});

}
}

0 comments on commit c633997

Please sign in to comment.