Class: BlockActor
- Inherits:
-
Object
- Object
- BlockActor
- Includes:
- Celluloid
- Defined in:
- lib/azure-contrib/blob_service.rb
Overview
Instance Method Summary collapse
-
#initialize(service, container, blob, options = {}) ⇒ BlockActor
constructor
A new instance of BlockActor.
- #log(message) ⇒ Object
- #upload(block_id, chunk, retries = 0) ⇒ Object
Constructor Details
#initialize(service, container, blob, options = {}) ⇒ BlockActor
Returns a new instance of BlockActor.
20 21 22 |
# File 'lib/azure-contrib/blob_service.rb', line 20 def initialize(service, container, blob, = {}) @service, @container, @blob, @options = service, container, blob, end |
Instance Method Details
#log(message) ⇒ Object
43 44 45 |
# File 'lib/azure-contrib/blob_service.rb', line 43 def log() puts end |
#upload(block_id, chunk, retries = 0) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/azure-contrib/blob_service.rb', line 24 def upload(block_id, chunk, retries = 0) Timeout::timeout(@options[:timeout] || 30){ log "Uploading block #{block_id}" = @options.dup [:content_md5] = Base64.strict_encode64(Digest::MD5.digest(chunk)) content_md5 = @service.create_blob_block(@container, @blob, block_id, chunk, ) log "Done uploading block #{block_id} #{content_md5}" [block_id, :uncommitted] } rescue Timeout::Error, Azure::Core::Error => e log "Failed to upload #{block_id}: #{e.class} #{e.}" if retries < 5 log "Retrying upload (#{retries})" upload(block_id, chunk, retries += 1) else log "Complete failure to upload #{retries} retries" end end |