Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use github.com/nspcc-dev/neofs-api-go/v2 where unnecessary #3057

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7af817b
cli/control: Do not use API client from NeoFS SDK
cthulhu-rider Dec 18, 2024
933c9ab
cli/control: Do not lose errors
cthulhu-rider Dec 18, 2024
7fa03a5
*: Avoid importing `github.com/nspcc-dev/neofs-api-go/v2/rpc` packages
cthulhu-rider Dec 18, 2024
73d7ba0
storage/shard: Use imported constant from SDK lib, not api-go one
cthulhu-rider Dec 19, 2024
f32e23a
node: Replace code from `pkg/network/transport` to `pkg/services`
cthulhu-rider Dec 24, 2024
f1589e4
pkg/services: Get rid of recurrent processing
cthulhu-rider Dec 24, 2024
f58b461
node/metrics: Refactor stat submitting in object ops
cthulhu-rider Dec 20, 2024
06db86d
node/metrics: Make method used inside package only unexported
cthulhu-rider Dec 20, 2024
a48b7e8
services/object: Inline metric service
cthulhu-rider Dec 24, 2024
2e96580
services/object: Inline signing service
cthulhu-rider Dec 26, 2024
e17ae1d
services/object: Refactor dependencies
cthulhu-rider Dec 24, 2024
ab7a2fb
services/object: Inline service setting response meta headers
cthulhu-rider Dec 26, 2024
c759e4f
services/object: Inline service checking node maintenance
cthulhu-rider Dec 22, 2024
8051803
service/object: Inline ACL service
cthulhu-rider Dec 24, 2024
84fec64
pkg/services/acl: Use constants from SDK
cthulhu-rider Dec 23, 2024
e412efc
service/object: Inline transport splitting service
cthulhu-rider Dec 23, 2024
5702d14
services/object: Inline intermediate DELETE service
cthulhu-rider Dec 23, 2024
424f596
services/object: Inline intermediate SEARCH service
cthulhu-rider Dec 23, 2024
76b6f4a
services/object: Inline intermediate PUT service
cthulhu-rider Dec 23, 2024
8d89ebe
services/object: Inline intermediate GET/RANGE/HEAD services
cthulhu-rider Dec 23, 2024
fb1fd87
services/object: Inline intermediate HASH service
cthulhu-rider Dec 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/drop_objects.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package control

import (
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -47,11 +46,7 @@
return err
}

var resp *control.DropObjectsResponse
err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.DropObjects(client, req)
return err
})
resp, err := cli.DropObjects(ctx, req)

Check warning on line 49 in cmd/neofs-cli/modules/control/drop_objects.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/drop_objects.go#L49

Added line #L49 was not covered by tests
if err != nil {
return err
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/evacuate_shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"fmt"

"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -44,11 +43,7 @@
return err
}

var resp *control.EvacuateShardResponse
err = cli.ExecRaw(func(client *client.Client) error {
resp, err = control.EvacuateShard(client, req)
return err
})
resp, err := cli.EvacuateShard(ctx, req)

Check warning on line 46 in cmd/neofs-cli/modules/control/evacuate_shard.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/evacuate_shard.go#L46

Added line #L46 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/flush_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"fmt"

"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -43,11 +42,7 @@
return err
}

var resp *control.FlushCacheResponse
err = cli.ExecRaw(func(client *client.Client) error {
resp, err = control.FlushCache(client, req)
return err
})
resp, err := cli.FlushCache(ctx, req)

Check warning on line 45 in cmd/neofs-cli/modules/control/flush_cache.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/flush_cache.go#L45

Added line #L45 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
21 changes: 6 additions & 15 deletions cmd/neofs-cli/modules/control/healthcheck.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package control

import (
"context"
"crypto/ecdsa"
"fmt"
"os"

rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
ircontrol "github.com/nspcc-dev/neofs-node/pkg/services/control/ir"
ircontrolsrv "github.com/nspcc-dev/neofs-node/pkg/services/control/ir/server"
"github.com/nspcc-dev/neofs-sdk-go/client"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -43,13 +42,13 @@
return err
}

cli, err := getClient(ctx)
conn, err := connect(ctx)

Check warning on line 45 in cmd/neofs-cli/modules/control/healthcheck.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/healthcheck.go#L45

Added line #L45 was not covered by tests
if err != nil {
return err
}

if isIR, _ := cmd.Flags().GetBool(healthcheckIRFlag); isIR {
return healthCheckIR(cmd, pk, cli)
return healthCheckIR(ctx, cmd, pk, ircontrol.NewControlServiceClient(conn))

Check warning on line 51 in cmd/neofs-cli/modules/control/healthcheck.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/healthcheck.go#L51

Added line #L51 was not covered by tests
}

req := new(control.HealthCheckRequest)
Expand All @@ -60,11 +59,7 @@
return err
}

var resp *control.HealthCheckResponse
err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.HealthCheck(client, req)
return err
})
resp, err := control.NewControlServiceClient(conn).HealthCheck(ctx, req)

Check warning on line 62 in cmd/neofs-cli/modules/control/healthcheck.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/healthcheck.go#L62

Added line #L62 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand All @@ -85,7 +80,7 @@
return nil
}

func healthCheckIR(cmd *cobra.Command, key *ecdsa.PrivateKey, c *client.Client) error {
func healthCheckIR(ctx context.Context, cmd *cobra.Command, key *ecdsa.PrivateKey, c ircontrol.ControlServiceClient) error {

Check warning on line 83 in cmd/neofs-cli/modules/control/healthcheck.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/healthcheck.go#L83

Added line #L83 was not covered by tests
req := new(ircontrol.HealthCheckRequest)

req.SetBody(new(ircontrol.HealthCheckRequest_Body))
Expand All @@ -95,11 +90,7 @@
return fmt.Errorf("could not sign request: %w", err)
}

var resp *ircontrol.HealthCheckResponse
err = c.ExecRaw(func(client *rawclient.Client) error {
resp, err = ircontrol.HealthCheck(client, req)
return err
})
resp, err := c.HealthCheck(ctx, req)

Check warning on line 93 in cmd/neofs-cli/modules/control/healthcheck.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/healthcheck.go#L93

Added line #L93 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
36 changes: 21 additions & 15 deletions cmd/neofs-cli/modules/control/object_list.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package control

import (
"errors"
"fmt"
"io"

rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -44,22 +45,27 @@
return err
}

err = cli.ExecRaw(func(client *rawclient.Client) error {
return control.ListObjects(client, req, func(r *control.ListObjectsResponse) error {
err := verifyResponse(r.GetSignature(), r.GetBody())
if err != nil {
return err
}

for _, address := range r.GetBody().GetObjectAddress() {
cmd.Println(string(address))
}
return nil
})
})
stream, err := cli.ListObjects(ctx, req)

Check warning on line 48 in cmd/neofs-cli/modules/control/object_list.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/object_list.go#L48

Added line #L48 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}

return nil
for {
resp, err := stream.Recv()
if err != nil {
if errors.Is(err, io.EOF) {
return nil
}
return fmt.Errorf("rpc error: %w", err)

Check warning on line 59 in cmd/neofs-cli/modules/control/object_list.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/object_list.go#L53-L59

Added lines #L53 - L59 were not covered by tests
}

body := resp.GetBody()
if err := verifyResponse(resp.GetSignature(), body); err != nil {
return err
}

Check warning on line 65 in cmd/neofs-cli/modules/control/object_list.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/object_list.go#L62-L65

Added lines #L62 - L65 were not covered by tests

for _, address := range body.GetObjectAddress() {
cmd.Println(string(address))
}

Check warning on line 69 in cmd/neofs-cli/modules/control/object_list.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/object_list.go#L67-L69

Added lines #L67 - L69 were not covered by tests
}
}
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/object_revive.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"fmt"

rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -38,7 +37,6 @@
return fmt.Errorf("reading %s flag: %w", objectFlag, err)
}

var resp *control.ReviveObjectResponse
req := &control.ReviveObjectRequest{
Body: &control.ReviveObjectRequest_Body{
ObjectAddress: []byte(addressRaw),
Expand All @@ -54,10 +52,7 @@
return err
}

err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.ReviveObject(client, req)
return err
})
resp, err := cli.ReviveObject(ctx, req)

Check warning on line 55 in cmd/neofs-cli/modules/control/object_revive.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/object_revive.go#L55

Added line #L55 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/object_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"fmt"

rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -38,7 +37,6 @@
return fmt.Errorf("validating address (%s): %w", addressRaw, err)
}

var resp *control.ObjectStatusResponse
req := &control.ObjectStatusRequest{
Body: &control.ObjectStatusRequest_Body{
ObjectAddress: addressRaw,
Expand All @@ -54,10 +52,7 @@
return err
}

err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.ObjectStatus(client, req)
return err
})
resp, err := cli.ObjectStatus(ctx, req)

Check warning on line 55 in cmd/neofs-cli/modules/control/object_status.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/object_status.go#L55

Added line #L55 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/set_netmap_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"fmt"

rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
Expand Down Expand Up @@ -93,11 +92,7 @@
return err
}

var resp *control.SetNetmapStatusResponse
err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.SetNetmapStatus(client, req)
return err
})
resp, err := cli.SetNetmapStatus(ctx, req)

Check warning on line 95 in cmd/neofs-cli/modules/control/set_netmap_status.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/set_netmap_status.go#L95

Added line #L95 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
11 changes: 4 additions & 7 deletions cmd/neofs-cli/modules/control/shards_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"fmt"

"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -58,16 +57,14 @@
return err
}

var resp *control.DumpShardResponse
err = cli.ExecRaw(func(client *client.Client) error {
resp, err = control.DumpShard(client, req)
return err
})
resp, err := cli.DumpShard(ctx, req)

Check warning on line 60 in cmd/neofs-cli/modules/control/shards_dump.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/shards_dump.go#L60

Added line #L60 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}

err = verifyResponse(resp.GetSignature(), resp.GetBody())
if err = verifyResponse(resp.GetSignature(), resp.GetBody()); err != nil {
return err
}

Check warning on line 67 in cmd/neofs-cli/modules/control/shards_dump.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/shards_dump.go#L65-L67

Added lines #L65 - L67 were not covered by tests

cmd.Println("Shard has been dumped successfully.")
return nil
Expand Down
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/shards_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"strings"

"github.com/mr-tron/base58"
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -51,11 +50,7 @@
return err
}

var resp *control.ListShardsResponse
err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.ListShards(client, req)
return err
})
resp, err := cli.ListShards(ctx, req)

Check warning on line 53 in cmd/neofs-cli/modules/control/shards_list.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/shards_list.go#L53

Added line #L53 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/shards_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import (
"fmt"

"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -58,11 +57,7 @@
return err
}

var resp *control.RestoreShardResponse
err = cli.ExecRaw(func(client *client.Client) error {
resp, err = control.RestoreShard(client, req)
return err
})
resp, err := cli.RestoreShard(ctx, req)

Check warning on line 60 in cmd/neofs-cli/modules/control/shards_restore.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/shards_restore.go#L60

Added line #L60 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/neofs-cli/modules/control/shards_set_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"strings"

"github.com/mr-tron/base58"
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -144,11 +143,7 @@
return err
}

var resp *control.SetShardModeResponse
err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.SetShardMode(client, req)
return err
})
resp, err := cli.SetShardMode(ctx, req)

Check warning on line 146 in cmd/neofs-cli/modules/control/shards_set_mode.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/shards_set_mode.go#L146

Added line #L146 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
10 changes: 4 additions & 6 deletions cmd/neofs-cli/modules/control/synchronize_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"errors"
"fmt"

rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
"github.com/nspcc-dev/neofs-node/pkg/services/control"
Expand Down Expand Up @@ -40,6 +39,9 @@
defer cancel()

pk, err := key.Get(cmd)
if err != nil {
return err
}

Check warning on line 44 in cmd/neofs-cli/modules/control/synchronize_tree.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/synchronize_tree.go#L42-L44

Added lines #L42 - L44 were not covered by tests

var cnr cid.ID
cidStr, _ := cmd.Flags().GetString(commonflags.CIDFlag)
Expand Down Expand Up @@ -72,11 +74,7 @@
return err
}

var resp *control.SynchronizeTreeResponse
err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.SynchronizeTree(client, req)
return err
})
resp, err := cli.SynchronizeTree(ctx, req)

Check warning on line 77 in cmd/neofs-cli/modules/control/synchronize_tree.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/control/synchronize_tree.go#L77

Added line #L77 was not covered by tests
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
Loading
Loading