Class: Pantry::Communication::FileService::SendFile
- Inherits:
-
Object
- Object
- Pantry::Communication::FileService::SendFile
- Includes:
- Celluloid
- Defined in:
- lib/pantry/communication/file_service/send_file.rb
Overview
Chunk file sending tool that implements the protocol as described here
http://zguide.zeromq.org/page:all#Transferring-Files
As this actor receives chunk requests from the Receiver, it reads that chunk from the given file and sends it along.
Instance Method Summary collapse
-
#initialize(service) ⇒ SendFile
constructor
A new instance of SendFile.
- #receive_message(from_identity, message) ⇒ Object
- #send_file(file_path, receiver_uuid, file_uuid) ⇒ Object
Constructor Details
#initialize(service) ⇒ SendFile
Returns a new instance of SendFile.
12 13 14 15 |
# File 'lib/pantry/communication/file_service/send_file.rb', line 12 def initialize(service) @service = service @sending = {} end |
Instance Method Details
#receive_message(from_identity, message) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pantry/communication/file_service/send_file.rb', line 26 def (from_identity, ) current_file_info = @sending[.to] return unless current_file_info case .body[0] when "FETCH" Pantry.logger.debug("[Send File] FETCH requested #{message.inspect}") fetch_and_return_chunk(current_file_info, ) when "FINISH" Pantry.logger.debug("[Send File] FINISHED cleaning up for #{message.inspect}") clean_up(current_file_info, ) when "ERROR" Pantry.logger.debug("[Send File] ERROR #{message.inspect}") end end |
#send_file(file_path, receiver_uuid, file_uuid) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/pantry/communication/file_service/send_file.rb', line 17 def send_file(file_path, receiver_uuid, file_uuid) sender_info = FileService::SendingFile.new(file_path, receiver_uuid, file_uuid) @sending[file_uuid] = sender_info (sender_info, "START") sender_info end |