Make `Client` to be the wrapper over raw protobuf client. Provide public
method to get the underlying raw client. Change implementations of all
methods with the new approach of the RPC execution.
Additional changes:
* key replaced from `New` argument to `WithDefaultPrivateKey` option;
* `GetSelfBalance` is removed as non-viable;
* `GetEACLWithSignature` is removed, `GetEACL` returns `EACLWithSignature`;
* `AttachSessionToken` / `AttachBearerToken` are removed as non-viable;
* redundant options are removed.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Implement `message.Message` interface on all structures and use new methods
for conversion instead of functions. make `Unmarshal` and JSON methods to
use encoding functions from `message` library. Remove all per-service
clients and implement `rpc` library of the functions which execute NeoFS API
RPC through new RPC client. Remove no longer used gRPC per-service clients.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Implement generic `Client` that can communicate with the remote server via
protobuf `Message`'s. The client can uniformly execute any protobuf RPC
on the remote server using any of the supported transport protocols.
Currently only gRPC protocol is supported.
Additionally implement helpful functions to transmit messages by one of the
flow types: unary, client- or server-side stream.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Define `Message` interface of the generic protobuf message. In the initial
implementation, the message should be convertible to and from related gRPC
message.
Implement encoding functions over the `Message` that can:
* unmarshal the `Message` via related gRPC message;
* decode the `Message` from JSON format via related gRPC message;
* encode the `Message` to JSON.
Implement nested `test` package for testing the implementation.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Implement gRPC client that can uniformly execute any RPC on the remote
server. In the primary implementation, the client is a thin wrapper over
gRPC client connection that is required to create the client. In the future,
it is planned to expand the library with convenient functionality.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
Make it easier to test API clients and mock specific methods.
Also add comments on exported methods.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
Allow to reuse underlying connection for requests
with different key. If no key is specified the one
provided on client creation is used.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
Rename `PriceAttr` constant to `AttrPrice`. Rename `CapacityAttr` constant
to `AttrCapacity`. Add documentation to both of them.
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
If CBF value is not set, then netmap package uses default CBF
value. However it modifies placement policy structure in
`GetContainerNodes()` because policy passed as a pointer.
Instead package can store CBF value in internal context and use
it without policy modification.
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
Object payload transferred in chunks. Size of the
chunks may be limited by transport protocols. To
split it we use `io.CopyBuffer` with pre-allocated
buffer size of one chunk. However this function may
ignore buffer if reader or writer implements
`WriteTo` or `ReadFrom` methods. Unfortunately
`bytes.Reader` implements `WriteTo` function.
To fix this we wrap reader so wrapper implements
only `io.Reader` interface.
Related to github.com/nspcc-dev/neofs-node/issues/338
Signed-off-by: Alex Vanin <alexey@nspcc.ru>