Class: RateThrottleClient::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rate_throttle_client/clients/base.rb

Overview

Standard interface for Client classes Don’t abuse this power

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log: nil, min_sleep: nil, starting_sleep_for: 0, multiplier: nil) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
# File 'lib/rate_throttle_client/clients/base.rb', line 7

def initialize(log: nil, min_sleep: nil, starting_sleep_for: 0, multiplier: nil)
  @log = log || RateThrottleClient.log_block
  @min_sleep = min_sleep || RateThrottleClient.min_sleep
  @multiplier = multiplier || RateThrottleClient.multiplier
  @sleep_for = starting_sleep_for
end

Instance Attribute Details

#logObject

Returns the value of attribute log.



5
6
7
# File 'lib/rate_throttle_client/clients/base.rb', line 5

def log
  @log
end

#min_sleepObject

Returns the value of attribute min_sleep.



5
6
7
# File 'lib/rate_throttle_client/clients/base.rb', line 5

def min_sleep
  @min_sleep
end

#multiplierObject

Returns the value of attribute multiplier.



5
6
7
# File 'lib/rate_throttle_client/clients/base.rb', line 5

def multiplier
  @multiplier
end

#sleep_forObject

Returns the value of attribute sleep_for.



5
6
7
# File 'lib/rate_throttle_client/clients/base.rb', line 5

def sleep_for
  @sleep_for
end

Instance Method Details

#jitter(val) ⇒ Object



14
15
16
# File 'lib/rate_throttle_client/clients/base.rb', line 14

def jitter(val)
  val * rand(0.0..0.1)
end