forked from TrueCloudLab/frostfs-node
[#406] cli: Pass context to internal client
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
63473d0806
commit
9562123c49
24 changed files with 83 additions and 82 deletions
|
@ -1,6 +1,7 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
|
@ -64,7 +65,7 @@ func createSession(cmd *cobra.Command, _ []string) {
|
|||
|
||||
var tok session.Object
|
||||
|
||||
err = CreateSession(&tok, c, lifetime)
|
||||
err = CreateSession(cmd.Context(), &tok, c, lifetime)
|
||||
commonCmd.ExitOnErr(cmd, "can't create session: %w", err)
|
||||
|
||||
var data []byte
|
||||
|
@ -86,11 +87,11 @@ func createSession(cmd *cobra.Command, _ []string) {
|
|||
// number of epochs.
|
||||
//
|
||||
// Fills ID, lifetime and session key.
|
||||
func CreateSession(dst *session.Object, c *client.Client, lifetime uint64) error {
|
||||
func CreateSession(ctx context.Context, dst *session.Object, c *client.Client, lifetime uint64) error {
|
||||
var netInfoPrm internalclient.NetworkInfoPrm
|
||||
netInfoPrm.SetClient(c)
|
||||
|
||||
ni, err := internalclient.NetworkInfo(netInfoPrm)
|
||||
ni, err := internalclient.NetworkInfo(ctx, netInfoPrm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't fetch network info: %w", err)
|
||||
}
|
||||
|
@ -102,7 +103,7 @@ func CreateSession(dst *session.Object, c *client.Client, lifetime uint64) error
|
|||
sessionPrm.SetClient(c)
|
||||
sessionPrm.SetExp(exp)
|
||||
|
||||
sessionRes, err := internalclient.CreateSession(sessionPrm)
|
||||
sessionRes, err := internalclient.CreateSession(ctx, sessionPrm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't open session: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue