From aa9f8dce3deae69c2f5df8aa11a76db2d578a4b0 Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Wed, 6 Sep 2023 15:53:53 +0300 Subject: [PATCH] [#677] client: Refactor PrmAnnounceSpace/EndpointInfo/NetworkInfo usage Signed-off-by: Airat Arifullin --- cmd/frostfs-cli/internal/client/client.go | 12 ++++++------ cmd/frostfs-cli/modules/netmap/get_epoch.go | 5 +++-- cmd/frostfs-cli/modules/netmap/netinfo.go | 5 +++-- cmd/frostfs-cli/modules/netmap/nodeinfo.go | 5 +++-- cmd/frostfs-cli/modules/session/create.go | 5 +++-- cmd/frostfs-node/container.go | 6 +++--- go.mod | 2 +- go.sum | Bin 100798 -> 100798 bytes 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cmd/frostfs-cli/internal/client/client.go b/cmd/frostfs-cli/internal/client/client.go index 7fbfd5105..ffed877c7 100644 --- a/cmd/frostfs-cli/internal/client/client.go +++ b/cmd/frostfs-cli/internal/client/client.go @@ -224,8 +224,8 @@ func SetEACL(ctx context.Context, prm SetEACLPrm) (res SetEACLRes, err error) { // NetworkInfoPrm groups parameters of NetworkInfo operation. type NetworkInfoPrm struct { - commonPrm - client.PrmNetworkInfo + Client *client.Client + ClientParams client.PrmNetworkInfo } // NetworkInfoRes groups the resulting values of NetworkInfo operation. @@ -242,15 +242,15 @@ func (x NetworkInfoRes) NetworkInfo() netmap.NetworkInfo { // // Returns any error which prevented the operation from completing correctly in error return. func NetworkInfo(ctx context.Context, prm NetworkInfoPrm) (res NetworkInfoRes, err error) { - res.cliRes, err = prm.cli.NetworkInfo(ctx, prm.PrmNetworkInfo) + res.cliRes, err = prm.Client.NetworkInfo(ctx, prm.ClientParams) return } // NodeInfoPrm groups parameters of NodeInfo operation. type NodeInfoPrm struct { - commonPrm - client.PrmEndpointInfo + Client *client.Client + ClientParams client.PrmEndpointInfo } // NodeInfoRes groups the resulting values of NodeInfo operation. @@ -272,7 +272,7 @@ func (x NodeInfoRes) LatestVersion() version.Version { // // Returns any error which prevented the operation from completing correctly in error return. func NodeInfo(ctx context.Context, prm NodeInfoPrm) (res NodeInfoRes, err error) { - res.cliRes, err = prm.cli.EndpointInfo(ctx, prm.PrmEndpointInfo) + res.cliRes, err = prm.Client.EndpointInfo(ctx, prm.ClientParams) return } diff --git a/cmd/frostfs-cli/modules/netmap/get_epoch.go b/cmd/frostfs-cli/modules/netmap/get_epoch.go index a9c2e1f19..1670f16c0 100644 --- a/cmd/frostfs-cli/modules/netmap/get_epoch.go +++ b/cmd/frostfs-cli/modules/netmap/get_epoch.go @@ -16,8 +16,9 @@ var getEpochCmd = &cobra.Command{ p := key.GetOrGenerate(cmd) cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC) - var prm internalclient.NetworkInfoPrm - prm.SetClient(cli) + prm := internalclient.NetworkInfoPrm{ + Client: cli, + } res, err := internalclient.NetworkInfo(cmd.Context(), prm) commonCmd.ExitOnErr(cmd, "rpc error: %w", err) diff --git a/cmd/frostfs-cli/modules/netmap/netinfo.go b/cmd/frostfs-cli/modules/netmap/netinfo.go index 3c1839114..ceea6a890 100644 --- a/cmd/frostfs-cli/modules/netmap/netinfo.go +++ b/cmd/frostfs-cli/modules/netmap/netinfo.go @@ -20,8 +20,9 @@ var netInfoCmd = &cobra.Command{ p := key.GetOrGenerate(cmd) cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC) - var prm internalclient.NetworkInfoPrm - prm.SetClient(cli) + prm := internalclient.NetworkInfoPrm{ + Client: cli, + } res, err := internalclient.NetworkInfo(cmd.Context(), prm) commonCmd.ExitOnErr(cmd, "rpc error: %w", err) diff --git a/cmd/frostfs-cli/modules/netmap/nodeinfo.go b/cmd/frostfs-cli/modules/netmap/nodeinfo.go index 3b2113efb..bf73286ed 100644 --- a/cmd/frostfs-cli/modules/netmap/nodeinfo.go +++ b/cmd/frostfs-cli/modules/netmap/nodeinfo.go @@ -22,8 +22,9 @@ var nodeInfoCmd = &cobra.Command{ p := key.GetOrGenerate(cmd) cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC) - var prm internalclient.NodeInfoPrm - prm.SetClient(cli) + prm := internalclient.NodeInfoPrm{ + Client: cli, + } res, err := internalclient.NodeInfo(cmd.Context(), prm) commonCmd.ExitOnErr(cmd, "rpc error: %w", err) diff --git a/cmd/frostfs-cli/modules/session/create.go b/cmd/frostfs-cli/modules/session/create.go index 53f6e8bc4..c578fc6b7 100644 --- a/cmd/frostfs-cli/modules/session/create.go +++ b/cmd/frostfs-cli/modules/session/create.go @@ -91,8 +91,9 @@ func createSession(cmd *cobra.Command, _ []string) { // // Fills ID, lifetime and session key. func CreateSession(ctx context.Context, dst *session.Object, c *client.Client, lifetime uint64) error { - var netInfoPrm internalclient.NetworkInfoPrm - netInfoPrm.SetClient(c) + netInfoPrm := internalclient.NetworkInfoPrm{ + Client: c, + } ni, err := internalclient.NetworkInfo(ctx, netInfoPrm) if err != nil { diff --git a/cmd/frostfs-node/container.go b/cmd/frostfs-node/container.go index 5d88ff9ea..d54bf13dd 100644 --- a/cmd/frostfs-node/container.go +++ b/cmd/frostfs-node/container.go @@ -383,9 +383,9 @@ func (r *remoteLoadAnnounceWriter) Put(a containerSDK.SizeEstimation) error { } func (r *remoteLoadAnnounceWriter) Close(ctx context.Context) error { - var cliPrm apiClient.PrmAnnounceSpace - - cliPrm.SetValues(r.buf) + cliPrm := apiClient.PrmAnnounceSpace{ + Announcements: r.buf, + } _, err := r.client.ContainerAnnounceUsedSpace(ctx, cliPrm) return err diff --git a/go.mod b/go.mod index 6d5382b75..e9b00cd67 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.15.1-0.20230802075510-964c3edb3f44 git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230627134746-36f3d39c406a git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20230531082742-c97d21411eb6 - git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230904141422-5a471e5002a7 + git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230904165523-55a1f23e7170 git.frostfs.info/TrueCloudLab/hrw v1.2.1 git.frostfs.info/TrueCloudLab/tzhash v1.8.0 github.com/cheggaaa/pb v1.0.29 diff --git a/go.sum b/go.sum index 6c8b417041d823f7cea6b64f8438d0af5b54c7b9..1d00dcf3739ee97ca708e9e33add949da77cccd3 100644 GIT binary patch delta 111 zcmdltnQh->whh*Tj%KE&M#j3Priq4WM#ib;hUNwe8HQGQ{=sH};o%nkCKWCPK4yj? z5vkgKP6c5RAx`>f0VY+I201|)2C0tWX`YiCcr_-g2#O0~n$&z&aQj(7#*gIyGgKjN delta 111 zcmdltnQh->whh*TjwXgCMn<}(i6-WTsip=7Mv3MM8HQGA<*qJe`i7oLkNoj#D z6*BMcr_-g2#O0~n$&z&aQj(7#*gIyP6;8M