Commit ad2d0041 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Use `!` for `increment_syncs_since_gc` and `reset_syncs_since_gc`

parent 387c844e
...@@ -64,11 +64,11 @@ class Geo::ProjectRegistry < Geo::BaseRegistry ...@@ -64,11 +64,11 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
Gitlab::Redis::SharedState.with { |redis| redis.get(fetches_since_gc_redis_key).to_i } Gitlab::Redis::SharedState.with { |redis| redis.get(fetches_since_gc_redis_key).to_i }
end end
def increment_syncs_since_gc def increment_syncs_since_gc!
Gitlab::Redis::SharedState.with { |redis| redis.incr(fetches_since_gc_redis_key) } Gitlab::Redis::SharedState.with { |redis| redis.incr(fetches_since_gc_redis_key) }
end end
def reset_syncs_since_gc def reset_syncs_since_gc!
Gitlab::Redis::SharedState.with { |redis| redis.del(fetches_since_gc_redis_key) } Gitlab::Redis::SharedState.with { |redis| redis.del(fetches_since_gc_redis_key) }
end end
......
...@@ -29,7 +29,7 @@ module Geo ...@@ -29,7 +29,7 @@ module Geo
def increment! def increment!
Gitlab::Metrics.measure(:geo_increment_syncs_since_gc) do Gitlab::Metrics.measure(:geo_increment_syncs_since_gc) do
registry.increment_syncs_since_gc registry.increment_syncs_since_gc!
end end
end end
...@@ -47,7 +47,7 @@ module Geo ...@@ -47,7 +47,7 @@ module Geo
ensure ensure
if should_reset? if should_reset?
Gitlab::Metrics.measure(:geo_reset_syncs_since_gc) do Gitlab::Metrics.measure(:geo_reset_syncs_since_gc) do
registry.reset_syncs_since_gc registry.reset_syncs_since_gc!
end end
end end
end end
......
...@@ -213,7 +213,7 @@ describe Geo::ProjectRegistry do ...@@ -213,7 +213,7 @@ describe Geo::ProjectRegistry do
context 'redis shared state', :redis do context 'redis shared state', :redis do
after do after do
subject.reset_syncs_since_gc subject.reset_syncs_since_gc!
end end
describe '#syncs_since_gc' do describe '#syncs_since_gc' do
...@@ -234,7 +234,7 @@ describe Geo::ProjectRegistry do ...@@ -234,7 +234,7 @@ describe Geo::ProjectRegistry do
describe '#increment_syncs_since_gc' do describe '#increment_syncs_since_gc' do
it 'increments the number of pushes since the last GC' do it 'increments the number of pushes since the last GC' do
3.times { subject.increment_syncs_since_gc } 3.times { subject.increment_syncs_since_gc! }
expect(subject.syncs_since_gc).to eq(3) expect(subject.syncs_since_gc).to eq(3)
end end
...@@ -242,9 +242,9 @@ describe Geo::ProjectRegistry do ...@@ -242,9 +242,9 @@ describe Geo::ProjectRegistry do
describe '#reset_syncs_since_gc' do describe '#reset_syncs_since_gc' do
it 'resets the number of pushes since the last GC' do it 'resets the number of pushes since the last GC' do
3.times { subject.increment_syncs_since_gc } 3.times { subject.increment_syncs_since_gc! }
subject.reset_syncs_since_gc subject.reset_syncs_since_gc!
expect(subject.syncs_since_gc).to eq(0) expect(subject.syncs_since_gc).to eq(0)
end end
......
...@@ -6,11 +6,11 @@ describe Geo::ProjectHousekeepingService do ...@@ -6,11 +6,11 @@ describe Geo::ProjectHousekeepingService do
let(:registry) { service.registry } let(:registry) { service.registry }
before do before do
registry.reset_syncs_since_gc registry.reset_syncs_since_gc!
end end
after do after do
registry.reset_syncs_since_gc registry.reset_syncs_since_gc!
end end
describe '#execute' do describe '#execute' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment