From 39eee2824bdc5ca7087c1fa8fe360f1e553ecd1a Mon Sep 17 00:00:00 2001 From: Richard McDaniel Date: Wed, 24 Apr 2024 03:09:16 +0000 Subject: [PATCH 1/2] Remove unused code --- src/Middleware/WithoutOverlappingMiddleware.php | 8 -------- src/Middleware/WorkflowMiddleware.php | 13 ------------- 2 files changed, 21 deletions(-) diff --git a/src/Middleware/WithoutOverlappingMiddleware.php b/src/Middleware/WithoutOverlappingMiddleware.php index 91aa9a6..2ab93f1 100644 --- a/src/Middleware/WithoutOverlappingMiddleware.php +++ b/src/Middleware/WithoutOverlappingMiddleware.php @@ -6,8 +6,6 @@ use Illuminate\Container\Container; use Illuminate\Contracts\Cache\Repository as Cache; -use Illuminate\Queue\Events\JobProcessing; -use Illuminate\Support\Facades\Queue; use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; @@ -31,8 +29,6 @@ class WithoutOverlappingMiddleware private $cache; - private $active = true; - public function __construct($workflowId, $type, $releaseAfter = 0, $expiresAfter = 0) { $this->key = "{$workflowId}"; @@ -47,10 +43,6 @@ public function handle($job, $next) $locked = $this->lock($job); if ($locked) { - Queue::before( - fn (JobProcessing $event) => $this->active = $job->job->getJobId() === $event->job->getJobId() - ); - Queue::stopping(fn () => $this->active ? $this->unlock($job) : null); try { $next($job); } finally { diff --git a/src/Middleware/WorkflowMiddleware.php b/src/Middleware/WorkflowMiddleware.php index 2137baf..7c69e62 100644 --- a/src/Middleware/WorkflowMiddleware.php +++ b/src/Middleware/WorkflowMiddleware.php @@ -4,28 +4,17 @@ namespace Workflow\Middleware; -use Exception; -use Illuminate\Support\Facades\Queue; use Illuminate\Support\Str; use LimitIterator; use SplFileObject; use Workflow\Events\ActivityCompleted; use Workflow\Events\ActivityFailed; use Workflow\Events\ActivityStarted; -use Workflow\Serializers\Y; final class WorkflowMiddleware { - private $active = true; - public function handle($job, $next): void { - Queue::stopping(fn () => $this->active ? $job->storedWorkflow->exceptions() - ->create([ - 'class' => $job::class, - 'exception' => Y::serialize(new Exception('Activity timed out.')), - ]) : null); - $uuid = (string) Str::uuid(); ActivityStarted::dispatch( @@ -71,8 +60,6 @@ public function handle($job, $next): void ]), now() ->format('Y-m-d\TH:i:s.u\Z')); throw $throwable; - } finally { - $this->active = false; } } } From 43775a36861c105e925347b0846d5827c375d8a1 Mon Sep 17 00:00:00 2001 From: Richard McDaniel Date: Wed, 24 Apr 2024 03:23:35 +0000 Subject: [PATCH 2/2] Remove unused code --- tests/Feature/TimeoutWorkflowTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/TimeoutWorkflowTest.php b/tests/Feature/TimeoutWorkflowTest.php index 1b389d2..eb86179 100644 --- a/tests/Feature/TimeoutWorkflowTest.php +++ b/tests/Feature/TimeoutWorkflowTest.php @@ -18,6 +18,6 @@ public function testTimeout(): void while ($workflow->running()); - $this->assertSame(2, $workflow->exceptions()->count()); + $this->assertSame(1, $workflow->exceptions()->count()); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy