My most common use of sidekiq is
foo.delay.my_method(1,2,3)
This is pretty safe for most things, but it would be more ideal and efficient in some ways to have the worker pull out the object again and then invoke.
class FooMyMethodDoer
include Sidekiq::Worker
def perform(id,a,b,c)
foo = Foo.find(id)
foo.my_method(a,b,c)
end
end
So, one could make some sort of generic worker for this
class MethodInvoker
include Sidekiq::Worker
def perform(class_name, id, method_name, *params)
object = class_name.constantize.find(id)
object.method(method_name.to_sym).run(params)
end
end
(I haven't tried that, I may have gotten something slightly off)
Would be nice to have some syntactic sugar for that, so instead of instantiating a worker in one's code all the time, one could just do:
foo.delay_awesomely(:my_method, 1,2,3)
Thoughts?
My most common use of sidekiq is
This is pretty safe for most things, but it would be more ideal and efficient in some ways to have the worker pull out the object again and then invoke.
So, one could make some sort of generic worker for this
(I haven't tried that, I may have gotten something slightly off)
Would be nice to have some syntactic sugar for that, so instead of instantiating a worker in one's code all the time, one could just do:
Thoughts?