Class: PumaAutoTune::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/puma_auto_tune/memory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master = PumaAutoTune::Master.new) ⇒ Memory

Returns a new instance of Memory.



8
9
10
# File 'lib/puma_auto_tune/memory.rb', line 8

def initialize(master = PumaAutoTune::Master.new)
  @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



6
7
8
# File 'lib/puma_auto_tune/memory.rb', line 6

def master
  @master
end

#workersObject

Returns the value of attribute workers.



6
7
8
# File 'lib/puma_auto_tune/memory.rb', line 6

def workers
  @workers
end

Instance Method Details

#amountObject



16
17
18
19
20
21
# File 'lib/puma_auto_tune/memory.rb', line 16

def amount
  @mb ||= begin
    worker_memory = workers.map {|w| w.memory }.inject(&:+) || 0
    worker_memory + @master.get_memory
  end
end

#largest_workerObject



23
24
25
# File 'lib/puma_auto_tune/memory.rb', line 23

def largest_worker
  workers.last
end

#nameObject



12
13
14
# File 'lib/puma_auto_tune/memory.rb', line 12

def name
  "resource_ram_mb"
end

#resetObject



35
36
37
38
39
# File 'lib/puma_auto_tune/memory.rb', line 35

def reset
  raise "must set master" unless @master
  @workers      = nil
  @mb           = nil
end

#smallest_workerObject



27
28
29
# File 'lib/puma_auto_tune/memory.rb', line 27

def smallest_worker
  workers.first
end