2020-09-21 14:31:31 +00:00
|
|
|
package putsvc
|
|
|
|
|
|
|
|
import (
|
2023-07-03 08:36:20 +00:00
|
|
|
"context"
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
2020-09-21 14:31:31 +00:00
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
|
|
|
putsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/put"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
2024-11-07 14:32:10 +00:00
|
|
|
objectAPI "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
|
2020-09-21 14:31:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Service implements Put operation of Object service v2.
|
|
|
|
type Service struct {
|
2021-05-28 13:26:32 +00:00
|
|
|
svc *putsvc.Service
|
|
|
|
keyStorage *util.KeyStorage
|
2020-09-21 14:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewService constructs Service instance from provided options.
|
2023-07-06 09:31:03 +00:00
|
|
|
func NewService(svc *putsvc.Service, ks *util.KeyStorage) *Service {
|
2020-09-21 14:31:31 +00:00
|
|
|
return &Service{
|
2023-07-06 09:31:03 +00:00
|
|
|
svc: svc,
|
|
|
|
keyStorage: ks,
|
2020-09-21 14:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put calls internal service and returns v2 object streamer.
|
2023-04-03 11:23:53 +00:00
|
|
|
func (s *Service) Put() (object.PutObjectStream, error) {
|
|
|
|
stream, err := s.svc.Put()
|
2020-09-21 14:31:31 +00:00
|
|
|
if err != nil {
|
2021-05-18 08:12:51 +00:00
|
|
|
return nil, fmt.Errorf("(%T) could not open object put stream: %w", s, err)
|
2020-09-21 14:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return &streamer{
|
2021-05-28 13:26:32 +00:00
|
|
|
stream: stream,
|
|
|
|
keyStorage: s.keyStorage,
|
2020-09-21 14:31:31 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-07-04 12:12:59 +00:00
|
|
|
func (s *Service) PutSingle(ctx context.Context, req *objectAPI.PutSingleRequest) (*objectAPI.PutSingleResponse, error) {
|
|
|
|
return s.svc.PutSingle(ctx, req)
|
2023-07-03 08:36:20 +00:00
|
|
|
}
|