Passing an object as an argument to Resque-Worker

Is there a way to pass an object as an argument value to a Resque-worker.

I want to do something like this Resque.enqueue(SomeWorker, obj) instead of Resque.enqueue(SomeWorker, id) . My object has a different type that does not have an identifier.

Appreciate any help.

+6
source share
1 answer

as best practice, you should never transfer a real object to an employee.

The idea is that you transfer a minimum of information to your employee, idealize the identifier so that the employee can receive all the remaining information.

since the data is stored in redis, you really need to somehow marshal your object in its order, and then disable it when the worker retrieves the data.

if your object just holds some data, you should consider passing this as a hash, because it is easily stored in redis.

+12
source

Source: https://habr.com/ru/post/906860/


All Articles