ava-innersource / Liquid-Application-Framework-1.0-deprecated

Liquid is a framework to speed up the development of microservices
MIT License
25 stars 13 forks source link

Remove LightBackgroundTask #88

Open bruno-brant opened 4 years ago

bruno-brant commented 4 years ago

There's no clear purpose for LightBackgroundTask.

One one hand, it's a simple implementation of IHostedService, with little functionality added (looped executing of ProcessAsyncwhile !IsCancellationRequested, it seems). There's no need to provide a base class for this kind of functionality. The implementation also has a number of pitfalls (ProcessAsync will be called in parallel, a derived class can reimplement IHostedService methods since they weren't sealed, the Cancel call won't stop the executing thread, etc.

On the other, scheduled functions are better managed by a external scheduler. Liquid is designed to be run in containers, where we expect multiple instances of each service. A background task such as this will end up running in every container, indiscriminately, which usually isn't what the author intended; also, the container manager may terminate a controller for a multiple number of reasons, and this background task will be stopped.

I think we should remove this from future version as it's clutter and not related to Liquid's core functionality (API/microservices).