1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 01:14:04 +00:00

end tenancy in queue if the next job is not tenant aware

This commit is contained in:
Samuel Štancl 2022-02-19 16:12:38 +01:00
parent 9c79267e24
commit 27f916c323
3 changed files with 13 additions and 3 deletions

View file

@ -75,14 +75,20 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
protected static function initializeTenancyForQueue($tenantId)
{
// The job is not tenant-aware
if (! $tenantId) {
// The job is not tenant-aware
if (tenancy()->initialized) {
// Tenancy was initialized, so we revert back to the central context
tenancy()->end();
}
return;
}
if (tenancy()->initialized) {
// Tenancy is already initialized
if (tenant()->getTenantKey() === $tenantId) {
// Tenancy is already initialized for the tenant (e.g. dispatchNow was used)
// It's initialized for the same tenant (e.g. dispatchNow was used, or the previous job also ran for this tenant)
return;
}
}