Skip to content

Commit 081c83d

Browse files
committed
Cleanup and resoving deprecated issues in async module.
1 parent 83a7000 commit 081c83d

12 files changed

Lines changed: 17 additions & 23 deletions

app/async/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function unschedule(AsyncJob $job): bool
8484

8585
try {
8686
$rows = 0;
87-
$this->entityManager->transactional(function ($em) use ($job, &$rows) {
87+
$this->entityManager->wrapInTransaction(function ($em) use ($job, &$rows) {
8888
$qb = $em->createQueryBuilder();
8989
$qb->delete(AsyncJob::class, 'aj')
9090
->where($qb->expr()->isNull("aj.startedAt"))

app/async/IAsyncJobHandler.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace App\Async;
44

55
use App\Model\Entity\AsyncJob;
6-
use Nette\Utils\Arrays;
7-
use Nette;
86

97
/**
108
* Interface implemented by all asynchronous job handlers.
@@ -25,14 +23,14 @@ public function getId(): string;
2523
public function checkArgs(array $args): bool;
2624

2725
/**
28-
* The main method of the async job does what the job is ment to do.
26+
* The main method of the async job does what the job is meant to do.
2927
* @param AsyncJob $job entity to be executed
3028
*/
3129
public function execute(AsyncJob $job);
3230

3331
/**
3432
* Called by signal handler to terminate the job asap (but gracefully).
35-
* If the job is not interruptable, this function should be implemented with empty body.
33+
* If the job is not interrupt-able, this function should be implemented with empty body.
3634
*/
3735
public function cancel(): void;
3836
}

app/async/Notify.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Notify
1919
*/
2020
public static function isAvailable(): bool
2121
{
22-
$requirements = [ 'inotify_init', 'inotify_add_watch', 'inotify_read', 'inotify_queue_len', 'stream_select' ];
22+
$requirements = ['inotify_init', 'inotify_add_watch', 'inotify_read', 'inotify_queue_len', 'stream_select'];
2323
foreach ($requirements as $reqFnc) {
2424
if (!function_exists($reqFnc)) {
2525
return false;
@@ -118,7 +118,7 @@ public function isNotified(): bool
118118
}
119119

120120
/**
121-
* Wait (block) until a nofitication is risen or timeout is breached.
121+
* Wait (block) until a notification is risen or timeout is breached.
122122
* @param int $timeout maximal waiting time in seconds
123123
* @return bool true if notifications were collected, false on timeout
124124
* @throws LogicException
@@ -136,7 +136,7 @@ public function waitForNotification(int $timeout = 1): bool
136136
);
137137
}
138138

139-
$streams = [ $this->inotifyStream ];
139+
$streams = [$this->inotifyStream];
140140
@stream_select($streams, $streams, $streams, $timeout); // will block until event or timeout
141141
return $this->isNotifiedInternal();
142142
}

app/async/Worker.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Worker
5656
private $timeToRestart = null;
5757

5858
/**
59-
* @var int number of jobs remainig to process (once it reaches zero, the worker terminates so it can be restarted)
59+
* @var int number of jobs remaining to process (once it reaches zero, the worker terminates so it can be restarted)
6060
*/
6161
private $jobsRemaining = 1;
6262

@@ -93,7 +93,7 @@ public function __construct(array $config, Dispatcher $dispatcher, AsyncJobs $as
9393

9494
$this->quiet = (bool)Arrays::get($config, "quiet", false);
9595

96-
// setup signal handling (try to terminate gracefuly on these signals)
96+
// setup signal handling (try to terminate gracefully on these signals)
9797
if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
9898
pcntl_async_signals(true);
9999
pcntl_signal(SIGINT, [$this, 'terminate']);
@@ -112,7 +112,7 @@ public function terminate(): void
112112

113113
/**
114114
* Test whether the worker shall process jobs further, or whether it should go for restart.
115-
* @return bool true if it shoud continue
115+
* @return bool true if it should continue
116116
*/
117117
private function shallContinue(): bool
118118
{
@@ -195,7 +195,7 @@ private function dispatchJob(AsyncJob $job)
195195
);
196196
}
197197

198-
// we need to relaod the job since the dispatcher might cleared the caches...
198+
// we need to reload the job since the dispatcher might cleared the caches...
199199
$jobReloaded = $this->asyncJobs->get($id);
200200
if ($jobReloaded) {
201201
if ($error) {
@@ -209,12 +209,12 @@ private function dispatchJob(AsyncJob $job)
209209

210210
/**
211211
* Main method of the worker that actually processes the async job.
212-
* This method is blockinig, once it terminates the worker process should also terminate.
212+
* This method is blocking, once it terminates the worker process should also terminate.
213213
* @param string $workerId identifier of the worker (should be gathered from the CLI arguments)
214214
*/
215215
public function run(string $workerId)
216216
{
217-
$this->notify->init(); // start listeining for notifications
217+
$this->notify->init(); // start listening for notifications
218218

219219
while ($this->shallContinue()) { // just a precaution so the worker will not run forever
220220
// allocate and mark the best suitable job (null = none available)

app/async/handlers/AssignmentNotificationJobHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
use App\Model\Entity\AsyncJob;
66
use App\Model\Entity\User;
77
use App\Model\Entity\Assignment;
8-
use App\Model\Repository\Assignments;
98
use App\Async\IAsyncJobHandler;
109
use App\Async\Dispatcher;
1110
use App\Helpers\Notifications\AssignmentEmailsSender;
12-
use InvalidArgumentException;
1311

1412
/**
1513
* Scheduled job that sends email notifications when the assignment becomes visible.

app/async/handlers/PingAsyncJobHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public static function dispatchAsyncJob(Dispatcher $dispatcher, ?User $user): As
4444

4545
public function cancel(): void
4646
{
47-
// ping is not interruptable, nothing to do here
47+
// ping is not interrupt-able, nothing to do here
4848
}
4949
}

app/exceptions/ConfigException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Nette\Http\IResponse;
77

88
/**
9-
* Exception concerning core module confugration.
9+
* Exception concerning core module configuration.
1010
*/
1111
class ConfigException extends ApiException
1212
{

app/exceptions/ExerciseCompilationException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
class ExerciseCompilationException extends ApiException
1212
{
13-
1413
/**
1514
* Create instance with further description.
1615
* @param string $msg description

app/exceptions/ExerciseCompilationSoftException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
class ExerciseCompilationSoftException extends ExerciseCompilationException
1212
{
13-
1413
/**
1514
* Constructor.
1615
* @param string $msg description

app/exceptions/FrontendErrorMappings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FrontendErrorMappings
1919
public const E400_004__UPLOADED_FILE_INVALID_SIZE = "400-004";
2020
/** Per-partes upload is not completed yet */
2121
public const E400_005__UPLOADED_FILE_PARTIAL = "400-005";
22-
/** Entity version is too old (concurrent edits occured) */
22+
/** Entity version is too old (concurrent edits occurred) */
2323
public const E400_010__ENTITY_VERSION_TOO_OLD = "400-010";
2424

2525
/** Invalid credentials */

0 commit comments

Comments
 (0)