`CreateObject` function uses `slicer.Slicer` to read data encapsulated
behind `io.Reader` and store it in the NeoFS network. Sometimes there is
a need to init data writer (`io.Writer`)` instead of providing reader.
To cover such use-cases, it's worth to expose slicer's constructor based
on client.
Add `NewDataSlicer` constructor. Use the function in `CreateObject`.
Refs #342.
Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Homomorphic hashing of object payload is not always necessary. There is
a need to provide ability to skip calculation. It's also worth to not
calculate it by default since current implementation of Tillich-Zemor
algorithm has large resource cost.
Do not calculate homomorphic checksum in `Slicer` methods by default.
Provide option to enable the calculation. Make tests to randomize
calculation flag and assert results according to it.
Refs #342.
Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
Add `CreateObject` function which slices data stream into NeoFS objects
and saves the produced objects in the NeoFS network using `Client`.
Closes#342.
Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
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>