Passing `nil` context to `rpc.Balance` leads to panic. To prevent panic,
we need to provide some default context in `Dial`.
Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
In previous implementation of `Client.Dial` there was no ability to
specify parent context (e.g. global application context).
Add `PrmDial.SetContext` method which accepts optional base dial
context. Use the context to open client connection or fall back to using
`context.Background()`.
Upgraded version of `github.com/nspcc-dev/neofs-api-go/v2` module
also fixes the problem when dial timeout didn't work properly.
Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
There is a need to test each `Client` operation. In previous
implementation `Client` was based on real socket connection. This didn't
allow to test the `Client` without OS resources. In order to write
convenient and useful unit tests we need to slightly refactor the code.
Introduce `neoFSAPIServer` interface as a provider of `Client` type's
abstraction from the exact NeoFS API server. Add `netMapSnapshot` method
for initial implementation. Define core interface provider used in real
code. Set `coreServer` as an underlying `neoFSAPIServer` in
`Client.Dial`. Cover `Client.NetMapSnapshot` method with unit tests
using the opportunity to override the server.
From now client library can be tested not only with real physical
listeners but with imitations.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Use `node is under maintenance` message in `NodeUnderMaintenance.Error`
is `message` field is unset in the status message.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Support decoding `NodeUnderMaintenance` status errors in `FromStatusV2`
function.
From now `NodeUnderMaintenance` instance can be decoded from
`status.Status` message of NeoFS API V2 protocol.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
In previous implementation `ObjectWrite.Close` called `close` method
which in turn called `result` callback. Thus failed statuses could lead
to false-positive result processing.
Replace calling `close` method with direct `closer` method's call in
`ObjectWrite.Close`.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
In previous implementation `client` package provided access to nested
response fields as pointers to them. This caused clients to handle nil
cases even when the field presence in the response is required.
Avoid returning pointers to required fields in response getters. This
also reduces reference counter load and allows fields to be decoded
directly without additional assignment.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Return `error` from all `ReadFromV2` methods in order to support
backward compatibility if message will be extended with some formatted
field.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>