forked from TrueCloudLab/frostfs-node
[#463] putsvc: Use PutSingle RPC for remote target
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
b2487e8cc5
commit
8966dd8e35
4 changed files with 78 additions and 0 deletions
|
@ -449,6 +449,54 @@ func PutObject(ctx context.Context, prm PutObjectPrm) (*PutObjectRes, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// PutObjectSingle saves the object in local storage of the remote node with PutSingle RPC.
|
||||
//
|
||||
// Client and key must be set.
|
||||
//
|
||||
// Returns any error which prevented the operation from completing correctly in error return.
|
||||
func PutObjectSingle(ctx context.Context, prm PutObjectPrm) (*PutObjectRes, error) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "client.PutObjectSingle")
|
||||
defer span.End()
|
||||
|
||||
objID, isSet := prm.obj.ID()
|
||||
if !isSet {
|
||||
return nil, errors.New("missing object id")
|
||||
}
|
||||
|
||||
var prmCli client.PrmObjectPutSingle
|
||||
|
||||
prmCli.ExecuteLocal()
|
||||
|
||||
if prm.key != nil {
|
||||
prmCli.UseKey(prm.key)
|
||||
}
|
||||
|
||||
if prm.tokenSession != nil {
|
||||
prmCli.WithinSession(*prm.tokenSession)
|
||||
}
|
||||
|
||||
if prm.tokenBearer != nil {
|
||||
prmCli.WithBearerToken(*prm.tokenBearer)
|
||||
}
|
||||
|
||||
prmCli.WithXHeaders(prm.xHeaders...)
|
||||
prmCli.SetObject(prm.obj.ToV2())
|
||||
|
||||
res, err := prm.cli.ObjectPutSingle(ctx, prmCli)
|
||||
if err != nil {
|
||||
ReportError(prm.cli, err)
|
||||
return nil, fmt.Errorf("put single object on client: %w", err)
|
||||
}
|
||||
|
||||
if err = apistatus.ErrFromStatus(res.Status()); err != nil {
|
||||
return nil, fmt.Errorf("put single object via client: %w", err)
|
||||
}
|
||||
|
||||
return &PutObjectRes{
|
||||
id: objID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// SearchObjectsPrm groups parameters of SearchObjects operation.
|
||||
type SearchObjectsPrm struct {
|
||||
readPrmCommon
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue