[#425] Adapt the Client's refactoring to the interface
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
b62a2a0f54
commit
383d2494eb
9 changed files with 12 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -95,7 +95,7 @@ type sgHeadReceiver struct {
|
|||
|
||||
tok *token.SessionToken
|
||||
|
||||
c *client.Client
|
||||
c client.Client
|
||||
|
||||
bearerToken *token.BearerToken
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
6
pkg/network/cache/client.go
vendored
6
pkg/network/cache/client.go
vendored
|
@ -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
|
||||
|
|
|
@ -22,7 +22,7 @@ type clientCacheWrapper struct {
|
|||
}
|
||||
|
||||
type clientWrapper struct {
|
||||
client *client.Client
|
||||
client client.Client
|
||||
}
|
||||
|
||||
type storageEngineWrapper struct {
|
||||
|
|
|
@ -26,7 +26,7 @@ type clientCacheWrapper struct {
|
|||
}
|
||||
|
||||
type clientWrapper struct {
|
||||
client *client.Client
|
||||
client client.Client
|
||||
}
|
||||
|
||||
type storageEngineWrapper engine.StorageEngine
|
||||
|
|
Loading…
Reference in a new issue