mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-02-02 09:40:35 +00:00
Merge pull request #3758 from nspcc-dev/sdk-fix
services: fix error check for NeoFS client Dial
This commit is contained in:
commit
24f81a7f3e
3 changed files with 7 additions and 12 deletions
2
go.mod
2
go.mod
|
@ -30,7 +30,6 @@ require (
|
|||
golang.org/x/term v0.27.0
|
||||
golang.org/x/text v0.21.0
|
||||
golang.org/x/tools v0.24.0
|
||||
google.golang.org/grpc v1.65.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
|
@ -73,6 +72,7 @@ require (
|
|||
golang.org/x/sync v0.10.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
|
||||
google.golang.org/grpc v1.65.0 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
rsc.io/tmplfunc v0.0.3 // indirect
|
||||
)
|
||||
|
|
|
@ -80,7 +80,7 @@ func TestServiceConstructor(t *testing.T) {
|
|||
require.Equal(t, service.IsActive(), false)
|
||||
})
|
||||
|
||||
t.Run("SDK client", func(t *testing.T) {
|
||||
t.Run("NeoFS client", func(t *testing.T) {
|
||||
cfg := config.NeoFSBlockFetcher{
|
||||
InternalService: config.InternalService{
|
||||
Enabled: true,
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -58,7 +56,7 @@ type Client interface {
|
|||
// URI scheme is "neofs:<Container-ID>/<Object-ID/<Command>/<Params>".
|
||||
// If Command is not provided, full object is requested.
|
||||
func Get(ctx context.Context, priv *keys.PrivateKey, u *url.URL, addr string) (io.ReadCloser, error) {
|
||||
c, err := GetSDKClient(ctx, addr, 0)
|
||||
c, err := GetClient(ctx, addr, 0)
|
||||
if err != nil {
|
||||
return clientCloseWrapper{c: c}, fmt.Errorf("failed to create client: %w", err)
|
||||
}
|
||||
|
@ -273,9 +271,9 @@ func ObjectSearch(ctx context.Context, c Client, priv *keys.PrivateKey, containe
|
|||
return objectIDs, nil
|
||||
}
|
||||
|
||||
// GetSDKClient returns a NeoFS SDK client configured with the specified address and context.
|
||||
// GetClient returns a NeoFS client configured with the specified address and context.
|
||||
// If timeout is 0, the default timeout will be used.
|
||||
func GetSDKClient(ctx context.Context, addr string, timeout time.Duration) (*client.Client, error) {
|
||||
func GetClient(ctx context.Context, addr string, timeout time.Duration) (*client.Client, error) {
|
||||
var prmDial client.PrmDial
|
||||
if addr == "" {
|
||||
return nil, errors.New("address is empty")
|
||||
|
@ -288,14 +286,11 @@ func GetSDKClient(ctx context.Context, addr string, timeout time.Duration) (*cli
|
|||
}
|
||||
c, err := client.New(client.PrmInit{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't create SDK client: %w", err)
|
||||
return nil, fmt.Errorf("can't create NeoFS client: %w", err)
|
||||
}
|
||||
|
||||
if err := c.Dial(prmDial); err != nil {
|
||||
if status.Code(err) == codes.Unimplemented {
|
||||
return c, nil
|
||||
}
|
||||
return nil, fmt.Errorf("can't init SDK client: %w", err)
|
||||
return nil, fmt.Errorf("can't init NeoFS client: %w", err)
|
||||
}
|
||||
|
||||
return c, nil
|
||||
|
|
Loading…
Add table
Reference in a new issue