yii2-queue icon indicating copy to clipboard operation
yii2-queue copied to clipboard

Stoppable behavior

Open zhuravljov opened this issue 8 years ago • 6 comments

Related #87.

The code is simple and anyone can create it inside own project. But maybe need to create abstract class which will include stopping logics, and cache component should be moved into child?

zhuravljov avatar Jul 29 '17 16:07 zhuravljov

This wont work when your dealing with EA filecache and 2 different services, It requires to that the runner and pusher use the same cache instance.

TerraSkye avatar Jul 29 '17 17:07 TerraSkye

@TerraSkye, you are right, cache must use common storage only.

zhuravljov avatar Jul 29 '17 17:07 zhuravljov

This wont work when your dealing with EA filecache and 2 different services, It requires to that the runner and pusher use the same cache instance.

could be added as a note to the phpdoc.

cebe avatar Jul 30 '17 23:07 cebe

How about unit tests?

samdark avatar Aug 27 '17 11:08 samdark

@samdark, tests have been added.

zhuravljov avatar Aug 27 '17 12:08 zhuravljov

I don't like this approach at all.

  • There is no guarantee they will actually be stopped (a cache is not persistent reliable storage).
  • It uses the cache as some kind of quick storage, that is not what it is for.
  • If the cache is not reachable for whatever reason, all workers will stop working.
  • Several drivers already implement remove() (file, db, beanstalk, redis).

The exceptions here are amqp and gearman.

In the cases where you use amqp / gearman and you have multiple workers, you will need a shared cache. If you are on the same host then you could use files storage, but in that case you could just as well use the file queue driver since you're depending on the file system anyway. If you're on different hosts you'll probably end up using a cache driver like redis or memcache; in which case you could just as well use redis for your queue in the first place.

As OP mentioned, implementing it in your own project is simple. Since this (in my opinion) is hardly ever the best, or even a good, solution I think adding this behavior will result in worse decisions by developers.

SamMousa avatar May 23 '18 13:05 SamMousa