2020-09-30 10:52:14 +00:00
|
|
|
package deletesvc
|
|
|
|
|
|
|
|
import (
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
|
|
|
getsvc "github.com/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
|
|
|
putsvc "github.com/TrueCloudLab/frostfs-node/pkg/services/object/put"
|
|
|
|
searchsvc "github.com/TrueCloudLab/frostfs-node/pkg/services/object/search"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/util/logger"
|
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
|
|
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
2020-11-23 11:19:49 +00:00
|
|
|
"go.uber.org/zap"
|
2020-09-30 10:52:14 +00:00
|
|
|
)
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
// Service utility serving requests of Object.Get service.
|
2020-09-30 10:52:14 +00:00
|
|
|
type Service struct {
|
2022-12-30 11:19:42 +00:00
|
|
|
cfg
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
// Option is a Service's constructor option.
|
2020-09-30 10:52:14 +00:00
|
|
|
type Option func(*cfg)
|
|
|
|
|
2021-02-17 12:30:11 +00:00
|
|
|
// NetworkInfo wraps network state and configurations.
|
|
|
|
type NetworkInfo interface {
|
|
|
|
netmap.State
|
|
|
|
|
|
|
|
// Must return the lifespan of the tombstones
|
2023-02-05 15:59:38 +00:00
|
|
|
// in the FrostFS epochs.
|
2021-02-17 12:30:11 +00:00
|
|
|
TombstoneLifetime() (uint64, error)
|
2021-11-08 12:10:49 +00:00
|
|
|
|
|
|
|
// Returns user ID of the local storage node. Result must not be nil.
|
|
|
|
// New tombstone objects will have the result as an owner ID if removal is executed w/o a session.
|
2022-05-31 17:00:41 +00:00
|
|
|
LocalNodeID() user.ID
|
2021-02-17 12:30:11 +00:00
|
|
|
}
|
|
|
|
|
2020-09-30 10:52:14 +00:00
|
|
|
type cfg struct {
|
2020-12-11 08:04:04 +00:00
|
|
|
log *logger.Logger
|
2020-09-30 10:52:14 +00:00
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
header interface {
|
|
|
|
// must return (nil, nil) for PHY objects
|
2022-03-03 14:19:05 +00:00
|
|
|
splitInfo(*execCtx) (*object.SplitInfo, error)
|
2020-09-30 10:52:14 +00:00
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
children(*execCtx) ([]oid.ID, error)
|
2020-09-30 10:52:14 +00:00
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
// must return (nil, nil) for 1st object in chain
|
2022-05-31 17:00:41 +00:00
|
|
|
previous(*execCtx, oid.ID) (*oid.ID, error)
|
2020-12-11 08:04:04 +00:00
|
|
|
}
|
2020-10-01 10:54:18 +00:00
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
searcher interface {
|
2022-05-31 17:00:41 +00:00
|
|
|
splitMembers(*execCtx) ([]oid.ID, error)
|
2020-12-11 08:04:04 +00:00
|
|
|
}
|
2020-11-23 11:19:49 +00:00
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
placer interface {
|
2022-05-31 17:00:41 +00:00
|
|
|
put(*execCtx) (*oid.ID, error)
|
2020-12-11 08:04:04 +00:00
|
|
|
}
|
2021-02-17 12:30:11 +00:00
|
|
|
|
|
|
|
netInfo NetworkInfo
|
2022-09-28 12:05:19 +00:00
|
|
|
|
|
|
|
keyStorage *util.KeyStorage
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
|
2022-12-30 11:19:42 +00:00
|
|
|
func (c *cfg) initDefault() {
|
|
|
|
c.log = &logger.Logger{Logger: zap.L()}
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
// New creates, initializes and returns utility serving
|
|
|
|
// Object.Get service requests.
|
|
|
|
func New(opts ...Option) *Service {
|
2022-12-30 11:19:42 +00:00
|
|
|
var s Service
|
|
|
|
s.cfg.initDefault()
|
2020-09-30 10:52:14 +00:00
|
|
|
|
|
|
|
for i := range opts {
|
2022-12-30 11:19:42 +00:00
|
|
|
opts[i](&s.cfg)
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
|
2022-12-30 11:19:42 +00:00
|
|
|
return &s
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
// WithLogger returns option to specify Delete service's logger.
|
|
|
|
func WithLogger(l *logger.Logger) Option {
|
2020-09-30 10:52:14 +00:00
|
|
|
return func(c *cfg) {
|
2022-09-28 07:41:01 +00:00
|
|
|
c.log = &logger.Logger{Logger: l.With(zap.String("component", "Object.Delete service"))}
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
// WithHeadService returns option to set Head service
|
|
|
|
// to work with object headers.
|
|
|
|
func WithHeadService(h *getsvc.Service) Option {
|
2020-09-30 10:52:14 +00:00
|
|
|
return func(c *cfg) {
|
2020-12-11 08:04:04 +00:00
|
|
|
c.header = (*headSvcWrapper)(h)
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-01 10:54:18 +00:00
|
|
|
|
2021-06-23 13:29:46 +00:00
|
|
|
// WithSearchService returns option to set search service.
|
2020-12-11 08:04:04 +00:00
|
|
|
func WithSearchService(s *searchsvc.Service) Option {
|
2020-10-01 10:54:18 +00:00
|
|
|
return func(c *cfg) {
|
2020-12-11 08:04:04 +00:00
|
|
|
c.searcher = (*searchSvcWrapper)(s)
|
2020-10-01 10:54:18 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-23 11:19:49 +00:00
|
|
|
|
2021-06-23 13:29:46 +00:00
|
|
|
// WithPutService returns option to specify put service.
|
2020-12-11 08:04:04 +00:00
|
|
|
func WithPutService(p *putsvc.Service) Option {
|
2020-11-23 11:19:49 +00:00
|
|
|
return func(c *cfg) {
|
2020-12-11 08:04:04 +00:00
|
|
|
c.placer = (*putSvcWrapper)(p)
|
2020-11-23 11:19:49 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-17 12:30:11 +00:00
|
|
|
|
|
|
|
// WithNetworkInfo returns option to set network information source.
|
|
|
|
func WithNetworkInfo(netInfo NetworkInfo) Option {
|
|
|
|
return func(c *cfg) {
|
|
|
|
c.netInfo = netInfo
|
|
|
|
}
|
|
|
|
}
|
2022-09-28 12:05:19 +00:00
|
|
|
|
|
|
|
// WithKeyStorage returns option to set local private key storage.
|
|
|
|
func WithKeyStorage(ks *util.KeyStorage) Option {
|
|
|
|
return func(c *cfg) {
|
|
|
|
c.keyStorage = ks
|
|
|
|
}
|
|
|
|
}
|