Class: Upr::Monitor
- Inherits:
-
Struct
- Object
- Struct
- Upr::Monitor
- Defined in:
- lib/upr/monitor.rb
Overview
Constant Summary collapse
- OPT =
nuke anything not read/updated in 60 seconds
{ :expires_in => 60 }
Instance Attribute Summary collapse
-
#moneta ⇒ Object
Returns the value of attribute moneta.
Instance Method Summary collapse
- #error!(upid) ⇒ Object
- #finish(upid) ⇒ Object
- #incr(upid, nr) ⇒ Object
-
#initialize(moneta_store = nil) ⇒ Monitor
constructor
A new instance of Monitor.
- #read(upid) ⇒ Object
- #start(upid, length) ⇒ Object
Constructor Details
#initialize(moneta_store = nil) ⇒ Monitor
Returns a new instance of Monitor.
17 18 19 20 21 22 |
# File 'lib/upr/monitor.rb', line 17 def initialize(moneta_store = nil) super if moneta_store.nil? self.moneta = Moneta.new(:Memory, :serializer => nil) end end |
Instance Attribute Details
#moneta ⇒ Object
Returns the value of attribute moneta
13 14 15 |
# File 'lib/upr/monitor.rb', line 13 def moneta @moneta end |
Instance Method Details
#error!(upid) ⇒ Object
45 46 47 48 49 |
# File 'lib/upr/monitor.rb', line 45 def error!(upid) status = moneta[upid] or return status.seen = -1 moneta.store(upid, status, OPT) end |
#finish(upid) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/upr/monitor.rb', line 38 def finish(upid) status = moneta[upid] or return status.length ||= status.seen status.seen = status.length moneta.store(upid, status, OPT) end |
#incr(upid, nr) ⇒ Object
32 33 34 35 36 |
# File 'lib/upr/monitor.rb', line 32 def incr(upid, nr) status = moneta[upid] or return status.seen += nr if status.seen >= 0 moneta.store(upid, status, OPT) end |
#read(upid) ⇒ Object
28 29 30 |
# File 'lib/upr/monitor.rb', line 28 def read(upid) moneta[upid] end |