[#6] services/object: Remove nmSrc wrapper

It calls a single method from source without any processing.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2022-12-30 14:06:47 +03:00
parent eb48a5bb33
commit 826294209b
8 changed files with 20 additions and 38 deletions

View file

@ -120,7 +120,7 @@ func (exec *execCtx) initEpoch() bool {
return true
}
e, err := exec.svc.currentEpochReceiver.currentEpoch()
e, err := exec.svc.epochSource.Epoch()
switch {
default:

View file

@ -56,7 +56,7 @@ type testClient struct {
type testEpochReceiver uint64
func (e testEpochReceiver) currentEpoch() (uint64, error) {
func (e testEpochReceiver) Epoch() (uint64, error) {
return uint64(e), nil
}
@ -487,7 +487,7 @@ func TestGetRemoteSmall(t *testing.T) {
},
}
svc.clientCache = c
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
svc.epochSource = testEpochReceiver(curEpoch)
return svc
}
@ -1182,7 +1182,7 @@ func TestGetFromPastEpoch(t *testing.T) {
},
}
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
svc.epochSource = testEpochReceiver(curEpoch)
w := NewSimpleObjectWriter()

View file

@ -42,13 +42,15 @@ type cfg struct {
GenerateTraverser(cid.ID, *oid.ID, uint64) (*placement.Traverser, error)
}
currentEpochReceiver interface {
currentEpoch() (uint64, error)
}
epochSource epochSource
keyStore *util.KeyStorage
}
type epochSource interface {
Epoch() (uint64, error)
}
func defaultCfg() *cfg {
return &cfg{
assembly: true,
@ -117,9 +119,7 @@ func WithTraverserGenerator(t *util.TraverserGenerator) Option {
// map storage to receive current network state.
func WithNetMapSource(nmSrc netmap.Source) Option {
return func(c *cfg) {
c.currentEpochReceiver = &nmSrcWrapper{
nmSrc: nmSrc,
}
c.epochSource = nmSrc
}
}

View file

@ -6,7 +6,6 @@ import (
"io"
coreclient "github.com/TrueCloudLab/frostfs-node/pkg/core/client"
"github.com/TrueCloudLab/frostfs-node/pkg/core/netmap"
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
internal "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client"
internalclient "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client"
@ -44,10 +43,6 @@ type hasherWrapper struct {
hash io.Writer
}
type nmSrcWrapper struct {
nmSrc netmap.Source
}
func NewSimpleObjectWriter() *SimpleObjectWriter {
return &SimpleObjectWriter{
obj: object.New(),
@ -250,7 +245,3 @@ func (h *hasherWrapper) WriteChunk(p []byte) error {
_, err := h.hash.Write(p)
return err
}
func (n *nmSrcWrapper) currentEpoch() (uint64, error) {
return n.nmSrc.Epoch()
}

View file

@ -56,7 +56,7 @@ func (exec *execCtx) initEpoch() bool {
return true
}
e, err := exec.svc.currentEpochReceiver.currentEpoch()
e, err := exec.svc.epochSource.Epoch()
switch {
default:

View file

@ -51,7 +51,7 @@ type simpleIDWriter struct {
type testEpochReceiver uint64
func (e testEpochReceiver) currentEpoch() (uint64, error) {
func (e testEpochReceiver) Epoch() (uint64, error) {
return uint64(e), nil
}
@ -261,7 +261,7 @@ func TestGetRemoteSmall(t *testing.T) {
},
}
svc.clientConstructor = c
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
svc.epochSource = testEpochReceiver(curEpoch)
return svc
}
@ -388,7 +388,7 @@ func TestGetFromPastEpoch(t *testing.T) {
},
}
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
svc.epochSource = testEpochReceiver(curEpoch)
w := new(simpleIDWriter)

View file

@ -46,13 +46,15 @@ type cfg struct {
generateTraverser(cid.ID, uint64) (*placement.Traverser, error)
}
currentEpochReceiver interface {
currentEpoch() (uint64, error)
}
epochSource epochSource
keyStore *util.KeyStorage
}
type epochSource interface {
Epoch() (uint64, error)
}
func defaultCfg() *cfg {
return &cfg{
log: &logger.Logger{Logger: zap.L()},
@ -110,9 +112,7 @@ func WithTraverserGenerator(t *util.TraverserGenerator) Option {
// map storage to receive current network state.
func WithNetMapSource(nmSrc netmap.Source) Option {
return func(c *cfg) {
c.currentEpochReceiver = &nmSrcWrapper{
nmSrc: nmSrc,
}
c.epochSource = nmSrc
}
}

View file

@ -4,7 +4,6 @@ import (
"sync"
"github.com/TrueCloudLab/frostfs-node/pkg/core/client"
"github.com/TrueCloudLab/frostfs-node/pkg/core/netmap"
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
internalclient "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client"
"github.com/TrueCloudLab/frostfs-node/pkg/services/object/util"
@ -35,10 +34,6 @@ type storageEngineWrapper struct {
type traverseGeneratorWrapper util.TraverserGenerator
type nmSrcWrapper struct {
nmSrc netmap.Source
}
func newUniqueAddressWriter(w IDListWriter) IDListWriter {
return &uniqueIDWriter{
written: make(map[oid.ID]struct{}),
@ -143,7 +138,3 @@ func idsFromAddresses(addrs []oid.Address) []oid.ID {
func (e *traverseGeneratorWrapper) generateTraverser(cnr cid.ID, epoch uint64) (*placement.Traverser, error) {
return (*util.TraverserGenerator)(e).GenerateTraverser(cnr, nil, epoch)
}
func (n *nmSrcWrapper) currentEpoch() (uint64, error) {
return n.nmSrc.Epoch()
}