dshoreman / servidor

A modern web application for managing servers
GNU Lesser General Public License v2.1
9 stars 11 forks source link

Creation Event Chaining #383

Open dshoreman opened 3 years ago

dshoreman commented 3 years ago

Currently the project's app/redirect listeners are dumped in an array and they all get triggered at once on the saved model event: https://github.com/dshoreman/servidor/blob/bdb9e1c5a601d324fe7dbbf1e8194547f2981097/app/Projects/Application.php#L68-L69 https://github.com/dshoreman/servidor/blob/bdb9e1c5a601d324fe7dbbf1e8194547f2981097/app/Projects/Redirect.php#L40-L41 https://github.com/dshoreman/servidor/blob/bdb9e1c5a601d324fe7dbbf1e8194547f2981097/app/Providers/EventServiceProvider.php#L18-L28

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

dshoreman commented 3 years ago

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