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:
parent
9c79267e24
commit
27f916c323
3 changed files with 13 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue