[#378] object/delete: Set expiration epoch of the created tombstones

Make object delete service to use network information to calculate and set
expiration of the created tombstone.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-17 15:30:11 +03:00 committed by Alex Vanin
parent 717f2beb47
commit b8d1144839
3 changed files with 43 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package deletesvc
import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
@ -17,6 +18,15 @@ type Service struct {
// Option is a Service's constructor option.
type Option func(*cfg)
// NetworkInfo wraps network state and configurations.
type NetworkInfo interface {
netmap.State
// Must return the lifespan of the tombstones
// in the NeoFS epochs.
TombstoneLifetime() (uint64, error)
}
type cfg struct {
log *logger.Logger
@ -37,6 +47,8 @@ type cfg struct {
placer interface {
put(*execCtx, bool) (*objectSDK.ID, error)
}
netInfo NetworkInfo
}
func defaultCfg() *cfg {
@ -87,3 +99,10 @@ func WithPutService(p *putsvc.Service) Option {
c.placer = (*putSvcWrapper)(p)
}
}
// WithNetworkInfo returns option to set network information source.
func WithNetworkInfo(netInfo NetworkInfo) Option {
return func(c *cfg) {
c.netInfo = netInfo
}
}