From 16aec657094d7196567bb4b117dc1e372fb4886f Mon Sep 17 00:00:00 2001 From: Egor Olefirenko Date: Tue, 12 Sep 2023 18:57:04 +0300 Subject: [PATCH 1/3] [#131] client: Switch ResolveFrostFSFailures to DontResolveFrostFSFailures option Signed-off-by: Egor Olefirenko --- README.md | 6 +++--- client/accounting.go | 6 +++--- client/client.go | 14 +++++++------- client/common.go | 2 +- client/container_delete.go | 6 +++--- client/container_eacl.go | 6 +++--- client/container_get.go | 6 +++--- client/container_list.go | 6 +++--- client/container_put.go | 6 +++--- client/container_set_eacl.go | 6 +++--- client/container_space.go | 6 +++--- client/netmap.go | 18 +++++++++--------- client/object_delete.go | 6 +++--- client/object_get.go | 6 +++--- client/object_hash.go | 6 +++--- client/object_put_transformer.go | 4 ++-- client/session.go | 6 +++--- 17 files changed, 58 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index e898e49..30fb6aa 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Contains client for working with FrostFS. ```go var prmInit client.PrmInit prmInit.SetDefaultPrivateKey(key) // private key for request signing -prmInit.ResolveFrostFSFailures() // enable erroneous status parsing +prmInit.DontResolveFrostFSFailures() // disable erroneous status parsing var c client.Client c.Init(prmInit) @@ -77,8 +77,8 @@ if needed and perform any desired action. In the case above we may want to repor these details to the user as well as retry an operation, possibly with different parameters. 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). There is also -a `client.PrmInit.ResolveFrostFSFailures()` to seamlessly convert erroneous statuses into Go error type. +[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. ### policy Contains helpers allowing conversion of placing policy from/to JSON representation diff --git a/client/accounting.go b/client/accounting.go index 021b26a..03f4cf9 100644 --- a/client/accounting.go +++ b/client/accounting.go @@ -64,9 +64,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmBalanceGet docs). // Context is required and must not be nil. It is used for network communication. diff --git a/client/client.go b/client/client.go index 3942390..310ab8d 100644 --- a/client/client.go +++ b/client/client.go @@ -144,7 +144,7 @@ func (c *Client) Close() error { // // See also Init. type PrmInit struct { - resolveFrostFSErrors bool + dontResolveFrostFSErrors bool key ecdsa.PrivateKey @@ -161,12 +161,12 @@ func (x *PrmInit) SetDefaultPrivateKey(key ecdsa.PrivateKey) { x.key = key } -// ResolveFrostFSFailures makes the Client to resolve failure statuses of the -// FrostFS protocol into Go built-in errors. These errors are returned from -// each protocol operation. By default, statuses aren't resolved and written -// to the resulting structure (see corresponding Res* docs). -func (x *PrmInit) ResolveFrostFSFailures() { - x.resolveFrostFSErrors = true +// DontResolveFrostFSFailures 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 } // SetResponseInfoCallback makes the Client to pass ResponseMetaInfo from each diff --git a/client/common.go b/client/common.go index 3895b00..ff08bf2 100644 --- a/client/common.go +++ b/client/common.go @@ -119,7 +119,7 @@ func (c *Client) processResponse(resp responseV2) (apistatus.Status, error) { } st := apistatus.FromStatusV2(resp.GetMetaHeader().GetStatus()) - if c.prm.resolveFrostFSErrors { + if !c.prm.dontResolveFrostFSErrors { return st, apistatus.ErrFromStatus(st) } return st, nil diff --git a/client/container_delete.go b/client/container_delete.go index 181c15b..43ddec7 100644 --- a/client/container_delete.go +++ b/client/container_delete.go @@ -101,9 +101,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Operation is asynchronous and no guaranteed even in the absence of errors. // The required time is also not predictable. diff --git a/client/container_eacl.go b/client/container_eacl.go index 2acde86..b28ad52 100644 --- a/client/container_eacl.go +++ b/client/container_eacl.go @@ -68,9 +68,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmContainerEACL docs). // Context is required and must not be nil. It is used for network communication. diff --git a/client/container_get.go b/client/container_get.go index d2ef0fe..72961b2 100644 --- a/client/container_get.go +++ b/client/container_get.go @@ -71,9 +71,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmContainerGet docs). // Context is required and must not be nil. It is used for network communication. diff --git a/client/container_list.go b/client/container_list.go index eb8cc88..48684b1 100644 --- a/client/container_list.go +++ b/client/container_list.go @@ -65,9 +65,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmContainerList docs). // Context is required and must not be nil. It is used for network communication. diff --git a/client/container_put.go b/client/container_put.go index f186abd..5e026d3 100644 --- a/client/container_put.go +++ b/client/container_put.go @@ -110,9 +110,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Operation is asynchronous and no guaranteed even in the absence of errors. // The required time is also not predictable. diff --git a/client/container_set_eacl.go b/client/container_set_eacl.go index 0ea89aa..af0ce3c 100644 --- a/client/container_set_eacl.go +++ b/client/container_set_eacl.go @@ -101,9 +101,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Operation is asynchronous and no guaranteed even in the absence of errors. // The required time is also not predictable. diff --git a/client/container_space.go b/client/container_space.go index c066c0a..bc11bc8 100644 --- a/client/container_space.go +++ b/client/container_space.go @@ -57,9 +57,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Operation is asynchronous and no guaranteed even in the absence of errors. // The required time is also not predictable. diff --git a/client/netmap.go b/client/netmap.go index 80d1ded..0e72233 100644 --- a/client/netmap.go +++ b/client/netmap.go @@ -53,9 +53,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmEndpointInfo docs). // Context is required and must not be nil. It is used for network communication. @@ -140,9 +140,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmNetworkInfo docs). // Context is required and must not be nil. It is used for network communication. @@ -204,9 +204,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly. // Context is required and MUST NOT be nil. It is used for network communication. diff --git a/client/object_delete.go b/client/object_delete.go index 993cd5d..a535752 100644 --- a/client/object_delete.go +++ b/client/object_delete.go @@ -112,9 +112,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmObjectDelete docs). // Context is required and must not be nil. It is used for network communication. diff --git a/client/object_get.go b/client/object_get.go index 56cbfda..fcf5e24 100644 --- a/client/object_get.go +++ b/client/object_get.go @@ -444,9 +444,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmObjectHead docs). // Context is required and must not be nil. It is used for network communication. diff --git a/client/object_hash.go b/client/object_hash.go index 7fdf335..2a99426 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -152,9 +152,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmObjectHash docs). // Context is required and must not be nil. It is used for network communication. diff --git a/client/object_put_transformer.go b/client/object_put_transformer.go index 402ad00..327cb58 100644 --- a/client/object_put_transformer.go +++ b/client/object_put_transformer.go @@ -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.resolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) { + if err == nil && it.client.prm.dontResolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) { err = apistatus.ErrFromStatus(it.res.st) } return err @@ -110,7 +110,7 @@ func (it *internalTarget) tryPutSingle(ctx context.Context, o *object.Object) (b statusRes: res.statusRes, obj: id, } - if !it.client.prm.resolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) { + if it.client.prm.dontResolveFrostFSErrors && !apistatus.IsSuccessful(it.res.st) { return true, apistatus.ErrFromStatus(it.res.st) } return true, nil diff --git a/client/session.go b/client/session.go index b3ec722..12cb2a1 100644 --- a/client/session.go +++ b/client/session.go @@ -89,9 +89,9 @@ 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.ResolveFrostFSFailures has been called, unsuccessful -// FrostFS status codes are returned as `error`, otherwise, are included -// in the returned result structure. +// If PrmInit.DontResolveFrostFSFailures has been called, unsuccessful +// FrostFS status codes are included in the returned result structure, +// otherwise, are also returned as `error`. // // Returns an error if parameters are set incorrectly (see PrmSessionCreate docs). // Context is required and must not be nil. It is used for network communication. -- 2.45.2 From d241aa92bf67104831c1550b16523ef2075ea8e8 Mon Sep 17 00:00:00 2001 From: Egor Olefirenko Date: Fri, 15 Sep 2023 18:52:08 +0300 Subject: [PATCH 2/3] [#131] client: rename option consistently and fix test Signed-off-by: Egor Olefirenko --- README.md | 4 ++-- client/accounting.go | 2 +- client/client.go | 8 ++++---- client/common.go | 2 +- client/container_delete.go | 2 +- client/container_eacl.go | 2 +- client/container_get.go | 2 +- client/container_list.go | 2 +- client/container_put.go | 2 +- client/container_set_eacl.go | 2 +- client/container_space.go | 2 +- client/netmap.go | 6 +++--- client/netmap_test.go | 1 + client/object_delete.go | 2 +- client/object_get.go | 2 +- client/object_hash.go | 2 +- client/object_put_transformer.go | 4 ++-- client/session.go | 2 +- 18 files changed, 25 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 30fb6aa..23704fb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/client/accounting.go b/client/accounting.go index 03f4cf9..c47de31 100644 --- a/client/accounting.go +++ b/client/accounting.go @@ -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`. // diff --git a/client/client.go b/client/client.go index 310ab8d..f1dacf1 100644 --- a/client/client.go +++ b/client/client.go @@ -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 diff --git a/client/common.go b/client/common.go index ff08bf2..ac9feb0 100644 --- a/client/common.go +++ b/client/common.go @@ -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 diff --git a/client/container_delete.go b/client/container_delete.go index 43ddec7..f750c90 100644 --- a/client/container_delete.go +++ b/client/container_delete.go @@ -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`. // diff --git a/client/container_eacl.go b/client/container_eacl.go index b28ad52..d577b7a 100644 --- a/client/container_eacl.go +++ b/client/container_eacl.go @@ -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`. // diff --git a/client/container_get.go b/client/container_get.go index 72961b2..4477973 100644 --- a/client/container_get.go +++ b/client/container_get.go @@ -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`. // diff --git a/client/container_list.go b/client/container_list.go index 48684b1..4197d3d 100644 --- a/client/container_list.go +++ b/client/container_list.go @@ -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`. // diff --git a/client/container_put.go b/client/container_put.go index 5e026d3..6ff4e5f 100644 --- a/client/container_put.go +++ b/client/container_put.go @@ -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`. // diff --git a/client/container_set_eacl.go b/client/container_set_eacl.go index af0ce3c..8ad808f 100644 --- a/client/container_set_eacl.go +++ b/client/container_set_eacl.go @@ -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`. // diff --git a/client/container_space.go b/client/container_space.go index bc11bc8..793f5f4 100644 --- a/client/container_space.go +++ b/client/container_space.go @@ -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`. // diff --git a/client/netmap.go b/client/netmap.go index 0e72233..c06f940 100644 --- a/client/netmap.go +++ b/client/netmap.go @@ -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`. // diff --git a/client/netmap_test.go b/client/netmap_test.go index 76920a1..4ec931e 100644 --- a/client/netmap_test.go +++ b/client/netmap_test.go @@ -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) diff --git a/client/object_delete.go b/client/object_delete.go index a535752..3f72e0c 100644 --- a/client/object_delete.go +++ b/client/object_delete.go @@ -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`. // diff --git a/client/object_get.go b/client/object_get.go index fcf5e24..03b91d2 100644 --- a/client/object_get.go +++ b/client/object_get.go @@ -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`. // diff --git a/client/object_hash.go b/client/object_hash.go index 2a99426..e65e948 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -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`. // diff --git a/client/object_put_transformer.go b/client/object_put_transformer.go index 327cb58..1fa474e 100644 --- a/client/object_put_transformer.go +++ b/client/object_put_transformer.go @@ -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 @@ -110,7 +110,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 diff --git a/client/session.go b/client/session.go index 12cb2a1..03ed5e8 100644 --- a/client/session.go +++ b/client/session.go @@ -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`. // -- 2.45.2 From 070db1d2c75d148a32faff29a34863dfccbf0bf2 Mon Sep 17 00:00:00 2001 From: Egor Olefirenko Date: Fri, 15 Sep 2023 21:31:02 +0300 Subject: [PATCH 3/3] [#131] client: keep backwards-compatibility, update README.md, fix chore Signed-off-by: Egor Olefirenko --- README.md | 2 -- client/client.go | 4 ++++ client/netmap_test.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 23704fb..2923408 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ Contains client for working with FrostFS. ```go var prmInit client.PrmInit prmInit.SetDefaultPrivateKey(key) // private key for request signing -prmInit.DisableFrostFSFailuresResolution() // disable erroneous status parsing var c client.Client c.Init(prmInit) @@ -78,7 +77,6 @@ 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.DisableFrostFSFailuresResolution()` to avoid returning erroneous statuses as Go built-in errors. ### policy Contains helpers allowing conversion of placing policy from/to JSON representation diff --git a/client/client.go b/client/client.go index f1dacf1..ba57b41 100644 --- a/client/client.go +++ b/client/client.go @@ -161,6 +161,10 @@ func (x *PrmInit) SetDefaultPrivateKey(key ecdsa.PrivateKey) { x.key = key } +// Deprecated: method is no-op. Option is default. +func (x *PrmInit) ResolveFrostFSFailures() { +} + // 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 diff --git a/client/netmap_test.go b/client/netmap_test.go index 4ec931e..bce6b3a 100644 --- a/client/netmap_test.go +++ b/client/netmap_test.go @@ -67,6 +67,7 @@ func TestClient_NetMapSnapshot(t *testing.T) { var res *ResNetMapSnapshot var srv serverNetMap c := newClient(&srv) + c.prm.DisableFrostFSFailuresResolution() ctx := context.Background() // request signature @@ -84,7 +85,6 @@ 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) -- 2.45.2