Module: Karafka::Pro::Routing::Features::Expiring::Topic
- Defined in:
- lib/karafka/pro/routing/features/expiring/topic.rb
Overview
Topic expiring API extensions
Instance Method Summary collapse
-
#expire_in ⇒ Object
Just an alias for nice API.
- #expiring(ttl = nil) ⇒ Object
-
#expiring? ⇒ Boolean
Is a given job expiring.
-
#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 expiring.
Instance Method Details
#expire_in ⇒ Object
Just an alias for nice API
55 56 57 |
# File 'lib/karafka/pro/routing/features/expiring/topic.rb', line 55 def expire_in(*) expiring(*) end |
#expiring(ttl = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/karafka/pro/routing/features/expiring/topic.rb', line 40 def expiring(ttl = nil) # Those settings are used for validation @expiring ||= begin config = Config.new(active: !ttl.nil?, ttl: ttl) if config.active? factory = ->(*) { Pro::Processing::Filters::Expirer.new(ttl) } filter(factory) end config end end |
#expiring? ⇒ Boolean
Returns is a given job expiring.
60 61 62 |
# File 'lib/karafka/pro/routing/features/expiring/topic.rb', line 60 def expiring? expiring.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.
34 35 36 37 |
# File 'lib/karafka/pro/routing/features/expiring/topic.rb', line 34 def initialize(...) super @expiring = nil end |
#to_h ⇒ Hash
Returns topic with all its native configuration options plus expiring.
65 66 67 68 69 |
# File 'lib/karafka/pro/routing/features/expiring/topic.rb', line 65 def to_h super.merge( expiring: expiring.to_h ).freeze end |