Class: Harnex::Session::EventCounters

Inherits:
Object
  • Object
show all
Defined in:
lib/harnex/runtime/session.rb

Instance Method Summary collapse

Constructor Details

#initializeEventCounters

Returns a new instance of EventCounters.



13
14
15
16
17
18
19
20
# File 'lib/harnex/runtime/session.rb', line 13

def initialize
  @counts = {
    stalls: 0,
    force_resumes: 0,
    disconnections: 0,
    compactions: 0
  }
end

Instance Method Details

#record(type) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/harnex/runtime/session.rb', line 22

def record(type)
  case type.to_s
  when "log_idle"
    @counts[:stalls] += 1
  when "resume"
    @counts[:force_resumes] += 1
  when "disconnect", "disconnection"
    @counts[:disconnections] += 1
  when "compaction"
    @counts[:compactions] += 1
  end
end

#snapshotObject



35
36
37
# File 'lib/harnex/runtime/session.rb', line 35

def snapshot
  @counts.dup
end