forked from TrueCloudLab/frostfs-node
[#961] *: Support NeoFS API status returns
Upgrade NeoFS API Go library to version with status returns. Make all API clients to pull out and return errors from failed statuses. Make signature service to respond with status if client version supports it. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
44d0d453ef
commit
7f5fb130c0
27 changed files with 618 additions and 415 deletions
|
@ -312,7 +312,8 @@ func (r *remoteLoadAnnounceWriter) Put(a containerSDK.UsedSpaceAnnouncement) err
|
|||
}
|
||||
|
||||
func (r *remoteLoadAnnounceWriter) Close() error {
|
||||
return r.client.AnnounceContainerUsedSpace(r.ctx, r.buf, apiClient.WithKey(r.key))
|
||||
_, err := r.client.AnnounceContainerUsedSpace(r.ctx, r.buf, apiClient.WithKey(r.key))
|
||||
return err
|
||||
}
|
||||
|
||||
type loadPlacementBuilder struct {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
|
@ -474,68 +473,60 @@ func (c *reputationClient) submitResult(err error) {
|
|||
c.cons.trustStorage.Update(prm)
|
||||
}
|
||||
|
||||
func (c *reputationClient) PutObject(ctx context.Context, prm *client.PutObjectParams, opts ...client.CallOption) (*objectSDK.ID, error) {
|
||||
id, err := c.Client.PutObject(ctx, prm, opts...)
|
||||
func (c *reputationClient) PutObject(ctx context.Context, prm *client.PutObjectParams, opts ...client.CallOption) (*client.ObjectPutRes, error) {
|
||||
res, err := c.Client.PutObject(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return id, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *reputationClient) DeleteObject(ctx context.Context, prm *client.DeleteObjectParams, opts ...client.CallOption) error {
|
||||
err := c.Client.DeleteObject(ctx, prm, opts...)
|
||||
func (c *reputationClient) DeleteObject(ctx context.Context, prm *client.DeleteObjectParams, opts ...client.CallOption) (*client.ObjectDeleteRes, error) {
|
||||
res, err := c.Client.DeleteObject(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return err
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *reputationClient) GetObject(ctx context.Context, prm *client.GetObjectParams, opts ...client.CallOption) (*objectSDK.Object, error) {
|
||||
obj, err := c.Client.GetObject(ctx, prm, opts...)
|
||||
func (c *reputationClient) GetObject(ctx context.Context, prm *client.GetObjectParams, opts ...client.CallOption) (*client.ObjectGetRes, error) {
|
||||
res, err := c.Client.GetObject(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return obj, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *reputationClient) GetObjectHeader(ctx context.Context, prm *client.ObjectHeaderParams, opts ...client.CallOption) (*objectSDK.Object, error) {
|
||||
obj, err := c.Client.GetObjectHeader(ctx, prm, opts...)
|
||||
func (c *reputationClient) HeadObject(ctx context.Context, prm *client.ObjectHeaderParams, opts ...client.CallOption) (*client.ObjectHeadRes, error) {
|
||||
res, err := c.Client.HeadObject(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return obj, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *reputationClient) ObjectPayloadRangeData(ctx context.Context, prm *client.RangeDataParams, opts ...client.CallOption) ([]byte, error) {
|
||||
rng, err := c.Client.ObjectPayloadRangeData(ctx, prm, opts...)
|
||||
func (c *reputationClient) ObjectPayloadRangeData(ctx context.Context, prm *client.RangeDataParams, opts ...client.CallOption) (*client.ObjectRangeRes, error) {
|
||||
res, err := c.Client.ObjectPayloadRangeData(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return rng, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *reputationClient) ObjectPayloadRangeSHA256(ctx context.Context, prm *client.RangeChecksumParams, opts ...client.CallOption) ([][sha256.Size]byte, error) {
|
||||
hashes, err := c.Client.ObjectPayloadRangeSHA256(ctx, prm, opts...)
|
||||
func (c *reputationClient) HashObjectPayloadRanges(ctx context.Context, prm *client.RangeChecksumParams, opts ...client.CallOption) (*client.ObjectRangeHashRes, error) {
|
||||
res, err := c.Client.HashObjectPayloadRanges(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return hashes, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *reputationClient) ObjectPayloadRangeTZ(ctx context.Context, prm *client.RangeChecksumParams, opts ...client.CallOption) ([][client.TZSize]byte, error) {
|
||||
hashes, err := c.Client.ObjectPayloadRangeTZ(ctx, prm, opts...)
|
||||
func (c *reputationClient) SearchObjects(ctx context.Context, prm *client.SearchObjectParams, opts ...client.CallOption) (*client.ObjectSearchRes, error) {
|
||||
res, err := c.Client.SearchObjects(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return hashes, err
|
||||
}
|
||||
|
||||
func (c *reputationClient) SearchObject(ctx context.Context, prm *client.SearchObjectParams, opts ...client.CallOption) ([]*objectSDK.ID, error) {
|
||||
ids, err := c.Client.SearchObject(ctx, prm, opts...)
|
||||
|
||||
c.submitResult(err)
|
||||
|
||||
return ids, err
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (c *reputationClientConstructor) Get(info coreclient.NodeInfo) (client.Client, error) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"crypto/ecdsa"
|
||||
|
||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/reputation"
|
||||
)
|
||||
|
||||
|
@ -65,7 +66,13 @@ type AnnounceLocalRes struct{}
|
|||
//
|
||||
// Returns any error prevented the operation from completing correctly in error return.
|
||||
func AnnounceLocal(prm AnnounceLocalPrm) (res AnnounceLocalRes, err error) {
|
||||
_, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
||||
var cliRes *client.AnnounceLocalTrustRes
|
||||
|
||||
cliRes, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
||||
if err == nil {
|
||||
// pull out an error from status
|
||||
err = apistatus.ErrFromStatus(cliRes.Status())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -102,7 +109,13 @@ type AnnounceIntermediateRes struct{}
|
|||
//
|
||||
// Returns any error prevented the operation from completing correctly in error return.
|
||||
func AnnounceIntermediate(prm AnnounceIntermediatePrm) (res AnnounceIntermediateRes, err error) {
|
||||
_, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
||||
var cliRes *client.AnnounceIntermediateTrustRes
|
||||
|
||||
cliRes, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
||||
if err == nil {
|
||||
// pull out an error from status
|
||||
err = apistatus.ErrFromStatus(cliRes.Status())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue