Module: Falqon::Hooks
Overview
Hooks can be registered on a custom queue to execute code before and after certain events. The following hooks are available:
-
after :initialize: executed after the queue has been initialized
-
before :push: executed before a message is pushed to the queue
-
after :push: executed after a message has been pushed to the queue
-
before :pop: executed before a message is popped from the queue
-
after :pop: executed after a message has been popped from the queue (but before deleting it)
-
before :peek: executed before peeking to a message in the queue
-
after :peek: executed after peeking to a message in the queue
-
before :range: executed before peeking to a message range in the queue
-
after :range: executed after peeking to a message range in the queue
-
before :clear: executed before clearing the queue
-
after :clear: executed after clearing the queue
-
before :delete: executed before deleting the queue
-
after :delete: executed after deleting the queue
-
before :refill: executed before refilling the queue
-
after :refill: executed after refilling the queue
-
before :revive: executed before reviving a message from the dead queue
-
after :revive: executed after reviving a message from the dead queue
-
before :schedule: executed before scheduling messages for retry
-
after :schedule: executed after scheduling messages for retry
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
48 49 50 |
# File 'lib/falqon/concerns/hooks.rb', line 48 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#run_hook(event, type = nil, &block) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/falqon/concerns/hooks.rb', line 54 def run_hook(event, type = nil, &block) T.unsafe(self).class.hooks[event][:before].each { |hook| instance_eval(&hook) } if type.nil? || type == :before block&.call T.unsafe(self).class.hooks[event][:after].each { |hook| instance_eval(&hook) } if type.nil? || type == :after end |