Class: Processor
- Inherits:
-
Object
- Object
- Processor
- Defined in:
- lib/processor/processor.rb
Overview
A Processor is a link in the processing chain. This is where
the processor gets chosen and the application runs on top of
the chosen processor
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
Class Method Summary collapse
-
.get_current_hostname ⇒ Object
return the current unix hostname.
Instance Method Summary collapse
-
#==(other) ⇒ Object
equality operator.
-
#active? ⇒ Boolean
is this processor working?.
-
#initialize(bucket, hostname = Processor.get_current_hostname) ⇒ Processor
constructor
A new instance of Processor.
-
#not_equal?(other) ⇒ Boolean
inequality operator.
-
#register ⇒ Object
make this processor available to the pool.
-
#registered? ⇒ Boolean
check to see if this processor has been properly registered.
-
#unregister ⇒ Object
remove this processor from the pool.
-
#url_for ⇒ Object
return the URL needed to try to upload to this processor.
Constructor Details
#initialize(bucket, hostname = Processor.get_current_hostname) ⇒ Processor
Returns a new instance of Processor.
40 41 42 43 |
# File 'lib/processor/processor.rb', line 40 def initialize(bucket, hostname = Processor.get_current_hostname) @bucket = bucket @hostname = hostname end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
38 39 40 |
# File 'lib/processor/processor.rb', line 38 def bucket @bucket end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
38 39 40 |
# File 'lib/processor/processor.rb', line 38 def hostname @hostname end |
Class Method Details
.get_current_hostname ⇒ Object
return the current unix hostname
77 78 79 |
# File 'lib/processor/processor.rb', line 77 def self.get_current_hostname return `hostname`.chomp end |
Instance Method Details
#==(other) ⇒ Object
equality operator
67 68 69 |
# File 'lib/processor/processor.rb', line 67 def ==(other) return @hostname == other.hostname end |
#active? ⇒ Boolean
is this processor working?
61 62 63 64 |
# File 'lib/processor/processor.rb', line 61 def active? # check to see if this server is pingable return Net::PingExternal.new(@hostname).ping end |
#not_equal?(other) ⇒ Boolean
inequality operator
72 73 74 |
# File 'lib/processor/processor.rb', line 72 def not_equal?(other) return @hostname != other.hostname end |
#register ⇒ Object
make this processor available to the pool
46 47 48 |
# File 'lib/processor/processor.rb', line 46 def register AWS::S3::S3Object.store(@hostname, 'ready', @bucket) if @hostname && @bucket end |
#registered? ⇒ Boolean
check to see if this processor has been properly registered
56 57 58 |
# File 'lib/processor/processor.rb', line 56 def registered? AWS::S3::S3Object.exists?(@hostname, @bucket) end |
#unregister ⇒ Object
remove this processor from the pool
51 52 53 |
# File 'lib/processor/processor.rb', line 51 def unregister AWS::S3::S3Object.delete(@hostname, @bucket) if @hostname && @bucket end |
#url_for ⇒ Object
return the URL needed to try to upload to this processor
82 83 84 |
# File 'lib/processor/processor.rb', line 82 def url_for "http://#{@hostname}:4567/new" end |