forked from TrueCloudLab/frostfs-node
Airat Arifullin
b3deb893ba
* Split the logic of write target initialization to different packages; * Refactor patch and put services: since both service initialize the target themselves. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package putsvc
|
|
|
|
import (
|
|
"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"
|
|
objectwriter "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/common/writer"
|
|
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"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
type Service struct {
|
|
*objectwriter.Config
|
|
}
|
|
|
|
func NewService(ks *objutil.KeyStorage,
|
|
cc objectwriter.ClientConstructor,
|
|
ms objectwriter.MaxSizeSource,
|
|
os objectwriter.ObjectStorage,
|
|
cs container.Source,
|
|
ns netmap.Source,
|
|
nk netmap.AnnouncedKeys,
|
|
nst netmap.State,
|
|
ir objectwriter.InnerRing,
|
|
opts ...objectwriter.Option,
|
|
) *Service {
|
|
c := &objectwriter.Config{
|
|
RemotePool: util.NewPseudoWorkerPool(),
|
|
LocalPool: util.NewPseudoWorkerPool(),
|
|
Logger: &logger.Logger{Logger: zap.L()},
|
|
KeyStorage: ks,
|
|
ClientConstructor: cc,
|
|
MaxSizeSrc: ms,
|
|
LocalStore: os,
|
|
ContainerSource: cs,
|
|
NetmapSource: ns,
|
|
NetmapKeys: nk,
|
|
NetworkState: nst,
|
|
}
|
|
|
|
for i := range opts {
|
|
opts[i](c)
|
|
}
|
|
|
|
c.FormatValidator = object.NewFormatValidator(
|
|
object.WithLockSource(os),
|
|
object.WithNetState(nst),
|
|
object.WithInnerRing(ir),
|
|
object.WithNetmapSource(ns),
|
|
object.WithContainersSource(cs),
|
|
object.WithVerifySessionTokenIssuer(c.VerifySessionTokenIssuer),
|
|
object.WithLogger(c.Logger),
|
|
)
|
|
|
|
return &Service{
|
|
Config: c,
|
|
}
|
|
}
|
|
|
|
func (p *Service) Put() (*Streamer, error) {
|
|
return &Streamer{
|
|
Config: p.Config,
|
|
}, nil
|
|
}
|