[#188] localstorage: Implement SetShardMode method
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3fa3661cad
commit
cba87a1300
1 changed files with 18 additions and 0 deletions
|
@ -10,6 +10,8 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var errShardNotFound = errors.New("shard not found")
|
||||
|
||||
// AddShard adds a new shard to the storage engine.
|
||||
//
|
||||
// Returns any error encountered that did not allow adding a shard.
|
||||
|
@ -72,3 +74,19 @@ func (e *StorageEngine) iterateOverSortedShards(addr *object.Address, handler fu
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetShardMode sets mode of the shard with provided identifier.
|
||||
//
|
||||
// Returns an error if shard mode was not set, or shard was not found in storage engine.
|
||||
func (e *StorageEngine) SetShardMode(id *shard.ID, m shard.Mode) error {
|
||||
e.mtx.RLock()
|
||||
defer e.mtx.RUnlock()
|
||||
|
||||
for shID, sh := range e.shards {
|
||||
if id.String() == shID {
|
||||
return sh.SetMode(m)
|
||||
}
|
||||
}
|
||||
|
||||
return errShardNotFound
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue