From 6994eb0e553b20bb62c21de75be590c6ef997d89 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 4 Jul 2022 18:33:33 +0300 Subject: [PATCH] [#222] client: Fix docs of resolving the failure statuses Signed-off-by: Leonard Lyubich --- README.md | 28 ++++++++++++++++++++-------- client/accounting.go | 2 +- client/container.go | 14 +++++++------- client/netmap.go | 4 ++-- client/object_delete.go | 2 +- client/object_get.go | 2 +- client/object_hash.go | 2 +- client/reputation.go | 4 ++-- client/session.go | 2 +- 9 files changed, 36 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 6740d976..e6974e95 100644 --- a/README.md +++ b/README.md @@ -40,21 +40,33 @@ to perform certain actions on behalf of the user. ### client Contains client for working with NeoFS. ```go -c, _ := client.New( - client.WithAddress("localhost:40005"), // endpoint address - client.WithDefaultPrivateKey(key), // private key for request signing - client.WithNeoFSErrorHandling(), // enable erroneous status parsing - client.WithTLSConfig(&tls.Config{})) // custom TLS configuration +var prmInit client.PrmInit +prmInit.SetDefaultPrivateKey(key) // private key for request signing +prmInit.ResolveNeoFSFailures() // enable erroneous status parsing + +var c client.Client +c.Init(prmInit) + +var prmDial client.PrmDial +prmDial.SetServerURI("grpcs://localhost:40005") // endpoint address + +err := c.Dial(prmDial) +if err != nil { + return +} ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second) defer cancel() -res, err := c.BalanceGet(ctx, owner) +var prm client.PrmBalanceGet +prm.SetAccount(acc) + +res, err := c.BalanceGet(ctx, prm) if err != nil { return } -fmt.Printf("Balance for %s: %s\n", owner, res.Amount()) +fmt.Printf("Balance for %s: %v\n", acc, res.Amount()) ``` #### Response status @@ -66,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 [NeoFS API](https://github.com/nspcc-dev/neofs-api/blob/master/status/types.proto). There is also -a `client.WithNeoFSErrorHandling()` to seamlessly convert erroneous statuses into Go error type. +a `client.PrmInit.ResolveNeoFSFailures()` to seamlessly convert erroneous statuses into Go error type. ### policy Contains helpers allowing conversion of placing policy from/to JSON representation diff --git a/client/accounting.go b/client/accounting.go index acf4d84a..7f77b1fc 100644 --- a/client/accounting.go +++ b/client/accounting.go @@ -48,7 +48,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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // diff --git a/client/container.go b/client/container.go index ed5337fe..d8d5cdb7 100644 --- a/client/container.go +++ b/client/container.go @@ -74,7 +74,7 @@ func (x *ResContainerPut) setID(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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -208,7 +208,7 @@ func (x *ResContainerGet) setContainer(cnr 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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -317,7 +317,7 @@ func (x *ResContainerList) setContainers(ids []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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -419,7 +419,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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -545,7 +545,7 @@ func (x *ResContainerEACL) setTable(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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -651,7 +651,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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -756,7 +756,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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // diff --git a/client/netmap.go b/client/netmap.go index ca45b66b..096ee0e2 100644 --- a/client/netmap.go +++ b/client/netmap.go @@ -53,7 +53,7 @@ func (x *ResEndpointInfo) setNodeInfo(info *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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -150,7 +150,7 @@ func (x *ResNetworkInfo) setInfo(info *netmap.NetworkInfo) { // NetworkInfo requests information about the NeoFS network of which the remote server is a part. // // Any client's internal or transport errors are returned as `error`. -// If WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // diff --git a/client/object_delete.go b/client/object_delete.go index eb7fb73b..3598e024 100644 --- a/client/object_delete.go +++ b/client/object_delete.go @@ -117,7 +117,7 @@ func (x ResObjectDelete) ReadTombstoneID(dst *oid.ID) bool { // // 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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // diff --git a/client/object_get.go b/client/object_get.go index 39b3fc47..7ea20e72 100644 --- a/client/object_get.go +++ b/client/object_get.go @@ -432,7 +432,7 @@ func (x *ResObjectHead) ReadHeader(dst *object.Object) bool { // // 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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // diff --git a/client/object_hash.go b/client/object_hash.go index 61f20f25..16b8b933 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -140,7 +140,7 @@ func (x ResObjectHash) Checksums() [][]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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // diff --git a/client/reputation.go b/client/reputation.go index 35c211a7..a37a1e2c 100644 --- a/client/reputation.go +++ b/client/reputation.go @@ -41,7 +41,7 @@ type ResAnnounceLocalTrust 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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // @@ -142,7 +142,7 @@ type ResAnnounceIntermediateTrust 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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. // diff --git a/client/session.go b/client/session.go index 26f053a5..754a7be6 100644 --- a/client/session.go +++ b/client/session.go @@ -68,7 +68,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 WithNeoFSErrorParsing option has been provided, unsuccessful +// If PrmInit.ResolveNeoFSFailures has been called, unsuccessful // NeoFS status codes are returned as `error`, otherwise, are included // in the returned result structure. //