[#647] objsvc/search: Wrap in uniqueIDWriter during parameter setting

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-08-24 21:55:36 +03:00
parent 966ad22abf
commit 4db2cbc927
4 changed files with 6 additions and 11 deletions

View file

@ -18,12 +18,6 @@ type execCtx struct {
curProcEpoch uint64 curProcEpoch uint64
} }
func (exec *execCtx) prepare() {
if _, ok := exec.prm.writer.(*uniqueIDWriter); !ok {
exec.prm.writer = newUniqueAddressWriter(exec.prm.writer)
}
}
func (exec *execCtx) setLogger(l *logger.Logger) { func (exec *execCtx) setLogger(l *logger.Logger) {
exec.log = &logger.Logger{Logger: l.With( exec.log = &logger.Logger{Logger: l.With(
zap.String("request", "SEARCH"), zap.String("request", "SEARCH"),

View file

@ -12,7 +12,7 @@ import (
// Prm groups parameters of Get service call. // Prm groups parameters of Get service call.
type Prm struct { type Prm struct {
writer IDListWriter writer *uniqueIDWriter
common *util.CommonPrm common *util.CommonPrm
@ -40,7 +40,7 @@ func (p *Prm) SetCommonParameters(common *util.CommonPrm) {
// SetWriter sets target component to write list of object identifiers. // SetWriter sets target component to write list of object identifiers.
func (p *Prm) SetWriter(w IDListWriter) { func (p *Prm) SetWriter(w IDListWriter) {
p.writer = w p.writer = newUniqueAddressWriter(w)
} }
// SetRequestForwarder sets callback for forwarding // SetRequestForwarder sets callback for forwarding

View file

@ -14,8 +14,6 @@ func (s *Service) Search(ctx context.Context, prm Prm) error {
prm: prm, prm: prm,
} }
exec.prepare()
exec.setLogger(s.log) exec.setLogger(s.log)
return exec.execute(ctx) return exec.execute(ctx)

View file

@ -31,7 +31,10 @@ type storageEngineWrapper struct {
storage *engine.StorageEngine storage *engine.StorageEngine
} }
func newUniqueAddressWriter(w IDListWriter) IDListWriter { func newUniqueAddressWriter(w IDListWriter) *uniqueIDWriter {
if w, ok := w.(*uniqueIDWriter); ok {
return w
}
return &uniqueIDWriter{ return &uniqueIDWriter{
written: make(map[oid.ID]struct{}), written: make(map[oid.ID]struct{}),
writer: w, writer: w,