From 9c906987caa2c483965ca99469c9831142a56473 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 6 Jul 2021 12:20:23 +0300 Subject: [PATCH] [#23] Remove usage of deprecated code elements in API Go v1.28.2 Remove usage of deprecated `NodeInfo.Address` method. Replace it with new methods which work with group of addresses. --- pkg/pool/pool.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/pool/pool.go b/pkg/pool/pool.go index c1265ea1..5abbde8a 100644 --- a/pkg/pool/pool.go +++ b/pkg/pool/pool.go @@ -13,6 +13,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/container" cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id" + "github.com/nspcc-dev/neofs-api-go/pkg/netmap" "github.com/nspcc-dev/neofs-api-go/pkg/object" "github.com/nspcc-dev/neofs-api-go/pkg/owner" "github.com/nspcc-dev/neofs-api-go/pkg/session" @@ -103,11 +104,21 @@ func newPool(ctx context.Context, options *BuilderOptions) (Pool, error) { } st, err := c.CreateSession(ctx, options.SessionExpirationEpoch) if err != nil { - address := "unknown" + var address interface{} = "unknown" + if epi, err := c.EndpointInfo(ctx); err == nil { - address = epi.NodeInfo().Address() + ni := epi.NodeInfo() + + addresses := make([]string, 0, ni.NumberOfAddresses()) + + netmap.IterateAllAddresses(ni, func(addr string) { + addresses = append(addresses, addr) + }) + + address = addresses } - return nil, fmt.Errorf("failed to create neofs session token for client %s: %w", address, err) + + return nil, fmt.Errorf("failed to create neofs session token for client %v: %w", address, err) } clientPacks[i] = &clientPack{client: c, sessionToken: st, healthy: true} }