mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
Close tenant connections after jobs (#1128)
* Test that the context is central after jobs get processed * Revert to central context when jobs get processed, delete `$previousTenant` logic * Test that the tenant connections get closed after jobs get processed * Bring back the previous tenant logic * Adapt tests to the previous tenant logic * Delete assertion
This commit is contained in:
parent
bd9bbe8b41
commit
9d6356aea4
2 changed files with 32 additions and 7 deletions
|
|
@ -41,7 +41,7 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
|||
*/
|
||||
public static function __constructStatic(Application $app): void
|
||||
{
|
||||
static::setUpJobListener($app->make(Dispatcher::class), $app->runningUnitTests());
|
||||
static::setUpJobListener($app->make(Dispatcher::class));
|
||||
}
|
||||
|
||||
public function __construct(Repository $config, QueueManager $queue)
|
||||
|
|
@ -52,7 +52,7 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
|||
$this->setUpPayloadGenerator();
|
||||
}
|
||||
|
||||
protected static function setUpJobListener(Dispatcher $dispatcher, bool $runningTests): void
|
||||
protected static function setUpJobListener(Dispatcher $dispatcher): void
|
||||
{
|
||||
$previousTenant = null;
|
||||
|
||||
|
|
@ -69,10 +69,8 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
|||
});
|
||||
|
||||
// If we're running tests, we make sure to clean up after any artisan('queue:work') calls
|
||||
$revertToPreviousState = function ($event) use (&$previousTenant, $runningTests) {
|
||||
if ($runningTests) {
|
||||
static::revertToPreviousState($event, $previousTenant);
|
||||
}
|
||||
$revertToPreviousState = function ($event) use (&$previousTenant) {
|
||||
static::revertToPreviousState($event, $previousTenant);
|
||||
};
|
||||
|
||||
$dispatcher->listen(JobProcessed::class, $revertToPreviousState); // artisan('queue:work') which succeeds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue