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>
41 lines
1,003 B
Go
41 lines
1,003 B
Go
package patchsvc
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
|
objectwriter "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/common/writer"
|
|
getsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/get"
|
|
)
|
|
|
|
// Service implements Put operation of Object service v2.
|
|
type Service struct {
|
|
*objectwriter.Config
|
|
|
|
getSvc *getsvc.Service
|
|
}
|
|
|
|
// NewService constructs Service instance from provided options.
|
|
//
|
|
// Patch service can use the same objectwriter.Config initializied by Put service.
|
|
func NewService(cfg *objectwriter.Config,
|
|
getSvc *getsvc.Service,
|
|
) *Service {
|
|
return &Service{
|
|
Config: cfg,
|
|
|
|
getSvc: getSvc,
|
|
}
|
|
}
|
|
|
|
// Put calls internal service and returns v2 object streamer.
|
|
func (s *Service) Patch() (object.PatchObjectStream, error) {
|
|
nodeKey, err := s.Config.KeyStorage.GetKey(nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &Streamer{
|
|
Config: s.Config,
|
|
getSvc: s.getSvc,
|
|
localNodeKey: nodeKey,
|
|
}, nil
|
|
}
|