frostfs-node/pkg/local_object_storage/engine/writecache.go
Evgenii Stratonikov 3d882e9f47 [#1806] engine: Allow to flush write-cache
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
2022-09-28 09:28:01 +03:00

33 lines
820 B
Go

package engine
import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
)
// FlushWriteCachePrm groups the parameters of FlushWriteCache operation.
type FlushWriteCachePrm struct {
shardID *shard.ID
}
// SetShardID is an option to set shard ID.
//
// Option is required.
func (p *FlushWriteCachePrm) SetShardID(id *shard.ID) {
p.shardID = id
}
// FlushWriteCacheRes groups the resulting values of FlushWriteCache operation.
type FlushWriteCacheRes struct{}
// FlushWriteCache flushes write-cache on a single shard.
func (e *StorageEngine) FlushWriteCache(p FlushWriteCachePrm) (FlushWriteCacheRes, error) {
e.mtx.RLock()
sh, ok := e.shards[p.shardID.String()]
e.mtx.RUnlock()
if !ok {
return FlushWriteCacheRes{}, errShardNotFound
}
return FlushWriteCacheRes{}, sh.FlushWriteCache()
}