Class: Siding::Staleness::Events
- Inherits:
-
Object
- Object
- Siding::Staleness::Events
- Defined in:
- lib/siding/staleness.rb
Defined Under Namespace
Classes: Event
Constant Summary collapse
- LIMIT =
50- COMPACT_AT =
When the file is rewritten rather than appended to. Rewriting on every record would turn a short append into a full read-modify-write for no benefit.
LIMIT * 4
Instance Method Summary collapse
-
#initialize(limit: LIMIT, path: nil) ⇒ Events
constructor
A new instance of Events.
- #last ⇒ Object
- #record(verdict, resolution: nil, developer_wait: nil, at: Time.now) ⇒ Object
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
Instance Method Details
#last ⇒ Object
156 |
# File 'lib/siding/staleness.rb', line 156 def last = @mutex.synchronize { @events.last } |
#record(verdict, resolution: nil, developer_wait: nil, at: Time.now) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/siding/staleness.rb', line 142 def record(verdict, resolution: nil, developer_wait: nil, at: Time.now) event = Event.new(at: at, reason: verdict.reasons.first, trigger_paths: verdict.trigger_paths, resolution: resolution || verdict.resolution, developer_wait: developer_wait) @mutex.synchronize do @events << event @events.shift while @events.size > @limit end persist(event) event end |
#size ⇒ Object
157 |
# File 'lib/siding/staleness.rb', line 157 def size = @mutex.synchronize { @events.size } |
#to_a ⇒ Object
155 |
# File 'lib/siding/staleness.rb', line 155 def to_a = @mutex.synchronize { @events.dup } |