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 initializedbefore :push: executed before a message is pushed to the queueafter :push: executed after a message has been pushed to the queuebefore :pop: executed before a message is popped from the queueafter :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 queueafter :peek: executed after peeking to a message in the queuebefore :range: executed before peeking to a message range in the queueafter :range: executed after peeking to a message range in the queuebefore :clear: executed before clearing the queueafter :clear: executed after clearing the queuebefore :delete: executed before deleting the queueafter :delete: executed after deleting the queuebefore :refill: executed before refilling the queueafter :refill: executed after refilling the queuebefore :revive: executed before reviving a message from the dead queueafter :revive: executed after reviving a message from the dead queuebefore :schedule: executed before scheduling messages for retryafter :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 |