Class: Uploadr::Worker
- Inherits:
-
Object
- Object
- Uploadr::Worker
- Includes:
- Celluloid
- Defined in:
- lib/uploadr/worker.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize ⇒ Worker
constructor
A new instance of Worker.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Worker
Returns a new instance of Worker.
9 10 11 12 13 |
# File 'lib/uploadr/worker.rb', line 9 def initialize @connection = Uploadr::Connection.new async.run # @connection = get_connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
7 8 9 |
# File 'lib/uploadr/worker.rb', line 7 def connection @connection end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/uploadr/worker.rb', line 15 def run loop do file = Actor[:queue].shift break unless file # Actor[:out].puts "[#{thread_id}] Uploading file: #{file}" upload(file) # Actor[:out].puts "[#{thread_id}] Finished uploading file: #{file}" # Actor[:out].puts "#{queue.files.length} photos remaining" Actor[:bar].increment end Actor[:queue].async.completed end |