[#477] engine: Make generateShardID function independent

This function does not use any engine internal states.
This way it can be reused in tests.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-04-14 11:47:42 +03:00 committed by Alex Vanin
parent bd5ce4535a
commit 2716000b08

View file

@ -24,7 +24,7 @@ func (e *StorageEngine) AddShard(opts ...shard.Option) (*shard.ID, error) {
e.mtx.Lock()
defer e.mtx.Unlock()
id, err := e.generateShardID()
id, err := generateShardID()
if err != nil {
return nil, errors.Wrap(err, "could not generate shard ID")
}
@ -37,7 +37,7 @@ func (e *StorageEngine) AddShard(opts ...shard.Option) (*shard.ID, error) {
return id, nil
}
func (e *StorageEngine) generateShardID() (*shard.ID, error) {
func generateShardID() (*shard.ID, error) {
uid, err := uuid.NewRandom()
if err != nil {
return nil, err