Skip to content

Commit

Permalink
fix: retry for jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
vicholp committed Dec 19, 2023
1 parent 152e337 commit ab8d4c8
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 5 deletions.
21 changes: 19 additions & 2 deletions app/Jobs/Art/MinimizeArtJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@ class MinimizeArtJob implements ShouldQueue
use Queueable;
use SerializesModels;

/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 3;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(
private string $source_path, private string $target_path, private int $height, private int $width, private int $quality = 80
private string $sourcePath,
private string $targetPath,
private int $height,
private int $width,
private int $quality = 80
) {
//
}
Expand All @@ -34,6 +45,12 @@ public function __construct(
*/
public function handle()
{
(new ArtService())->minimizeArt($this->source_path, $this->target_path, $this->height, $this->width, $this->quality);
(new ArtService())->minimizeArt(
$this->sourcePath,
$this->targetPath,
$this->height,
$this->width,
$this->quality
);
}
}
7 changes: 7 additions & 0 deletions app/Jobs/Art/SyncArtJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class SyncArtJob implements ShouldQueue
use Queueable;
use SerializesModels;

/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 3;

/**
* Create a new job instance.
*
Expand Down
7 changes: 7 additions & 0 deletions app/Jobs/Synchronization/CheckServerTracksJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ class CheckServerTracksJob implements ShouldQueue
use Queueable;
use SerializesModels;

/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 3;

/**
* Create a new job instance.
*/
Expand Down
18 changes: 15 additions & 3 deletions app/Jobs/Synchronization/SyncAlbumFromBeetsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@ class SyncAlbumFromBeetsJob implements ShouldQueue
use Queueable;
use SerializesModels;

/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 3;

/**
* Create a new job instance.
*
* @return void
*/
public function __construct(
private Server $server,
private string $mb_id,
private string $beets_album_id,
private string $mbId,
private string $beetsAlbumId,
) {
//
}
Expand All @@ -46,6 +53,11 @@ public function handle()

$beetsService = new BeetsService($this->server);

(new SynchronizationService())->syncAlbumFromBeets($beetsService, $this->server, $this->mb_id, $this->beets_album_id);
(new SynchronizationService())->syncAlbumFromBeets(
$beetsService,
$this->server,
$this->mbId,
$this->beetsAlbumId
);
}
}
7 changes: 7 additions & 0 deletions app/Jobs/Synchronization/SyncReleaseJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class SyncReleaseJob implements ShouldQueue
use Queueable;
use SerializesModels;

/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 3;

/**
* Create a new job instance.
*
Expand Down
7 changes: 7 additions & 0 deletions app/Jobs/Synchronization/SyncServerJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ class SyncServerJob implements ShouldQueue
use Queueable;
use SerializesModels;

/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 5;

/**
* Create a new job instance.
*
Expand Down

0 comments on commit ab8d4c8

Please sign in to comment.