-
-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update queue service to include web worker
- Loading branch information
1 parent
a68aaeb
commit 2bce7b6
Showing
5 changed files
with
76 additions
and
5 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
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,48 @@ | ||
<?php | ||
|
||
namespace Leantime\Domain\Queue\Workers; | ||
|
||
use GuzzleHttp\Exception\GuzzleException; | ||
use Leantime\Core\Mailer; | ||
use Leantime\Domain\Queue\Repositories\Queue; | ||
use Leantime\Domain\Setting\Repositories\Setting; | ||
use Leantime\Domain\Users\Repositories\Users; | ||
use GuzzleHttp\Client; | ||
use PHPUnit\Exception; | ||
|
||
class DefaultWorker | ||
{ | ||
public function __construct( | ||
private Users $userRepo, | ||
private Setting $settingsRepo, | ||
private Queue $queue, | ||
private Client $client | ||
) { | ||
} | ||
|
||
public function handleQueue($messages) | ||
{ | ||
|
||
|
||
foreach ($messages as $message) { | ||
try { | ||
$payload = unserialize($message['message']); | ||
$subjectClass = $message['subject']; | ||
|
||
$jobClass = app()->make($subjectClass); | ||
|
||
$result = $jobClass->handle($payload); | ||
|
||
if ($result) { | ||
$this->queue->deleteMessageInQueue($message['msghash']); | ||
return true; | ||
} | ||
|
||
} catch (Exception $e) { | ||
error_log($e); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ enum Workers: string | |
{ | ||
case EMAILS = "email"; | ||
case HTTPREQUESTS = "httprequests"; | ||
|
||
case DEFAULT = "default"; | ||
} |
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