[#265] node: Fix after SDK & API-Go version up

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-04-18 12:04:59 +03:00
parent a358255c1b
commit 3d43b0f7f9
9 changed files with 18 additions and 18 deletions

View file

@ -36,11 +36,11 @@ func getSDKClientByFlag(cmd *cobra.Command, key *ecdsa.PrivateKey, endpointFlag
if err != nil {
return nil, fmt.Errorf("%v: %w", errInvalidEndpoint, err)
}
return GetSDKClient(cmd, key, addr)
return GetSDKClient(cmd.Context(), cmd, key, addr)
}
// GetSDKClient returns default frostfs-sdk-go client.
func GetSDKClient(cmd *cobra.Command, key *ecdsa.PrivateKey, addr network.Address) (*client.Client, error) {
func GetSDKClient(ctx context.Context, cmd *cobra.Command, key *ecdsa.PrivateKey, addr network.Address) (*client.Client, error) {
var (
c client.Client
prmInit client.PrmInit
@ -62,7 +62,7 @@ func GetSDKClient(cmd *cobra.Command, key *ecdsa.PrivateKey, addr network.Addres
c.Init(prmInit)
if err := c.Dial(prmDial); err != nil {
if err := c.Dial(ctx, prmDial); err != nil {
return nil, fmt.Errorf("can't init SDK client: %w", err)
}
@ -82,7 +82,7 @@ func GetCurrentEpoch(ctx context.Context, cmd *cobra.Command, endpoint string) (
return 0, fmt.Errorf("can't generate key to sign query: %w", err)
}
c, err := GetSDKClient(cmd, key, addr)
c, err := GetSDKClient(ctx, cmd, key, addr)
if err != nil {
return 0, err
}

View file

@ -54,7 +54,7 @@ func createSession(cmd *cobra.Command, _ []string) {
addrStr, _ := cmd.Flags().GetString(commonflags.RPC)
commonCmd.ExitOnErr(cmd, "can't parse endpoint: %w", netAddr.FromString(addrStr))
c, err := internalclient.GetSDKClient(cmd, privKey, netAddr)
c, err := internalclient.GetSDKClient(cmd.Context(), cmd, privKey, netAddr)
commonCmd.ExitOnErr(cmd, "can't create client: %w", err)
lifetime := uint64(defaultLifetime)

View file

@ -30,7 +30,7 @@ type MultiAddressClient interface {
// RawForAddress must return rawclient.Client
// for the passed network.Address.
RawForAddress(network.Address, func(cli *rawclient.Client) error) error
RawForAddress(context.Context, network.Address, func(cli *rawclient.Client) error) error
ReportError(error)
}

View file

@ -47,7 +47,7 @@ func newMultiClient(addr network.AddressGroup, opts ClientCacheOpts) *multiClien
}
}
func (x *multiClient) createForAddress(addr network.Address) (clientcore.Client, error) {
func (x *multiClient) createForAddress(ctx context.Context, addr network.Address) (clientcore.Client, error) {
var (
c client.Client
prmInit client.PrmInit
@ -73,7 +73,7 @@ func (x *multiClient) createForAddress(addr network.Address) (clientcore.Client,
}
c.Init(prmInit)
err := c.Dial(prmDial)
err := c.Dial(ctx, prmDial)
if err != nil {
return nil, fmt.Errorf("can't init SDK client: %w", err)
}
@ -144,7 +144,7 @@ func (x *multiClient) iterateClients(ctx context.Context, f func(clientcore.Clie
var err error
c, err := x.client(addr)
c, err := x.client(ctx, addr)
if err == nil {
err = f(c)
}
@ -297,8 +297,8 @@ func (x *multiClient) Close() error {
return nil
}
func (x *multiClient) RawForAddress(addr network.Address, f func(client *rawclient.Client) error) error {
c, err := x.client(addr)
func (x *multiClient) RawForAddress(ctx context.Context, addr network.Address, f func(client *rawclient.Client) error) error {
c, err := x.client(ctx, addr)
if err != nil {
return err
}
@ -310,7 +310,7 @@ func (x *multiClient) RawForAddress(addr network.Address, f func(client *rawclie
return err
}
func (x *multiClient) client(addr network.Address) (clientcore.Client, error) {
func (x *multiClient) client(ctx context.Context, addr network.Address) (clientcore.Client, error) {
strAddr := addr.String()
x.mtx.RLock()
@ -351,7 +351,7 @@ func (x *multiClient) client(addr network.Address) (clientcore.Client, error) {
return nil, errRecentlyFailed
}
cl, err := x.createForAddress(addr)
cl, err := x.createForAddress(ctx, addr)
if err != nil {
c.lastAttempt = time.Now()
return nil, err

View file

@ -99,7 +99,7 @@ func (f *getRequestForwarder) writeHeader(ctx context.Context, v *objectV2.GetOb
func (f *getRequestForwarder) openStream(ctx context.Context, addr network.Address, c client.MultiAddressClient) (*rpc.GetResponseReader, error) {
var getStream *rpc.GetResponseReader
err := c.RawForAddress(addr, func(cli *rpcclient.Client) error {
err := c.RawForAddress(ctx, addr, func(cli *rpcclient.Client) error {
var e error
getStream, e = rpc.GetObject(cli, f.Request, rpcclient.WithContext(ctx))
return e

View file

@ -85,7 +85,7 @@ func (f *getRangeRequestForwarder) verifyResponse(resp *objectV2.GetRangeRespons
func (f *getRangeRequestForwarder) openStream(ctx context.Context, addr network.Address, c client.MultiAddressClient) (*rpc.ObjectRangeResponseReader, error) {
// open stream
var rangeStream *rpc.ObjectRangeResponseReader
err := c.RawForAddress(addr, func(cli *rpcclient.Client) error {
err := c.RawForAddress(ctx, addr, func(cli *rpcclient.Client) error {
var e error
rangeStream, e = rpc.GetObjectRange(cli, f.Request, rpcclient.WithContext(ctx))
return e

View file

@ -154,7 +154,7 @@ func (f *headRequestForwarder) getHeaderAndSignature(hdrWithSig *objectV2.Header
func (f *headRequestForwarder) sendHeadRequest(ctx context.Context, addr network.Address, c client.MultiAddressClient) (*objectV2.HeadResponse, error) {
var headResp *objectV2.HeadResponse
err := c.RawForAddress(addr, func(cli *rpcclient.Client) error {
err := c.RawForAddress(ctx, addr, func(cli *rpcclient.Client) error {
var e error
headResp, e = rpc.HeadObject(cli, f.Request, rpcclient.WithContext(ctx))
return e

View file

@ -161,7 +161,7 @@ func (s *streamer) relayRequest(ctx context.Context, info client.NodeInfo, c cli
var stream *rpc.PutRequestWriter
err = c.RawForAddress(addr, func(cli *rawclient.Client) error {
err = c.RawForAddress(ctx, addr, func(cli *rawclient.Client) error {
stream, err = rpc.PutObject(cli, resp, rawclient.WithContext(ctx))
return err
})

View file

@ -46,7 +46,7 @@ func (f *requestForwarder) forwardRequest(ctx context.Context, addr network.Addr
}
var searchStream *rpc.SearchResponseReader
err = c.RawForAddress(addr, func(cli *rpcclient.Client) error {
err = c.RawForAddress(ctx, addr, func(cli *rpcclient.Client) error {
searchStream, err = rpc.SearchObjects(cli, f.Request, rpcclient.WithContext(ctx))
return err
})