dshoreman / servidor

A modern web application for managing servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creation Event Chaining

dshoreman opened this issue · comments

Currently the project's app/redirect listeners are dumped in an array and they all get triggered at once on the saved model event:

protected $dispatchesEvents = [
'saved' => ProjectAppSaved::class,

protected $dispatchesEvents = [
'saved' => ProjectRedirectSaved::class,

protected $listen = [
ProjectAppSaved::class => [
CreateSystemUser::class,
ApplyAppNginxConfig::class,
DeployApp::class,
ReloadNginxService::class,
],
ProjectRedirectSaved::class => [
ApplyRedirectNginxConfig::class,
ReloadNginxService::class,
],

While there's nothing inherently wrong with that--creating a project still happens in order--it would be better if actions were queued individually, independent of the model's saved event.

We essentially need a single event (I think) that saved would trigger. That event would be responsible for queuing any subsequent actions (jobs?) that need to happen.

Related: https://laravel.com/docs/8.x/queues#job-chaining

TIL! Re jobs/actions, see spatie/laravel-queueable-action. Should make life a bit easier...

ezoic increase your site revenue