Class: Uploadr::Worker

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/uploadr/worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWorker

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

#connectionObject

Returns the value of attribute connection.



7
8
9
# File 'lib/uploadr/worker.rb', line 7

def connection
  @connection
end

Instance Method Details

#runObject



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