Class: VSM::Lens::Stats
- Inherits:
-
Object
- Object
- VSM::Lens::Stats
- Defined in:
- lib/vsm/lens/stats.rb
Instance Method Summary collapse
-
#initialize(hub:, capsule:) ⇒ Stats
constructor
A new instance of Stats.
- #state ⇒ Object
Constructor Details
#initialize(hub:, capsule:) ⇒ Stats
Returns a new instance of Stats.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/vsm/lens/stats.rb', line 7 def initialize(hub:, capsule:) @sessions = Hash.new { |h,k| h[k] = { count: 0, last: nil, kinds: Hash.new(0) } } @kinds = Hash.new(0) @capsule = capsule queue, snapshot = hub.subscribe snapshot.each { |ev| ingest(ev) } @thread = Thread.new do loop do ev = queue.pop ingest(ev) end end end |
Instance Method Details
#state ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vsm/lens/stats.rb', line 23 def state { ts: Time.now.utc.iso8601(6), sessions: sort_sessions(@sessions), kinds: @kinds.dup, tools: tool_inventory, budgets: { limits: @capsule.homeostat.limits, usage: @capsule.homeostat.usage_snapshot } } end |