Class: Processors

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

Overview

Processors is the list of Processors from which

a process can choose from.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



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

def bucket
  @bucket
end

Class Method Details

.get_random_processor(bucket) ⇒ Object

returns a random processor from the pool of processors



25
26
27
28
29
# File 'lib/processor/processor.rb', line 25

def self.get_random_processor(bucket)
  processors = self.registered(bucket)
  return nil if processors.empty?
  processors[rand(processors.size)]
end

.registered(bucket) ⇒ Object

returns an array of the available active processors



14
15
16
17
18
19
20
21
22
# File 'lib/processor/processor.rb', line 14

def self.registered(bucket)
  @bucket = bucket
  processors = []
  # get the list of servers that have registered themselves
  AWS::S3::Bucket.objects(@bucket).each {|o|
    processors << Processor.new(@bucket, o.key)
  }
  processors
end