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 1 commit
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 @@ var dropObjectsCmd = &cobra.Command{
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)
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 @@ package control
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 @@ func evacuateShard(cmd *cobra.Command, _ []string) error {
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)
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 @@ package control
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 @@ func flushCache(cmd *cobra.Command, _ []string) error {
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)
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 @@ func healthCheck(cmd *cobra.Command, _ []string) error {
return err
}

cli, err := getClient(ctx)
conn, err := connect(ctx)
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))
}

req := new(control.HealthCheckRequest)
Expand All @@ -60,11 +59,7 @@ func healthCheck(cmd *cobra.Command, _ []string) error {
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)
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand All @@ -85,7 +80,7 @@ func healthCheck(cmd *cobra.Command, _ []string) error {
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 {
req := new(ircontrol.HealthCheckRequest)

req.SetBody(new(ircontrol.HealthCheckRequest_Body))
Expand All @@ -95,11 +90,7 @@ func healthCheckIR(cmd *cobra.Command, key *ecdsa.PrivateKey, c *client.Client)
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)
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 @@ func listObjects(cmd *cobra.Command, _ []string) error {
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)
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)
}

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

for _, address := range body.GetObjectAddress() {
cmd.Println(string(address))
}
}
}
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 @@ package control
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 @@ func reviveObject(cmd *cobra.Command, _ []string) error {
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 @@ func reviveObject(cmd *cobra.Command, _ []string) error {
return err
}

err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.ReviveObject(client, req)
return err
})
resp, err := cli.ReviveObject(ctx, req)
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 @@ package control
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 @@ func objectStatus(cmd *cobra.Command, _ []string) error {
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 @@ func objectStatus(cmd *cobra.Command, _ []string) error {
return err
}

err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.ObjectStatus(client, req)
return err
})
resp, err := cli.ObjectStatus(ctx, req)
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 @@ package control
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 @@ func setNetmapStatus(cmd *cobra.Command, _ []string) error {
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)
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
7 changes: 1 addition & 6 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 @@ package control
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 @@ func dumpShard(cmd *cobra.Command, _ []string) error {
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)
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
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 @@ import (
"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 @@ func listShards(cmd *cobra.Command, _ []string) error {
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)
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 @@ package control
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 @@ func restoreShard(cmd *cobra.Command, _ []string) error {
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)
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 @@ import (
"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 @@ func setShardMode(cmd *cobra.Command, _ []string) error {
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)
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
7 changes: 1 addition & 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 @@ import (
"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 @@ -72,11 +71,7 @@ func synchronizeTree(cmd *cobra.Command, _ []string) error {
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)
if err != nil {
return fmt.Errorf("rpc error: %w", err)
}
Expand Down
Loading