-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow subclasses to inherit more resque-retry configuration #129
Comments
Some information should already be passed on through class inheritance. Can you please explain what the problem is with the existing support? |
I feel a bit confused on how the inheritance should work... but since the config variables are defined as class instance variables, it doesn't seem like they are getting inherited? In particular, this doesn't work for
|
We copy a number of class instance-variables to the receiver in the |
I think You could use the module JobRetryDefaults
def retry_limit
@retry_limit ||= 64
end
def retry_exceptions
@retry_exceptions ||= [RuntimeError, Exception]
end
end
class JobExample
extend Resque::Plugins::Retry
extend JobRetryDefaults
@queue = :somequeue
# override defaults
@retry_exceptions = [Timeout::Error]
def self.perform(*args)
# do work
end
end |
It seems like right now we support both. Perhaps we should just buff up the
|
Should we be copying any instance vars at all? It seems a bit 'magic' to me, different to what happens with vanilla Ruby. Resque does not copy over the It is possible to implement this type 'job defaults' yourself, without a lot of code. If we copied over all instance vars
|
My vote would be for all or none. If |
My gut tells me we don't need the We can always add a short example of how you can configure job defaults. |
Hey, just wanted to let you know that I actually fell into that pit today. I assumed my base class instance variables would be picked up in subclasses, but actually they are not. So you would propose to overwrite the corresponding methods (e.g. class MyBaseClass
extend Resque::Plugins::ExponentialBackoff
class << self
def retry_exceptions
# subclass could still override this method or set the instance variable
@retry_exceptions ||= [DefaultRetryException]
end
end
end |
At work, we are using a
ResqueBase
class that all of our Resque jobs derive from. It would be great to be able to configure some resque-retry information there, so that we can have "defaults" that all of our resque jobs automatically inherit, but can override if desired.Either (A) we automatically inherit more resque-retry options (but I think this is a bit of a breaking change). Or (B) we add the ability for the user to specify which options should be inherited. e.g.,
What do you think? If it sounds reasonable the implementation is pretty straightforward.
The text was updated successfully, but these errors were encountered: