2020-09-30 10:52:14 +00:00
|
|
|
package deletesvc
|
|
|
|
|
|
|
|
import (
|
2023-04-04 09:45:59 +00:00
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
|
|
|
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
|
|
|
putsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/put"
|
|
|
|
searchsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/search"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
2023-07-06 12:36:41 +00:00
|
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
2023-03-07 13:38:26 +00:00
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
|
|
|
"git.frostfs.info/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 {
|
|
|
|
*cfg
|
|
|
|
}
|
|
|
|
|
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
|
2023-07-06 12:36:41 +00:00
|
|
|
splitInfo(context.Context, *execCtx) (*objectSDK.SplitInfo, error)
|
2020-09-30 10:52:14 +00:00
|
|
|
|
2023-04-04 09:45:59 +00:00
|
|
|
children(context.Context, *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
|
2023-04-04 09:45:59 +00:00
|
|
|
previous(context.Context, *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 {
|
2023-04-04 09:45:59 +00:00
|
|
|
splitMembers(context.Context, *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 {
|
2023-04-04 09:45:59 +00:00
|
|
|
put(context.Context, *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
|
|
|
}
|
|
|
|
|
2020-12-11 08:04:04 +00:00
|
|
|
// New creates, initializes and returns utility serving
|
|
|
|
// Object.Get service requests.
|
2023-07-06 09:04:00 +00:00
|
|
|
func New(gs *getsvc.Service,
|
|
|
|
ss *searchsvc.Service,
|
|
|
|
ps *putsvc.Service,
|
|
|
|
ni NetworkInfo,
|
|
|
|
ks *util.KeyStorage,
|
|
|
|
opts ...Option) *Service {
|
|
|
|
c := &cfg{
|
|
|
|
log: &logger.Logger{Logger: zap.L()},
|
2023-07-10 09:18:56 +00:00
|
|
|
header: &headSvcWrapper{s: gs},
|
|
|
|
searcher: &searchSvcWrapper{s: ss},
|
|
|
|
placer: &putSvcWrapper{s: ps},
|
2023-07-06 09:04:00 +00:00
|
|
|
netInfo: ni,
|
|
|
|
keyStorage: ks,
|
|
|
|
}
|
2020-09-30 10:52:14 +00:00
|
|
|
|
|
|
|
for i := range opts {
|
|
|
|
opts[i](c)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Service{
|
|
|
|
cfg: c,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
2023-07-06 12:36:41 +00:00
|
|
|
c.log = &logger.Logger{Logger: l.With(zap.String("component", "objectSDK.Delete service"))}
|
2020-09-30 10:52:14 +00:00
|
|
|
}
|
|
|
|
}
|