Commit graph

152 commits

Author SHA1 Message Date
Leonard Lyubich
0fb22361a3 [#127] apistatus: Support WRONG_MAGIC_NUMBER status
Define `WrongMagicNumber` type for which encapsulates the work with
incorrect network magic. Provide method to read/write the correct magic
(which is a status detail in NeoFS API V2 protocol).

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-02-01 17:02:58 +03:00
Leonard Lyubich
883a26d210 [#92] client: Add docs about status returns
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-02-01 17:02:43 +03:00
Leonard Lyubich
213d20e3fb [#92] client: Accept structured parameters in non-object operations
Define `XPrm` type for each `X` client operation which structures
parameters. Export setters of each parameterized value. Emphasize that
some parameters are required. Make the client panic when the parameters
are incorrectly set. Get rid of vadiadic call options and `CallOption`
type. Improve documentation of client behavior.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-02-01 17:02:43 +03:00
Evgenii Stratonikov
596774ce5b [#103] owner: remove NEO3Wallet type
Allow to use public keys and N3 wallet accounts instead.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-21 11:01:44 +03:00
Evgenii Stratonikov
f83ff628fb [#36] eacl: add eACL table to ValidationUnit
Improve SDK usability a bit:
1. Replace bearer and storage with a single eACL table. This way
   caller can implement it's own behaviour for missing eACL.
2. Remove logging. SDK library shouldn't be dependent on a specific
   logger.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-19 11:06:27 +03:00
Evgenii Stratonikov
8c5a596ea2 [#36] eacl: add tests for filter match
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-19 11:06:27 +03:00
Evgenii Stratonikov
be9bc5d612 [#36] eacl: add tests for operation match
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-19 11:06:27 +03:00
Evgenii Stratonikov
3a0c9e4542 [#36] eacl: add eACL checking algorithm from neofs-node
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-19 11:06:27 +03:00
Evgenii Stratonikov
ea5da31bd2 [#109] netmap: add 1 more test in JSON
Move `PlacementPolicy_ProcessSelectors` test. It tests how good
nodes were grouped into buckets after selection, but we can still query
full results and check them.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-18 13:50:48 +03:00
Denis Kirillov
dd91fbd6ef [#118] Use correct owner in session token
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-01-18 13:21:40 +03:00
Evgenii Stratonikov
feb40146b7 [#109] netmap: describe JSON test format
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-18 13:06:25 +03:00
Evgenii Stratonikov
2f446c8e42 [#109] netmap: convert tests to the json format
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-01-18 13:06:25 +03:00
Leonard Lyubich
49a17a7159 [#119] client: Configure network magic
In the latest NeoFS protocol update, each request is provided with a
network magic number. We have to provide the ability to set it on
the client.

Add `WithNetworkMagic` option constructor which accepts magic number.
Write the number to meta header of the all requests.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-01-14 14:48:29 +03:00
Pavel Karpy
7f31621106 [#114] pool: Use "simple" error handling in pool
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-13 15:37:43 +03:00
Pavel Karpy
ecb441639e [#114] client: Fix comments according to new option
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-13 15:37:43 +03:00
Pavel Karpy
2a6fe47e5e [#114] client: Add WithNeoFSErrorParsing option
This option make client parse all NeoFS error statuses and return them as
errors from method calls (not as part of result structure). This is done
for applications that want to handle errors as it is customary in golang.
Default behaviour (construction client without new option) has not been
changed.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-13 15:37:43 +03:00
Pavel Karpy
13d72efd60 [#111] client: Add comments to Client and New
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-11 11:03:14 +03:00
Pavel Karpy
b50bff53e7 [#111] pool: Adopt new client.New signature
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-11 11:03:14 +03:00
Pavel Karpy
543291f8c5 [#111] client: Add comments to client's public methods
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-11 11:03:14 +03:00
Pavel Karpy
09f7df10ed [#111] client: Fix doc comments
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-11 11:03:14 +03:00
Pavel Karpy
cb42437e5c [#111] client: Drop client.Client interface
Return structure instead.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-01-11 11:03:14 +03:00
Denis Kirillov
66d71cde30 [#106] Add extra descriptions for constants
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-01-11 11:01:37 +03:00
Denis Kirillov
2d597c1be8 [#106] Use BasicACL instead of uint32
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-01-11 11:01:37 +03:00
Denis Kirillov
b5235bdf34 [#106] Add stringer and tests
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-01-11 11:01:37 +03:00
Denis Kirillov
bd110d8b41 [#106] Add basic ACL parser
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-01-11 11:01:37 +03:00
Denis Kirillov
d4d0feb59d [#106] Add public constants for well-known names
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2022-01-11 11:01:37 +03:00
Elizaveta Chichindaeva
1fe37df88f [#104] Add ACL constants to acl/types.go
- New non-final ACL constants for which eACL can be set
- Changed comments

Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2021-12-30 10:29:47 +03:00
Evgenii Stratonikov
3edaf9ecb6 netmap: sort buckets by HRW value
If weights for some buckets are equal, result depends on the
initial positions of buckets in slice. Thus we sort buckets by value
using hash of the first node as a have for the whole bucket.
This is ok, because buckets are already sorted by HRW.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-12-28 15:59:35 +03:00
Alex Vanin
f7582399ed [#107] client: Provide RWTimeout option
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-12-28 15:59:21 +03:00
Alex Vanin
2fd5802c48 [#105] pool: Add balance command
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-12-17 15:11:23 +03:00
Alex Vanin
b1770ecb92 [#70] pool: Ignore default session token in non object service requests
Default session token is created for object service requests
and should not be reused in container or any other service requests.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-12-16 19:14:45 +03:00
Denis Kirillov
2806d90089 [#93] Remove golang.org/x/crypto dependency
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2021-12-14 15:27:04 +03:00
Denis Kirillov
a2572a23a3 [#93] Return NNS resolver
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2021-12-14 15:27:04 +03:00
Leonard Lyubich
a5b61c4f64 [#96] Downgrade github.com/golang/mock module version
Downgrade `gomock` dependency to `v1.5.0` in order to import latest SDK
library to `neo-go`. Later version `v1.6.0` upgrades `golang
.org/x/tools` module which break Neo Go compiler (see neo-go#2086).

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-12-01 21:24:51 +03:00
Pavel Karpy
471ed5a3ec [#95] go.mod: Update api-go/v2 package.
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-12-01 16:55:01 +03:00
Evgenii Stratonikov
3d0df0d068 [#54] tests: unify test generator names
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-12-01 10:34:54 +03:00
Denis Kirillov
fa7c01bd0b [#74] Fix some tests
For some tests enough empty results.

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2021-11-26 16:17:45 +03:00
Denis Kirillov
618eeb8172 [#74] Add priority to nodes
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
2021-11-26 16:17:45 +03:00
Evgenii Stratonikov
279a5a1e0b [#80] netmap: process subnet in selection
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-11-26 15:52:08 +03:00
Evgenii Stratonikov
b49404d9b6 [#80] netmap: add NodeInfo.ExitSubnet method
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-11-26 15:52:08 +03:00
Leonard Lyubich
29f589b54e [#94] subnet: Add methods to check subnet owner and ID
Implement `IsOwner` and `IDEquals` functions which check the
correspondence of the fields in `Info`. Remove no longer needed
`HasOwner` method of `Info`.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-26 15:51:53 +03:00
Leonard Lyubich
8175462050 [#79] Implement type for subnet information
Create `subnet` package. Define `Info` type of the subnet info. Support
encoding and transport over the NeoFS API V2 protocol. Add methods to
work with identifier and owner.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-25 13:04:24 +03:00
Leonard Lyubich
755c01264e [#79] subnet/id: Add function which resets ID to zero subnet
Add `MakeZero` function which makes `ID` instance to refer to zero
subnet.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-25 13:04:24 +03:00
Leonard Lyubich
e7ac7f339e [#82] netmap: Add functionality for working with subnets
* Implement `NodeInfo.EnterSubnet` method which adds node's subnet.
  * Implement `NodeInfo.IterateSubnets` which behaves similar to
  eponymous function from neofs-api-go/v2.
  * Implement `BelongsToSubnet` which checks if `NodeInfo` describes the
  node belonging to a specific subnet.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-25 13:04:24 +03:00
Leonard Lyubich
b8989e3abb [#79] Implement type for subnet ID
Create `subnet` package. Define `ID` type of subnet identifiers.
Implement encoding and support NeoFS API V2 protocol. Provide method to
init instance from integer. Implement function which checks if `ID`
instance refers to zero subnet.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-25 13:04:24 +03:00
Leonard Lyubich
d9317cbea1 [#83] pool: Temporary skip tests with mocked client
After update of `client.Client` interface it can't be mocked.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-23 13:03:40 +03:00
Leonard Lyubich
639ab1e443 [#83] pool: Support changes of client.Client interface
Handle status results and return status failures in `error` return.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-23 13:03:40 +03:00
Leonard Lyubich
87cbd4b701 [#83] pkg: Upgrade NeoFS API protocol version to 2.11
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-23 13:03:40 +03:00
Leonard Lyubich
bf78cddf69 [#83] pkg/client: Support status returns
Make all `Client` methods to return structured values and error. Parse v2
status messages in all RPC and provide status getter from all result
structures. Returns status failures as status result instead of error.

Interface changes:
  * all methods return `<method>Res` structure;
  * rename some methods to be more clear;
  * unify TZ and SHA256 objecy payload hashing in single method.

Behavior changes:
  * client doesn't verify object header structure received via Object.Head.
    If the caller was tied to verification, now it must do it explicitly.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-23 13:03:40 +03:00
Leonard Lyubich
9dcff95a29 [#83] client: Implement status library
Define base `Status` interface. Provide the functionality to distinguish
success and failure returns. Provide functionality to transport statuses
over NeoFS API V2 protocol. Support success `OK` and failure `INTERNAL`
returns.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-11-23 13:03:40 +03:00