2020-09-21 14:31:31 +00:00
|
|
|
package putsvc
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
|
|
|
objutil "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
2020-11-23 11:22:32 +00:00
|
|
|
"go.uber.org/zap"
|
2020-09-21 14:31:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MaxSizeSource interface {
|
2020-10-22 14:20:59 +00:00
|
|
|
// MaxObjectSize returns maximum payload size
|
|
|
|
// of physically stored object in system.
|
|
|
|
//
|
|
|
|
// Must return 0 if value can not be obtained.
|
2020-09-21 14:31:31 +00:00
|
|
|
MaxObjectSize() uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
type Service struct {
|
|
|
|
*cfg
|
|
|
|
}
|
|
|
|
|
|
|
|
type Option func(*cfg)
|
|
|
|
|
2021-03-23 18:40:36 +00:00
|
|
|
type ClientConstructor interface {
|
2022-01-13 15:01:50 +00:00
|
|
|
Get(client.NodeInfo) (client.MultiAddressClient, error)
|
2021-03-23 18:40:36 +00:00
|
|
|
}
|
|
|
|
|
2023-07-28 12:44:35 +00:00
|
|
|
type InnerRing interface {
|
|
|
|
InnerRingKeys() ([][]byte, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type FormatValidatorConfig interface {
|
|
|
|
VerifySessionTokenIssuer() bool
|
|
|
|
}
|
|
|
|
|
2020-09-21 14:31:31 +00:00
|
|
|
type cfg struct {
|
2020-09-29 16:44:59 +00:00
|
|
|
keyStorage *objutil.KeyStorage
|
2020-09-21 14:31:31 +00:00
|
|
|
|
|
|
|
maxSizeSrc MaxSizeSource
|
|
|
|
|
2022-03-15 19:40:31 +00:00
|
|
|
localStore ObjectStorage
|
2020-09-21 14:31:31 +00:00
|
|
|
|
|
|
|
cnrSrc container.Source
|
|
|
|
|
|
|
|
netMapSrc netmap.Source
|
|
|
|
|
2021-09-24 10:36:54 +00:00
|
|
|
remotePool, localPool util.WorkerPool
|
2020-09-21 14:31:31 +00:00
|
|
|
|
2021-09-06 12:17:14 +00:00
|
|
|
netmapKeys netmap.AnnouncedKeys
|
2020-09-29 12:38:35 +00:00
|
|
|
|
|
|
|
fmtValidator *object.FormatValidator
|
2020-10-03 10:14:09 +00:00
|
|
|
|
2020-10-21 15:11:50 +00:00
|
|
|
networkState netmap.State
|
2020-11-18 13:03:31 +00:00
|
|
|
|
2021-03-23 18:40:36 +00:00
|
|
|
clientConstructor ClientConstructor
|
2020-11-23 11:22:32 +00:00
|
|
|
|
|
|
|
log *logger.Logger
|
2023-07-28 12:44:35 +00:00
|
|
|
|
|
|
|
verifySessionTokenIssuer bool
|
2020-09-21 14:31:31 +00:00
|
|
|
}
|
|
|
|
|
2023-07-06 09:21:03 +00:00
|
|
|
func NewService(ks *objutil.KeyStorage,
|
|
|
|
cc ClientConstructor,
|
|
|
|
ms MaxSizeSource,
|
|
|
|
os ObjectStorage,
|
|
|
|
cs container.Source,
|
|
|
|
ns netmap.Source,
|
|
|
|
nk netmap.AnnouncedKeys,
|
|
|
|
nst netmap.State,
|
2023-07-28 12:44:35 +00:00
|
|
|
ir InnerRing,
|
2023-07-06 09:21:03 +00:00
|
|
|
opts ...Option) *Service {
|
|
|
|
c := &cfg{
|
|
|
|
remotePool: util.NewPseudoWorkerPool(),
|
|
|
|
localPool: util.NewPseudoWorkerPool(),
|
|
|
|
log: &logger.Logger{Logger: zap.L()},
|
|
|
|
keyStorage: ks,
|
|
|
|
clientConstructor: cc,
|
|
|
|
maxSizeSrc: ms,
|
|
|
|
localStore: os,
|
|
|
|
cnrSrc: cs,
|
|
|
|
netMapSrc: ns,
|
|
|
|
netmapKeys: nk,
|
|
|
|
networkState: nst,
|
2020-09-21 14:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := range opts {
|
|
|
|
opts[i](c)
|
|
|
|
}
|
|
|
|
|
2023-07-28 12:44:35 +00:00
|
|
|
c.fmtValidator = object.NewFormatValidator(
|
|
|
|
object.WithLockSource(os),
|
|
|
|
object.WithNetState(nst),
|
|
|
|
object.WithInnerRing(ir),
|
|
|
|
object.WithNetmapSource(ns),
|
|
|
|
object.WithContainersSource(cs),
|
|
|
|
object.WithVerifySessionTokenIssuer(c.verifySessionTokenIssuer),
|
2023-08-07 06:54:47 +00:00
|
|
|
object.WithLogger(c.log),
|
2023-07-28 12:44:35 +00:00
|
|
|
)
|
2020-10-03 10:14:09 +00:00
|
|
|
|
2020-09-21 14:31:31 +00:00
|
|
|
return &Service{
|
|
|
|
cfg: c,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-03 11:23:53 +00:00
|
|
|
func (p *Service) Put() (*Streamer, error) {
|
2020-09-21 14:31:31 +00:00
|
|
|
return &Streamer{
|
|
|
|
cfg: p.cfg,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-02-22 08:31:50 +00:00
|
|
|
func WithWorkerPools(remote, local util.WorkerPool) Option {
|
2020-09-21 14:31:31 +00:00
|
|
|
return func(c *cfg) {
|
2023-02-22 08:31:50 +00:00
|
|
|
c.remotePool, c.localPool = remote, local
|
2020-09-21 14:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-23 11:22:32 +00:00
|
|
|
func WithLogger(l *logger.Logger) Option {
|
|
|
|
return func(c *cfg) {
|
|
|
|
c.log = l
|
|
|
|
}
|
|
|
|
}
|
2023-07-28 12:44:35 +00:00
|
|
|
|
|
|
|
func WithVerifySessionTokenIssuer(v bool) Option {
|
|
|
|
return func(c *cfg) {
|
|
|
|
c.verifySessionTokenIssuer = v
|
|
|
|
}
|
|
|
|
}
|