lib/filestack/utils/utils.rb
# Runs the intelligent upload flow, from start to finish
#
# @param [Array]    jobs      A list of file parts
# @param [IntelligentState]    state     An IntelligentState object
#
# @return [Array]
Runs the intelligent upload flow, from start to finish
Runs the intelligent upload flow from start to finish
def run_intelligent_upload_flow(jobs, filepath, io, state, storage)
    bar = ProgressBar.new(jobs.length)
    generator = create_intelligent_generator(jobs)
    working_offset = FilestackConfig::DEFAULT_OFFSET_SIZE
    while generator.alive?
      batch = get_generator_batch(generator)
      Parallel.map(batch, in_threads: 4) do |part|
        state = run_intelligent_uploads(part, filepath, io, state, storage)
        while bad_state(state)
          if state.error_type == 'S3_NETWORK'
            sleep(5)
            state.offset = working_offset = change_offset(working_offset, state)
          elsif ['S3_SERVER', 'BACKEND_SERVER'].include? state.error_type
            sleep(state.backoff)
          end
          state.add_retry
          state = run_intelligent_uploads(part, filepath, io, state, storage)
        end
        raise "Upload has failed. Please try again later." unless state.ok
        bar.increment!
      end
    end
  end
def run_intelligent_upload_flow ( jobs , filepath , io , state , storage ) bar = ProgressBar . new ( jobs . length ) generator = create_intelligent_generator ( jobs ) working_offset = FilestackConfig :: DEFAULT_OFFSET_SIZE while generator . alive? batch = get_generator_batch ( generator ) Parallel . map ( batch , in_threads : 4 ) do | part | state = run_intelligent_uploads ( part , filepath , io , state , storage ) while bad_state ( state ) if state . error_type == 'S3_NETWORK' sleep ( 5 ) state . offset = working_offset = change_offset ( working_offset , state ) elsif [ 'S3_SERVER' , 'BACKEND_SERVER' ] . include? state . error_type sleep ( state . backoff ) end state . add_retry state = run_intelligent_uploads ( part , filepath , io , state , storage ) end raise "Upload has failed. Please try again later." unless state . ok bar . increment! end end end
Runs the intelligent upload flow, from start to finish
Runs the intelligent upload flow from start to finish
# run parts # condition: a chunk has failed but we have not reached the maximum retries # condition: timeout to S3, requiring offset size to be changed # condition: timeout to backend, requiring only backoff
None
Array
jobs
<not_specific>
filepath
<not_specific>
io
<not_specific>
state
<not_specific>
storage
<not_specific>
<not_specific>
state An IntelligentState object
state An IntelligentState object