Module: Karafka::Pro::Routing::Features::Delaying::Topic
- Defined in:
- lib/karafka/pro/routing/features/delaying/topic.rb
Overview
Topic delaying API extensions
Instance Method Summary collapse
-
#delay_by ⇒ Object
Just an alias for nice API.
-
#delaying(delay = nil) ⇒ Object
-
#delaying? ⇒ Boolean
Is a given job delaying.
-
#initialize ⇒ Object
This method calls the parent class initializer and then sets up the extra instance variable to nil.
-
#to_h ⇒ Hash
Topic with all its native configuration options plus delaying.
Instance Method Details
#delay_by ⇒ Object
Just an alias for nice API
38 39 40 |
# File 'lib/karafka/pro/routing/features/delaying/topic.rb', line 38 def delay_by(*) (*) end |
#delaying(delay = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/karafka/pro/routing/features/delaying/topic.rb', line 23 def (delay = nil) # Those settings are used for validation @delaying ||= begin config = Config.new(active: !delay.nil?, delay: delay) if config.active? factory = ->(*) { Pro::Processing::Filters::Delayer.new(delay) } filter(factory) end config end end |
#delaying? ⇒ Boolean
Returns is a given job delaying.
43 44 45 |
# File 'lib/karafka/pro/routing/features/delaying/topic.rb', line 43 def .active? end |
#initialize ⇒ Object
This method calls the parent class initializer and then sets up the extra instance variable to nil. The explicit initialization to nil is included as an optimization for Ruby’s object shapes system, which improves memory layout and access performance.
17 18 19 20 |
# File 'lib/karafka/pro/routing/features/delaying/topic.rb', line 17 def initialize(...) super @delaying = nil end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus delaying.
48 49 50 51 52 |
# File 'lib/karafka/pro/routing/features/delaying/topic.rb', line 48 def to_h super.merge( delaying: .to_h ).freeze end |