Rename persisted? to data_persisted?

This commit is contained in:
Shinya Maeda 2018-06-18 17:56:16 +09:00
parent 71e30c0119
commit 494673793d
3 changed files with 10 additions and 14 deletions

View file

@ -75,9 +75,7 @@ module Ci
raise ArgumentError, 'Offset is out of range' if offset > size || offset < 0
raise ArgumentError, 'Chunk size overflow' if CHUNK_SIZE < (offset + new_data.bytesize)
in_lock(*lock_params) do
self.reload if self.persisted?
in_lock(*lock_params) do # Write opetation is atomic
unsafe_set_data!(data.byteslice(0, offset) + new_data)
end
@ -100,21 +98,19 @@ module Ci
(start_offset...end_offset)
end
def persisted?
def data_persisted?
!redis?
end
def persist!
in_lock(*lock_params) do
self.reload if self.persisted?
unsafe_move_to!(self.class.persist_store)
def persist_data!
in_lock(*lock_params) do # Write opetation is atomic
unsafe_migrate_to!(self.class.persist_store)
end
end
private
def unsafe_move_to!(new_store)
def unsafe_migrate_to!(new_store)
return if data_store == new_store.to_s
return unless size > 0
@ -143,7 +139,7 @@ module Ci
end
def schedule_to_persist
return if persisted?
return if data_persisted?
Ci::BuildTraceChunkFlushWorker.perform_async(id)
end

View file

@ -5,7 +5,7 @@ module Ci
def perform(build_trace_chunk_id)
::Ci::BuildTraceChunk.find_by(id: build_trace_chunk_id).try do |build_trace_chunk|
build_trace_chunk.persist!
build_trace_chunk.persist_data!
end
end
end

View file

@ -286,8 +286,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
describe '#persist!' do
subject { build_trace_chunk.persist! }
describe '#persist_data!' do
subject { build_trace_chunk.persist_data! }
context 'when data_store is redis' do
let(:data_store) { :redis }