Class: Upperkut::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/upperkut/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Manager

Returns a new instance of Manager.



9
10
11
12
13
14
15
# File 'lib/upperkut/manager.rb', line 9

def initialize(opts = {})
  self.worker = opts.fetch(:worker).constantize
  self.redis  = worker.setup.redis
  @concurrency = opts.fetch(:concurrency, 25)
  @stopped = false
  @processors = []
end

Instance Attribute Details

#redisObject

Returns the value of attribute redis.



6
7
8
# File 'lib/upperkut/manager.rb', line 6

def redis
  @redis
end

#stoppedObject (readonly)

Returns the value of attribute stopped.



7
8
9
# File 'lib/upperkut/manager.rb', line 7

def stopped
  @stopped
end

#workerObject

Returns the value of attribute worker.



6
7
8
# File 'lib/upperkut/manager.rb', line 6

def worker
  @worker
end

Instance Method Details

#killObject



27
28
29
# File 'lib/upperkut/manager.rb', line 27

def kill
  @processors.each(&:kill)
end

#runObject



17
18
19
20
21
# File 'lib/upperkut/manager.rb', line 17

def run
  @concurrency.times do
    @processors << Processor.new(self).run
  end
end

#stopObject



23
24
25
# File 'lib/upperkut/manager.rb', line 23

def stop
  @stopped = true
end