[#131] client: rename option consistently and fix test

Signed-off-by: Egor Olefirenko <egor.olefirenko892@gmail.com>
This commit is contained in:
Egor Olefirenko 2023-09-15 18:52:08 +03:00 committed by Evgenii Stratonikov
parent 9727beb47d
commit 0d79d10482
18 changed files with 25 additions and 24 deletions

View file

@ -42,7 +42,7 @@ Contains client for working with FrostFS.
```go
var prmInit client.PrmInit
prmInit.SetDefaultPrivateKey(key) // private key for request signing
prmInit.DontResolveFrostFSFailures() // disable erroneous status parsing
prmInit.DisableFrostFSFailuresResolution() // disable erroneous status parsing
var c client.Client
c.Init(prmInit)
@ -78,7 +78,7 @@ these details to the user as well as retry an operation, possibly with different
Status wire-format is extendable and each node can report any set of details it wants.
The set of reserved status codes can be found in
[FrostFS API](https://git.frostfs.info/TrueCloudLab/frostfs-api/src/branch/master/status/types.proto).
Use `client.PrmInit.DontResolveFrostFSFailures()` to avoid returning erroneous statuses as Go built-in errors.
Use `client.PrmInit.DisableFrostFSFailuresResolution()` to avoid returning erroneous statuses as Go built-in errors.
### policy
Contains helpers allowing conversion of placing policy from/to JSON representation

View file

@ -64,7 +64,7 @@ func (x ResBalanceGet) Amount() accounting.Decimal {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`,
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -144,7 +144,7 @@ func (c *Client) Close() error {
//
// See also Init.
type PrmInit struct {
dontResolveFrostFSErrors bool
disableFrostFSErrorResolution bool
key ecdsa.PrivateKey
@ -161,12 +161,12 @@ func (x *PrmInit) SetDefaultPrivateKey(key ecdsa.PrivateKey) {
x.key = key
}
// DontResolveFrostFSFailures makes the Client to preserve failure statuses of the
// DisableFrostFSFailuresResolution makes the Client to preserve failure statuses of the
// FrostFS protocol only in resulting structure (see corresponding Res* docs).
// These errors are returned from each protocol operation. By default, statuses
// are resolved and returned as a Go built-in errors.
func (x *PrmInit) DontResolveFrostFSFailures() {
x.dontResolveFrostFSErrors = true
func (x *PrmInit) DisableFrostFSFailuresResolution() {
x.disableFrostFSErrorResolution = true
}
// SetResponseInfoCallback makes the Client to pass ResponseMetaInfo from each

View file

@ -119,7 +119,7 @@ func (c *Client) processResponse(resp responseV2) (apistatus.Status, error) {
}
st := apistatus.FromStatusV2(resp.GetMetaHeader().GetStatus())
if !c.prm.dontResolveFrostFSErrors {
if !c.prm.disableFrostFSErrorResolution {
return st, apistatus.ErrFromStatus(st)
}
return st, nil

View file

@ -101,7 +101,7 @@ type ResContainerDelete struct {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -68,7 +68,7 @@ func (x ResContainerEACL) Table() eacl.Table {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -71,7 +71,7 @@ func (x ResContainerGet) Container() container.Container {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -65,7 +65,7 @@ func (x ResContainerList) Containers() []cid.ID {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -110,7 +110,7 @@ func (x ResContainerPut) ID() cid.ID {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -101,7 +101,7 @@ type ResContainerSetEACL struct {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -57,7 +57,7 @@ type ResAnnounceSpace struct {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -53,7 +53,7 @@ func (x ResEndpointInfo) NodeInfo() netmap.NodeInfo {
// Method can be used as a health check to see if node is alive and responds to requests.
//
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//
@ -140,7 +140,7 @@ func (x ResNetworkInfo) Info() netmap.NetworkInfo {
// NetworkInfo requests information about the FrostFS network of which the remote server is a part.
//
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//
@ -204,7 +204,7 @@ func (x ResNetMapSnapshot) NetMap() netmap.NetMap {
// NetMapSnapshot requests current network view of the remote server.
//
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -84,6 +84,7 @@ func TestClient_NetMapSnapshot(t *testing.T) {
srv.signResponse = true
// status failure
c.prm.DisableFrostFSFailuresResolution()
res, err = c.NetMapSnapshot(ctx, prm)
require.NoError(t, err)
assertStatusErr(t, res)

View file

@ -112,7 +112,7 @@ func (prm *PrmObjectDelete) buildRequest(c *Client) (*v2object.DeleteRequest, er
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`,
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -444,7 +444,7 @@ func (prm *PrmObjectHead) buildRequest(c *Client) (*v2object.HeadRequest, error)
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`,
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -152,7 +152,7 @@ func (prm *PrmObjectHash) buildRequest(c *Client) (*v2object.GetRangeHashRequest
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`,
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//

View file

@ -83,7 +83,7 @@ func (it *internalTarget) putAsStream(ctx context.Context, o *object.Object) err
wrt.WritePayloadChunk(ctx, o.Payload())
}
it.res, err = wrt.Close(ctx)
if err == nil && it.client.prm.dontResolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) {
if err == nil && it.client.prm.disableFrostFSErrorResolution && !apistatus.IsSuccessful(it.res.st) {
err = apistatus.ErrFromStatus(it.res.st)
}
return err
@ -115,7 +115,7 @@ func (it *internalTarget) tryPutSingle(ctx context.Context, o *object.Object) (b
statusRes: res.statusRes,
obj: id,
}
if it.client.prm.dontResolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) {
if it.client.prm.disableFrostFSErrorResolution && !apistatus.IsSuccessful(it.res.st) {
return true, apistatus.ErrFromStatus(it.res.st)
}
return true, nil

View file

@ -89,7 +89,7 @@ func (x ResSessionCreate) PublicKey() []byte {
//
// Exactly one return value is non-nil. By default, server status is returned in res structure.
// Any client's internal or transport errors are returned as `error`.
// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful
// If PrmInit.DisableFrostFSFailuresResolution has been called, unsuccessful
// FrostFS status codes are included in the returned result structure,
// otherwise, are also returned as `error`.
//