Class: VSM::Homeostat

Inherits:
Object
  • Object
show all
Defined in:
lib/vsm/homeostat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHomeostat

Returns a new instance of Homeostat.



6
7
8
9
# File 'lib/vsm/homeostat.rb', line 6

def initialize
  @limits = { tokens: 8_000, time_ms: 15_000, bytes: 2_000_000 }
  @usage  = Hash.new(0)
end

Instance Attribute Details

#limitsObject (readonly)

Returns the value of attribute limits.



4
5
6
# File 'lib/vsm/homeostat.rb', line 4

def limits
  @limits
end

Instance Method Details

#alarm?(message) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/vsm/homeostat.rb', line 15

def alarm?(message)
  message.meta&.dig(:severity) == :algedonic
end

#usage_snapshotObject



11
12
13
# File 'lib/vsm/homeostat.rb', line 11

def usage_snapshot
  @usage.dup
end