Class: Karafka::Pro::ScheduledMessages::State
- Inherits:
-
Object
- Object
- Karafka::Pro::ScheduledMessages::State
- Defined in:
- lib/karafka/pro/scheduled_messages/state.rb
Overview
Represents the loading/bootstrapping state of the given topic partition
Bootstrapping can be in the following states: - fresh - when we got an assignment but we did not load the schedule yet - loading - when we are in the process of bootstrapping the daily state and we consume historical messages to build the needed schedules. - loaded - state in which we finished loading all the schedules and we can dispatch messages when the time comes and we can process real-time incoming schedules and changes to schedules as they appear in the stream.
Instance Method Summary collapse
-
#fresh? ⇒ Boolean
Are we in a fresh, pre-bootstrap state.
-
#initialize(loaded = nil) ⇒ State
constructor
A new instance of State.
-
#loaded! ⇒ Object
Marks the current state as fully loaded.
-
#loaded? ⇒ Boolean
Are we in a loaded state.
-
#to_s ⇒ String
Current state string representation.
Constructor Details
#initialize(loaded = nil) ⇒ State
Returns a new instance of State.
29 30 31 |
# File 'lib/karafka/pro/scheduled_messages/state.rb', line 29 def initialize(loaded = nil) @loaded = loaded end |
Instance Method Details
#fresh? ⇒ Boolean
Returns are we in a fresh, pre-bootstrap state.
34 35 36 |
# File 'lib/karafka/pro/scheduled_messages/state.rb', line 34 def fresh? @loaded.nil? end |
#loaded! ⇒ Object
Marks the current state as fully loaded
39 40 41 |
# File 'lib/karafka/pro/scheduled_messages/state.rb', line 39 def loaded! @loaded = true end |
#loaded? ⇒ Boolean
Returns are we in a loaded state.
44 45 46 |
# File 'lib/karafka/pro/scheduled_messages/state.rb', line 44 def loaded? @loaded == true end |
#to_s ⇒ String
Returns current state string representation.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/karafka/pro/scheduled_messages/state.rb', line 49 def to_s case @loaded when nil 'fresh' when false 'loading' when true 'loaded' end end |