Commit graph

42 commits

Author SHA1 Message Date
Leonard Lyubich
2f783dfad7 [#323] pkg/client: Prevent corruption of parameterized session token
Create new `SessionTokenBody` instead of using one from the parameter in
order to prevent data corruption.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-07-06 11:48:17 +03:00
Leonard Lyubich
6d531a07a5
[#313] client/object: Always return number of bytes read from Get stream (#316)
Fix failure to comply with a requirement of stdlib `io.Reader` docs: `When
Read encounters an error or end-of-file condition after successfully reading
n > 0 bytes, it returns the number of bytes read.`

Prepare a platform for unit tests and test the affected case.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-23 14:15:58 +03:00
Leonard Lyubich
fdea892db7 [#313] client/object: Add payload-handling parameter to GetObjectParams
Define `ReaderHandler` type. Add `GetObjectParams.WithPayloadReaderHandler`
method which accepts `ReaderHandler`. The handler is called right after
header receipt in `Client.GetObject`. After the handler is called,
`GetObject` returns object header immediately.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-22 17:54:39 +03:00
Leonard Lyubich
65080c8b69 [#295] pkg: Remove usage of deprecated elements
Remove usage of deprecated of `container.ID` and `token.SessionToken` code
elements. Replace using of custom message generators with the ones provided
by packages. Replace string comparison with `Equal` method call.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-06-01 08:04:12 +03:00
Evgenii Stratonikov
9ddfcdfbba [#277] go.mod: remove pkg/errors
Use stdlib `errors` instead.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-05-19 11:14:56 +03:00
Leonard Lyubich
fcb2cce8a0 [#278] pkg/client: Fix payload slice allocation in Object Range method
Allocate capacity instead of length of the slice to write the object payload
range since each chunk is written through `append`.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-04-30 11:15:35 +03:00
Leonard Lyubich
a43175e2ea [#263] pkg/client: Split interface method's declarations with linebreaks
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00
Leonard Lyubich
c819909906 [#263] pkg/client: Refactor the client to use raw protobuf client
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>
2021-03-17 14:03:49 +03:00
Evgenii Stratonikov
ae2fb263f1 [#266] pkg/client: Export Client interface instead of structure
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>
2021-03-17 13:43:22 +03:00
Evgenii Stratonikov
64505180b4 [#261] pkg/client: Provide signing key in call options
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>
2021-03-12 10:40:10 +03:00
Alex Vanin
9401724b9c [#246] pkg/client: Use io.Reader wrapper at object put
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>
2021-01-25 13:25:52 +03:00
Alex Vanin
8a82400451 [#243] Fix golint linter errors
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-01-12 18:22:07 +03:00
Leonard Lyubich
37e2cab93b [#229] pkg/client: Set hash fields to result of short HEAD operation
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-12-25 16:20:26 +03:00
Leonard Lyubich
1bc91466aa sdk/client: Fix setter of objectAddressWriter structure value
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-12-11 11:19:45 +03:00
Leonard Lyubich
803c91b3eb [#226] sdk/client: Add tombstone address to the return of DeleteObject
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-12-10 18:26:23 +03:00
Alex Vanin
139660c6ff [#225] pkg/client: Update object methods
- Support errors with SplitInfo in head and range methods.
- Support raw flat in range method.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-08 10:23:27 +03:00
Alex Vanin
28aad71860 [#225] Do not use wrappers on oneof object.HeadResponse types
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-08 10:23:27 +03:00
Alex Vanin
6db6b569e0 [#223] pkg/client: Add getters for object params
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-03 18:07:42 +03:00
Alex Vanin
664ebfd8a7 [#218] pkg/client: Add raw flag for object.Head
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-03 16:09:38 +03:00
Alex Vanin
582cdd4ba3 [#218] pkg/client: Add raw flag for object.Get
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-03 16:09:38 +03:00
Alex Vanin
e11b1728be [#218] pkg/object: Define custom error for SplitInfo
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-03 16:09:38 +03:00
Alex Vanin
1fdeca84e1 [#218] Support SplitInfo structure
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-12-03 16:09:38 +03:00
Leonard Lyubich
5ee500bb43 [#205] sdk/client: Support option to set dial timeout
There is a need to set dial timeout in SDK client that is used in case of
internal connection opening. Add DialTimeout option constructor to support
this feature.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-23 14:15:42 +03:00
Alex Vanin
9ceba98198 [#202] pkg/client: Fix signature check in object header getter
According to API object.Head response contains signature of
object ID rather than signature of object header itself.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-11-17 16:23:44 +03:00
Leonard Lyubich
0620a3b1eb [#199] sdk/client: Correct linter's remarks
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-16 18:51:14 +03:00
Leonard Lyubich
3097059f85 [#199] sdk/client: Verify header signature in GetObjectHeader method
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-16 18:51:14 +03:00
Leonard Lyubich
5f5e5ac5dd [#197] sdk/object: Rename getters of Attribute and Object types
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-16 11:52:21 +03:00
Leonard Lyubich
67bcf6eb4d [#197] sdk/object: Rename getters of Address type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-16 11:52:21 +03:00
Leonard Lyubich
2bcbd48972 [#197] sdk: Rename getters of Version type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-11-16 11:52:21 +03:00
Leonard Lyubich
805ad54f41 [#180] sdk/client: Make defaultOptions func a Client method
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-10-28 12:15:49 +03:00
Alex Vanin
7b3736567c [#169] sdk/client: Do not resign session token
In some cases SDK Client provided with signed and prepared
session token. In this case we don't need to change verb
or sign it.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-14 21:09:56 +03:00
Leonard Lyubich
2cc58e36f8 [#160] sdk/client: Set object identifier in Head result
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-25 17:37:44 +03:00
Alex Vanin
c814cc62fa [#158] pkg/client: Ignore EOF on buffer copy in object.Put
There is a issue when user sends payload chunk to the neofs
node, but node closes connection earlier, e.g. node can return
error as soon as it checked ACL permission and denied request.

In this case client will receive EOF error and it produces
`could not send payload bytes to Put object stream` error, but
in fact there is different error.

If we ignore EOF there then `stream.CloseAndRecv()` return
correct error message later.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-09-25 15:58:40 +03:00
Leonard Lyubich
d19e5418da [#159] sdk: Define object range in object pkg
Define Range type in object package. Replace Range in client package with
the new one.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-25 15:58:24 +03:00
Leonard Lyubich
0259a06783 [#150] sdk/token: Add owner ID
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:45:11 +03:00
Alex Vanin
73220620c5 [#148] sdk/client: Support object search rpc
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-09-18 10:45:11 +03:00
Alex Vanin
5fa271e141 [#144] sdk/client: Add call option to set session token
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-09-18 10:45:11 +03:00
Leonard Lyubich
644a21edca [#141] sdk/client: Fix object operations
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:45:11 +03:00
Leonard Lyubich
e0c34a51f2 [#140] sdk: Refactor version type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:45:11 +03:00
Leonard Lyubich
524280a5e8 [#140] sdk: Refactor reference types
Refactor v2-compatible reference types to be wrappers over corresponding
types from v2.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:45:11 +03:00
Alex Vanin
efbf73b775 [#138] sdk/object: Fix head request
Now head request returns full header with signature.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-09-18 10:45:11 +03:00
Leonard Lyubich
b19e3a48db [#135] sdk/client: Implement object operations
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-09-18 10:45:11 +03:00