Last active
October 28, 2020 08:29
-
-
Save kinnalru/2ebb83e4faa2fa3ef4dd60091bc15d5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DelayedJobPlugin | |
attr_reader :limiter, :dj | |
def initialize(limiter_klass:, **opts) | |
@limiter = limiter_klass.new(opts) | |
end | |
# Delayed::Worker вызовет new без агрументов у каждого плагина | |
def new(*_args) | |
configure_lifecycle(Delayed::Worker.lifecycle) | |
end | |
def configure_lifecycle lifecycle | |
lifecycle.after(:perform) do |worker, *_args| | |
worker.stop if limiter.check | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment