From 383d2494ebe7ab251ac2f1943c33bc49f9b4e917 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 17 Mar 2021 14:34:59 +0300 Subject: [PATCH] [#425] Adapt the Client's refactoring to the interface Signed-off-by: Leonard Lyubich --- cmd/neofs-cli/modules/object.go | 2 +- cmd/neofs-cli/modules/root.go | 2 +- cmd/neofs-cli/modules/storagegroup.go | 2 +- cmd/neofs-node/container.go | 4 ++-- pkg/innerring/processors/audit/processor.go | 2 +- pkg/innerring/rpc.go | 2 +- pkg/network/cache/client.go | 6 +++--- pkg/services/object/get/util.go | 2 +- pkg/services/object/search/util.go | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/neofs-cli/modules/object.go b/cmd/neofs-cli/modules/object.go index 4bbdda06d4..8c39daeb4b 100644 --- a/cmd/neofs-cli/modules/object.go +++ b/cmd/neofs-cli/modules/object.go @@ -193,7 +193,7 @@ func init() { // objectCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } -func initSession(ctx context.Context) (*client.Client, *token.SessionToken, error) { +func initSession(ctx context.Context) (client.Client, *token.SessionToken, error) { cli, err := getSDKClient() if err != nil { return nil, nil, fmt.Errorf("can't create client: %w", err) diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index 36b910884d..bd7319bb5e 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -161,7 +161,7 @@ func getEndpointAddress() (*network.Address, error) { // getSDKClient returns default neofs-api-go sdk client. Consider using // opts... to provide TTL or other global configuration flags. -func getSDKClient() (*client.Client, error) { +func getSDKClient() (client.Client, error) { key, err := getKey() if err != nil { return nil, err diff --git a/cmd/neofs-cli/modules/storagegroup.go b/cmd/neofs-cli/modules/storagegroup.go index dc19863f27..f0820d2922 100644 --- a/cmd/neofs-cli/modules/storagegroup.go +++ b/cmd/neofs-cli/modules/storagegroup.go @@ -95,7 +95,7 @@ type sgHeadReceiver struct { tok *token.SessionToken - c *client.Client + c client.Client bearerToken *token.BearerToken } diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 3daa4be29d..7f127f6879 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -229,7 +229,7 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc } type remoteLoadAnnounceWriterProvider struct { - client *apiClient.Client + client apiClient.Client key *ecdsa.PrivateKey } @@ -244,7 +244,7 @@ func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (load type remoteLoadAnnounceWriter struct { ctx context.Context - client *apiClient.Client + client apiClient.Client key *ecdsa.PrivateKey buf []containerSDK.UsedSpaceAnnouncement diff --git a/pkg/innerring/processors/audit/processor.go b/pkg/innerring/processors/audit/processor.go index 4fc8e4760a..67d37faa42 100644 --- a/pkg/innerring/processors/audit/processor.go +++ b/pkg/innerring/processors/audit/processor.go @@ -27,7 +27,7 @@ type ( // NeoFSClientCache is an interface for cache of neofs RPC clients NeoFSClientCache interface { - Get(address string) (*SDKClient.Client, error) + Get(address string) (SDKClient.Client, error) } TaskManager interface { diff --git a/pkg/innerring/rpc.go b/pkg/innerring/rpc.go index 2986fe0574..fa4f56e7b8 100644 --- a/pkg/innerring/rpc.go +++ b/pkg/innerring/rpc.go @@ -46,7 +46,7 @@ func newClientCache(p *clientCacheParams) *ClientCache { } } -func (c *ClientCache) Get(address string) (*client.Client, error) { +func (c *ClientCache) Get(address string) (client.Client, error) { // Because cache is used by `ClientCache` exclusively, // client will always have valid key. return c.cache.Get(address) diff --git a/pkg/network/cache/client.go b/pkg/network/cache/client.go index ef1decb47c..5a38a59f83 100644 --- a/pkg/network/cache/client.go +++ b/pkg/network/cache/client.go @@ -11,7 +11,7 @@ type ( // already created clients. ClientCache struct { mu *sync.RWMutex - clients map[string]*client.Client + clients map[string]client.Client opts []client.Option } ) @@ -21,13 +21,13 @@ type ( func NewSDKClientCache(opts ...client.Option) *ClientCache { return &ClientCache{ mu: new(sync.RWMutex), - clients: make(map[string]*client.Client), + clients: make(map[string]client.Client), opts: opts, } } // Get function returns existing client or creates a new one. -func (c *ClientCache) Get(address string) (*client.Client, error) { +func (c *ClientCache) Get(address string) (client.Client, error) { c.mu.RLock() if cli, ok := c.clients[address]; ok { // todo: check underlying connection neofs-api-go#196 diff --git a/pkg/services/object/get/util.go b/pkg/services/object/get/util.go index ab87d1faa4..1b19ad045c 100644 --- a/pkg/services/object/get/util.go +++ b/pkg/services/object/get/util.go @@ -22,7 +22,7 @@ type clientCacheWrapper struct { } type clientWrapper struct { - client *client.Client + client client.Client } type storageEngineWrapper struct { diff --git a/pkg/services/object/search/util.go b/pkg/services/object/search/util.go index 5380f7eb4a..fc446a930a 100644 --- a/pkg/services/object/search/util.go +++ b/pkg/services/object/search/util.go @@ -26,7 +26,7 @@ type clientCacheWrapper struct { } type clientWrapper struct { - client *client.Client + client client.Client } type storageEngineWrapper engine.StorageEngine