Skip to content

Commit

Permalink
Changed: Rename Loop#loop_default_interval to #loop_base_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
delner committed Mar 30, 2020
1 parent 6f2e128 commit 9f7c7be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions lib/ddtrace/workers/loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Workers
module IntervalLoop
BACK_OFF_RATIO = 1.2
BACK_OFF_MAX = 5
DEFAULT_INTERVAL = 1
BASE_INTERVAL = 1

def self.included(base)
base.send(:prepend, PrependedMethods)
Expand Down Expand Up @@ -37,8 +37,8 @@ def run_loop?
@run_loop == true
end

def loop_default_interval
@loop_default_interval ||= DEFAULT_INTERVAL
def loop_base_interval
@loop_base_interval ||= BASE_INTERVAL
end

def loop_back_off_ratio
Expand All @@ -50,7 +50,7 @@ def loop_back_off_max
end

def loop_wait_time
@loop_wait_time ||= loop_default_interval
@loop_wait_time ||= loop_base_interval
end

def loop_back_off?
Expand All @@ -66,7 +66,7 @@ def loop_back_off!(amount = nil)
attr_writer \
:loop_back_off_max,
:loop_back_off_ratio,
:loop_default_interval
:loop_base_interval

def mutex
@mutex ||= Mutex.new
Expand All @@ -83,7 +83,7 @@ def perform_loop
yield

# Reset the wait interval
loop_back_off!(loop_default_interval)
loop_back_off!(loop_base_interval)
elsif loop_back_off?
# Back off the wait interval a bit
loop_back_off!
Expand Down
24 changes: 12 additions & 12 deletions spec/ddtrace/workers/loop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,20 @@
end
end

describe '#loop_default_interval' do
subject(:loop_default_interval) { worker.loop_default_interval }
describe '#loop_base_interval' do
subject(:loop_base_interval) { worker.loop_base_interval }

context 'default' do
it { is_expected.to eq(described_class::DEFAULT_INTERVAL) }
it { is_expected.to eq(described_class::BASE_INTERVAL) }
end

context 'when set' do
let(:value) { rand }

it do
expect { worker.send(:loop_default_interval=, value) }
.to change { worker.loop_default_interval }
.from(described_class::DEFAULT_INTERVAL)
expect { worker.send(:loop_base_interval=, value) }
.to change { worker.loop_base_interval }
.from(described_class::BASE_INTERVAL)
.to(value)
end
end
Expand Down Expand Up @@ -173,16 +173,16 @@
subject(:loop_wait_time) { worker.loop_wait_time }

context 'default' do
it { is_expected.to eq(described_class::DEFAULT_INTERVAL) }
it { is_expected.to eq(described_class::BASE_INTERVAL) }
end

context 'when set' do
let(:value) { rand }

it do
expect { worker.send(:loop_default_interval=, value) }
.to change { worker.loop_default_interval }
.from(described_class::DEFAULT_INTERVAL)
expect { worker.send(:loop_base_interval=, value) }
.to change { worker.loop_base_interval }
.from(described_class::BASE_INTERVAL)
.to(value)
end
end
Expand All @@ -200,7 +200,7 @@
it do
expect { loop_back_off! }
.to change { worker.loop_wait_time }
.from(described_class::DEFAULT_INTERVAL)
.from(described_class::BASE_INTERVAL)
.to(described_class::BACK_OFF_RATIO)

expect { worker.loop_back_off! }
Expand All @@ -217,7 +217,7 @@
it do
expect { loop_back_off! }
.to change { worker.loop_wait_time }
.from(described_class::DEFAULT_INTERVAL)
.from(described_class::BASE_INTERVAL)
.to(value)
end
end
Expand Down

0 comments on commit 9f7c7be

Please sign in to comment.