Skip to content

Commit

Permalink
shard: drop FlushWriteCachePrm
Browse files Browse the repository at this point in the history
Not the most useful piece of code.

Signed-off-by: Roman Khimov <[email protected]>
  • Loading branch information
roman-khimov committed Nov 22, 2024
1 parent 55e6615 commit 7c628a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/writecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ func (e *StorageEngine) FlushWriteCache(id *shard.ID) error {
return errShardNotFound
}

return sh.FlushWriteCache(shard.FlushWriteCachePrm{})
return sh.FlushWriteCache(false)
}
17 changes: 4 additions & 13 deletions pkg/local_object_storage/shard/writecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@ import (
"errors"
)

// FlushWriteCachePrm represents parameters of a `FlushWriteCache` operation.
type FlushWriteCachePrm struct {
ignoreErrors bool
}

// SetIgnoreErrors sets the flag to ignore read-errors during flush.
func (p *FlushWriteCachePrm) SetIgnoreErrors(ignore bool) {
p.ignoreErrors = ignore
}

// errWriteCacheDisabled is returned when an operation on write-cache is performed,
// but write-cache is disabled.
var errWriteCacheDisabled = errors.New("write-cache is disabled")

// FlushWriteCache flushes all data from the write-cache.
func (s *Shard) FlushWriteCache(p FlushWriteCachePrm) error {
// FlushWriteCache flushes all data from the write-cache. If ignoreErrors
// is set will flush all objects it can irrespective of any errors.
func (s *Shard) FlushWriteCache(ignoreErrors bool) error {
if !s.hasWriteCache() {
return errWriteCacheDisabled
}
Expand All @@ -35,5 +26,5 @@ func (s *Shard) FlushWriteCache(p FlushWriteCachePrm) error {
return ErrDegradedMode
}

return s.writeCache.Flush(p.ignoreErrors)
return s.writeCache.Flush(ignoreErrors)
}

0 comments on commit 7c628a0

Please sign in to comment.