Class: Karafka::Pro::ScheduledMessages::MaxEpoch
- Inherits:
-
Object
- Object
- Karafka::Pro::ScheduledMessages::MaxEpoch
- Defined in:
- lib/karafka/pro/scheduled_messages/max_epoch.rb
Overview
Simple max value accumulator. When we dispatch messages we can store the max timestamp until which messages were dispatched by us. This allows us to quickly skip those messages during recovery, because we do know, they were dispatched.
Instance Method Summary collapse
-
#initialize ⇒ MaxEpoch
constructor
A new instance of MaxEpoch.
-
#to_i ⇒ Integer
Max epoch recorded.
-
#update(new_max) ⇒ Object
Updates epoch if bigger than current max.
Constructor Details
#initialize ⇒ MaxEpoch
Returns a new instance of MaxEpoch.
21 22 23 |
# File 'lib/karafka/pro/scheduled_messages/max_epoch.rb', line 21 def initialize @max = -1 end |
Instance Method Details
#to_i ⇒ Integer
Returns max epoch recorded.
35 36 37 |
# File 'lib/karafka/pro/scheduled_messages/max_epoch.rb', line 35 def to_i @max end |
#update(new_max) ⇒ Object
Updates epoch if bigger than current max
27 28 29 30 31 32 |
# File 'lib/karafka/pro/scheduled_messages/max_epoch.rb', line 27 def update(new_max) return unless new_max return unless new_max > @max @max = new_max end |