Skip to content

Commit 24f81a7

Browse files
authored
Merge pull request #3758 from nspcc-dev/sdk-fix
services: fix error check for NeoFS client Dial
2 parents 9189b3e + f5ea79d commit 24f81a7

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ require (
3030
golang.org/x/term v0.27.0
3131
golang.org/x/text v0.21.0
3232
golang.org/x/tools v0.24.0
33-
google.golang.org/grpc v1.65.0
3433
gopkg.in/yaml.v3 v3.0.1
3534
)
3635

@@ -73,6 +72,7 @@ require (
7372
golang.org/x/sync v0.10.0 // indirect
7473
golang.org/x/sys v0.28.0 // indirect
7574
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
75+
google.golang.org/grpc v1.65.0 // indirect
7676
google.golang.org/protobuf v1.34.2 // indirect
7777
rsc.io/tmplfunc v0.0.3 // indirect
7878
)

pkg/services/blockfetcher/blockfetcher_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestServiceConstructor(t *testing.T) {
8080
require.Equal(t, service.IsActive(), false)
8181
})
8282

83-
t.Run("SDK client", func(t *testing.T) {
83+
t.Run("NeoFS client", func(t *testing.T) {
8484
cfg := config.NeoFSBlockFetcher{
8585
InternalService: config.InternalService{
8686
Enabled: true,

pkg/services/helpers/neofs/neofs.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"github.com/nspcc-dev/neofs-sdk-go/object"
1919
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
2020
"github.com/nspcc-dev/neofs-sdk-go/user"
21-
"google.golang.org/grpc/codes"
22-
"google.golang.org/grpc/status"
2321
)
2422

2523
const (
@@ -58,7 +56,7 @@ type Client interface {
5856
// URI scheme is "neofs:<Container-ID>/<Object-ID/<Command>/<Params>".
5957
// If Command is not provided, full object is requested.
6058
func Get(ctx context.Context, priv *keys.PrivateKey, u *url.URL, addr string) (io.ReadCloser, error) {
61-
c, err := GetSDKClient(ctx, addr, 0)
59+
c, err := GetClient(ctx, addr, 0)
6260
if err != nil {
6361
return clientCloseWrapper{c: c}, fmt.Errorf("failed to create client: %w", err)
6462
}
@@ -273,9 +271,9 @@ func ObjectSearch(ctx context.Context, c Client, priv *keys.PrivateKey, containe
273271
return objectIDs, nil
274272
}
275273

276-
// GetSDKClient returns a NeoFS SDK client configured with the specified address and context.
274+
// GetClient returns a NeoFS client configured with the specified address and context.
277275
// If timeout is 0, the default timeout will be used.
278-
func GetSDKClient(ctx context.Context, addr string, timeout time.Duration) (*client.Client, error) {
276+
func GetClient(ctx context.Context, addr string, timeout time.Duration) (*client.Client, error) {
279277
var prmDial client.PrmDial
280278
if addr == "" {
281279
return nil, errors.New("address is empty")
@@ -288,14 +286,11 @@ func GetSDKClient(ctx context.Context, addr string, timeout time.Duration) (*cli
288286
}
289287
c, err := client.New(client.PrmInit{})
290288
if err != nil {
291-
return nil, fmt.Errorf("can't create SDK client: %w", err)
289+
return nil, fmt.Errorf("can't create NeoFS client: %w", err)
292290
}
293291

294292
if err := c.Dial(prmDial); err != nil {
295-
if status.Code(err) == codes.Unimplemented {
296-
return c, nil
297-
}
298-
return nil, fmt.Errorf("can't init SDK client: %w", err)
293+
return nil, fmt.Errorf("can't init NeoFS client: %w", err)
299294
}
300295

301296
return c, nil

0 commit comments

Comments
 (0)