Class: Qmore::Persistence::Monitor
- Inherits:
-
Object
- Object
- Qmore::Persistence::Monitor
- Includes:
- GemLogger::LoggerSupport
- Defined in:
- lib/qmore/persistence.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#updating ⇒ Object
readonly
Returns the value of attribute updating.
Instance Method Summary collapse
-
#initialize(persistence, interval) ⇒ Monitor
constructor
from some source (redis, file, db, etc) defaults to 1 minute.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(persistence, interval) ⇒ Monitor
from some source (redis, file, db, etc) defaults to 1 minute
10 11 12 13 |
# File 'lib/qmore/persistence.rb', line 10 def initialize(persistence, interval) @persistence = persistence @interval = interval end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
5 6 7 |
# File 'lib/qmore/persistence.rb', line 5 def interval @interval end |
#updating ⇒ Object (readonly)
Returns the value of attribute updating.
5 6 7 |
# File 'lib/qmore/persistence.rb', line 5 def updating @updating end |
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/qmore/persistence.rb', line 15 def start return if @updating @updating = true # Ensure we load the configuration once from persistence before # the background thread. Qmore.configuration = @persistence.load Thread.new do while(@updating) do sleep @interval begin Qmore.configuration = @persistence.load rescue => e logger.error "#{e.class.name} : #{e.}" end end end end |
#stop ⇒ Object
35 36 37 |
# File 'lib/qmore/persistence.rb', line 35 def stop @updating = false end |