forked from TrueCloudLab/frostfs-node
[#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")
|
// 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()
|
cli, err := getSDKClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("can't create client: %w", err)
|
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
|
// getSDKClient returns default neofs-api-go sdk client. Consider using
|
||||||
// opts... to provide TTL or other global configuration flags.
|
// opts... to provide TTL or other global configuration flags.
|
||||||
func getSDKClient() (*client.Client, error) {
|
func getSDKClient() (client.Client, error) {
|
||||||
key, err := getKey()
|
key, err := getKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -95,7 +95,7 @@ type sgHeadReceiver struct {
|
||||||
|
|
||||||
tok *token.SessionToken
|
tok *token.SessionToken
|
||||||
|
|
||||||
c *client.Client
|
c client.Client
|
||||||
|
|
||||||
bearerToken *token.BearerToken
|
bearerToken *token.BearerToken
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
|
||||||
}
|
}
|
||||||
|
|
||||||
type remoteLoadAnnounceWriterProvider struct {
|
type remoteLoadAnnounceWriterProvider struct {
|
||||||
client *apiClient.Client
|
client apiClient.Client
|
||||||
key *ecdsa.PrivateKey
|
key *ecdsa.PrivateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (load
|
||||||
type remoteLoadAnnounceWriter struct {
|
type remoteLoadAnnounceWriter struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
client *apiClient.Client
|
client apiClient.Client
|
||||||
key *ecdsa.PrivateKey
|
key *ecdsa.PrivateKey
|
||||||
|
|
||||||
buf []containerSDK.UsedSpaceAnnouncement
|
buf []containerSDK.UsedSpaceAnnouncement
|
||||||
|
|
|
@ -27,7 +27,7 @@ type (
|
||||||
|
|
||||||
// NeoFSClientCache is an interface for cache of neofs RPC clients
|
// NeoFSClientCache is an interface for cache of neofs RPC clients
|
||||||
NeoFSClientCache interface {
|
NeoFSClientCache interface {
|
||||||
Get(address string) (*SDKClient.Client, error)
|
Get(address string) (SDKClient.Client, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskManager interface {
|
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,
|
// Because cache is used by `ClientCache` exclusively,
|
||||||
// client will always have valid key.
|
// client will always have valid key.
|
||||||
return c.cache.Get(address)
|
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.
|
// already created clients.
|
||||||
ClientCache struct {
|
ClientCache struct {
|
||||||
mu *sync.RWMutex
|
mu *sync.RWMutex
|
||||||
clients map[string]*client.Client
|
clients map[string]client.Client
|
||||||
opts []client.Option
|
opts []client.Option
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -21,13 +21,13 @@ type (
|
||||||
func NewSDKClientCache(opts ...client.Option) *ClientCache {
|
func NewSDKClientCache(opts ...client.Option) *ClientCache {
|
||||||
return &ClientCache{
|
return &ClientCache{
|
||||||
mu: new(sync.RWMutex),
|
mu: new(sync.RWMutex),
|
||||||
clients: make(map[string]*client.Client),
|
clients: make(map[string]client.Client),
|
||||||
opts: opts,
|
opts: opts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get function returns existing client or creates a new one.
|
// 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()
|
c.mu.RLock()
|
||||||
if cli, ok := c.clients[address]; ok {
|
if cli, ok := c.clients[address]; ok {
|
||||||
// todo: check underlying connection neofs-api-go#196
|
// todo: check underlying connection neofs-api-go#196
|
||||||
|
|
|
@ -22,7 +22,7 @@ type clientCacheWrapper struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientWrapper struct {
|
type clientWrapper struct {
|
||||||
client *client.Client
|
client client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
type storageEngineWrapper struct {
|
type storageEngineWrapper struct {
|
||||||
|
|
|
@ -26,7 +26,7 @@ type clientCacheWrapper struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientWrapper struct {
|
type clientWrapper struct {
|
||||||
client *client.Client
|
client client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
type storageEngineWrapper engine.StorageEngine
|
type storageEngineWrapper engine.StorageEngine
|
||||||
|
|
Loading…
Reference in a new issue