-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd63faa
commit 1df169a
Showing
4 changed files
with
67 additions
and
1 deletion.
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
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcingBundle\Listener; | ||
|
||
use Patchlevel\EventSourcing\Projection\Projectionist\Projectionist; | ||
use Symfony\Component\HttpKernel\Event\RequestEvent; | ||
use Symfony\Component\Lock\LockFactory; | ||
|
||
final class ProjectionistAutoBootListener | ||
{ | ||
public function __construct( | ||
private readonly Projectionist $projectionist, | ||
private readonly LockFactory $lockFactory, | ||
) { | ||
} | ||
|
||
public function __invoke(RequestEvent $event): void | ||
{ | ||
if (!$event->isMainRequest()) { | ||
return; | ||
} | ||
|
||
$lock = $this->lockFactory->createLock('projectionist-boot'); | ||
|
||
if (!$lock->acquire()) { | ||
return; | ||
} | ||
|
||
$this->projectionist->boot(); | ||
} | ||
} |
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