mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:14:04 +00:00
QueueTenancyBootstrapper
This commit is contained in:
parent
363b2fc56e
commit
8dc1ef61b8
2 changed files with 53 additions and 27 deletions
|
|
@ -56,7 +56,6 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
}
|
||||
|
||||
$this->registerTenantRedirectMacro();
|
||||
$this->makeQueuesTenantAware();
|
||||
}
|
||||
|
||||
public function setTelescopeTags()
|
||||
|
|
@ -88,32 +87,6 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
});
|
||||
}
|
||||
|
||||
// todo should this be a tenancybootstrapper?
|
||||
public function makeQueuesTenantAware()
|
||||
{
|
||||
$this->app['queue']->createPayloadUsing(function () {
|
||||
if (tenancy()->initialized) {
|
||||
[$uuid, $domain] = tenant()->get(['uuid', 'domain']);
|
||||
|
||||
return [
|
||||
'tenant_uuid' => $uuid,
|
||||
'tags' => [
|
||||
"tenant:$uuid",
|
||||
"domain:$domain",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
});
|
||||
|
||||
$this->app['events']->listen(\Illuminate\Queue\Events\JobProcessing::class, function ($event) {
|
||||
if (\array_key_exists('tenant_uuid', $event->job->payload())) {
|
||||
tenancy()->initById($event->job->payload()['tenant_uuid']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue