forked from TrueCloudLab/frostfs-node
[#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:
parent
eb48a5bb33
commit
826294209b
8 changed files with 20 additions and 38 deletions
|
@ -120,7 +120,7 @@ func (exec *execCtx) initEpoch() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
e, err := exec.svc.currentEpochReceiver.currentEpoch()
|
e, err := exec.svc.epochSource.Epoch()
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -56,7 +56,7 @@ type testClient struct {
|
||||||
|
|
||||||
type testEpochReceiver uint64
|
type testEpochReceiver uint64
|
||||||
|
|
||||||
func (e testEpochReceiver) currentEpoch() (uint64, error) {
|
func (e testEpochReceiver) Epoch() (uint64, error) {
|
||||||
return uint64(e), nil
|
return uint64(e), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
svc.clientCache = c
|
svc.clientCache = c
|
||||||
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
|
svc.epochSource = testEpochReceiver(curEpoch)
|
||||||
|
|
||||||
return svc
|
return svc
|
||||||
}
|
}
|
||||||
|
@ -1182,7 +1182,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
|
svc.epochSource = testEpochReceiver(curEpoch)
|
||||||
|
|
||||||
w := NewSimpleObjectWriter()
|
w := NewSimpleObjectWriter()
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,15 @@ type cfg struct {
|
||||||
GenerateTraverser(cid.ID, *oid.ID, uint64) (*placement.Traverser, error)
|
GenerateTraverser(cid.ID, *oid.ID, uint64) (*placement.Traverser, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentEpochReceiver interface {
|
epochSource epochSource
|
||||||
currentEpoch() (uint64, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
keyStore *util.KeyStorage
|
keyStore *util.KeyStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type epochSource interface {
|
||||||
|
Epoch() (uint64, error)
|
||||||
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
func defaultCfg() *cfg {
|
||||||
return &cfg{
|
return &cfg{
|
||||||
assembly: true,
|
assembly: true,
|
||||||
|
@ -117,9 +119,7 @@ func WithTraverserGenerator(t *util.TraverserGenerator) Option {
|
||||||
// map storage to receive current network state.
|
// map storage to receive current network state.
|
||||||
func WithNetMapSource(nmSrc netmap.Source) Option {
|
func WithNetMapSource(nmSrc netmap.Source) Option {
|
||||||
return func(c *cfg) {
|
return func(c *cfg) {
|
||||||
c.currentEpochReceiver = &nmSrcWrapper{
|
c.epochSource = nmSrc
|
||||||
nmSrc: nmSrc,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
coreclient "github.com/TrueCloudLab/frostfs-node/pkg/core/client"
|
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"
|
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
||||||
internal "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client"
|
internal "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client"
|
||||||
internalclient "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
|
hash io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
type nmSrcWrapper struct {
|
|
||||||
nmSrc netmap.Source
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewSimpleObjectWriter() *SimpleObjectWriter {
|
func NewSimpleObjectWriter() *SimpleObjectWriter {
|
||||||
return &SimpleObjectWriter{
|
return &SimpleObjectWriter{
|
||||||
obj: object.New(),
|
obj: object.New(),
|
||||||
|
@ -250,7 +245,3 @@ func (h *hasherWrapper) WriteChunk(p []byte) error {
|
||||||
_, err := h.hash.Write(p)
|
_, err := h.hash.Write(p)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *nmSrcWrapper) currentEpoch() (uint64, error) {
|
|
||||||
return n.nmSrc.Epoch()
|
|
||||||
}
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (exec *execCtx) initEpoch() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
e, err := exec.svc.currentEpochReceiver.currentEpoch()
|
e, err := exec.svc.epochSource.Epoch()
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -51,7 +51,7 @@ type simpleIDWriter struct {
|
||||||
|
|
||||||
type testEpochReceiver uint64
|
type testEpochReceiver uint64
|
||||||
|
|
||||||
func (e testEpochReceiver) currentEpoch() (uint64, error) {
|
func (e testEpochReceiver) Epoch() (uint64, error) {
|
||||||
return uint64(e), nil
|
return uint64(e), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
svc.clientConstructor = c
|
svc.clientConstructor = c
|
||||||
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
|
svc.epochSource = testEpochReceiver(curEpoch)
|
||||||
|
|
||||||
return svc
|
return svc
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
svc.currentEpochReceiver = testEpochReceiver(curEpoch)
|
svc.epochSource = testEpochReceiver(curEpoch)
|
||||||
|
|
||||||
w := new(simpleIDWriter)
|
w := new(simpleIDWriter)
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,15 @@ type cfg struct {
|
||||||
generateTraverser(cid.ID, uint64) (*placement.Traverser, error)
|
generateTraverser(cid.ID, uint64) (*placement.Traverser, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentEpochReceiver interface {
|
epochSource epochSource
|
||||||
currentEpoch() (uint64, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
keyStore *util.KeyStorage
|
keyStore *util.KeyStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type epochSource interface {
|
||||||
|
Epoch() (uint64, error)
|
||||||
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
func defaultCfg() *cfg {
|
||||||
return &cfg{
|
return &cfg{
|
||||||
log: &logger.Logger{Logger: zap.L()},
|
log: &logger.Logger{Logger: zap.L()},
|
||||||
|
@ -110,9 +112,7 @@ func WithTraverserGenerator(t *util.TraverserGenerator) Option {
|
||||||
// map storage to receive current network state.
|
// map storage to receive current network state.
|
||||||
func WithNetMapSource(nmSrc netmap.Source) Option {
|
func WithNetMapSource(nmSrc netmap.Source) Option {
|
||||||
return func(c *cfg) {
|
return func(c *cfg) {
|
||||||
c.currentEpochReceiver = &nmSrcWrapper{
|
c.epochSource = nmSrc
|
||||||
nmSrc: nmSrc,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/core/client"
|
"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"
|
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
||||||
internalclient "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client"
|
internalclient "github.com/TrueCloudLab/frostfs-node/pkg/services/object/internal/client"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
||||||
|
@ -35,10 +34,6 @@ type storageEngineWrapper struct {
|
||||||
|
|
||||||
type traverseGeneratorWrapper util.TraverserGenerator
|
type traverseGeneratorWrapper util.TraverserGenerator
|
||||||
|
|
||||||
type nmSrcWrapper struct {
|
|
||||||
nmSrc netmap.Source
|
|
||||||
}
|
|
||||||
|
|
||||||
func newUniqueAddressWriter(w IDListWriter) IDListWriter {
|
func newUniqueAddressWriter(w IDListWriter) IDListWriter {
|
||||||
return &uniqueIDWriter{
|
return &uniqueIDWriter{
|
||||||
written: make(map[oid.ID]struct{}),
|
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) {
|
func (e *traverseGeneratorWrapper) generateTraverser(cnr cid.ID, epoch uint64) (*placement.Traverser, error) {
|
||||||
return (*util.TraverserGenerator)(e).GenerateTraverser(cnr, nil, epoch)
|
return (*util.TraverserGenerator)(e).GenerateTraverser(cnr, nil, epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *nmSrcWrapper) currentEpoch() (uint64, error) {
|
|
||||||
return n.nmSrc.Epoch()
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue