Class: IntelligentState

Inherits:
Object
  • Object
show all
Defined in:
lib/filestack/utils/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIntelligentState

Returns a new instance of IntelligentState.



11
12
13
14
15
16
17
18
19
# File 'lib/filestack/utils/utils.rb', line 11

def initialize
  @offset = 524288
  @ok = true
  @alive = true
  @retries = 0
  @backoff = 1
  @offset_index = 0
  @offset_sizes = [524288, 262144, 131072, 65536, 32768]
end

Instance Attribute Details

#error_typeObject

Returns the value of attribute error_type.



10
11
12
# File 'lib/filestack/utils/utils.rb', line 10

def error_type
  @error_type
end

#offsetObject

Returns the value of attribute offset.



10
11
12
# File 'lib/filestack/utils/utils.rb', line 10

def offset
  @offset
end

#okObject

Returns the value of attribute ok.



10
11
12
# File 'lib/filestack/utils/utils.rb', line 10

def ok
  @ok
end

Instance Method Details

#add_retryObject



25
26
27
28
# File 'lib/filestack/utils/utils.rb', line 25

def add_retry
  @retries += 1
  @alive = false if @retries >= 5
end

#alive?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/filestack/utils/utils.rb', line 21

def alive?
  @alive
end

#backoffObject



30
31
32
# File 'lib/filestack/utils/utils.rb', line 30

def backoff
  @backoff = 2 ** @retries
end

#next_offsetObject



34
35
36
37
38
# File 'lib/filestack/utils/utils.rb', line 34

def next_offset
  current_offset = @offset_sizes[@offset_index]
  @offset_index += 1
  return current_offset
end

#resetObject



40
41
42
# File 'lib/filestack/utils/utils.rb', line 40

def reset
  @retries = 0
end