[#168] node: Refactor container services

Resolve containedctx for remoteLoadAnnounceWriter struct

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-03-24 11:08:45 +03:00
parent 28dc9e2190
commit 56161d39b4
6 changed files with 12 additions and 16 deletions

View file

@ -309,7 +309,7 @@ func (w *morphLoadWriter) Put(a containerSDK.SizeEstimation) error {
return w.cnrMorphClient.AnnounceLoad(prm)
}
func (*morphLoadWriter) Close() error {
func (*morphLoadWriter) Close(context.Context) error {
return nil
}
@ -319,7 +319,7 @@ func (nopLoadWriter) Put(containerSDK.SizeEstimation) error {
return nil
}
func (nopLoadWriter) Close() error {
func (nopLoadWriter) Close(context.Context) error {
return nil
}
@ -368,15 +368,11 @@ type remoteLoadAnnounceWriterProvider struct {
func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (loadcontroller.Writer, error) {
return &remoteLoadAnnounceWriter{
ctx: ctx,
client: p.client,
}, nil
}
// nolint: containedctx
type remoteLoadAnnounceWriter struct {
ctx context.Context
client client.Client
buf []containerSDK.SizeEstimation
@ -388,12 +384,12 @@ func (r *remoteLoadAnnounceWriter) Put(a containerSDK.SizeEstimation) error {
return nil
}
func (r *remoteLoadAnnounceWriter) Close() error {
func (r *remoteLoadAnnounceWriter) Close(ctx context.Context) error {
var cliPrm apiClient.PrmAnnounceSpace
cliPrm.SetValues(r.buf)
_, err := r.client.ContainerAnnounceUsedSpace(r.ctx, cliPrm)
_, err := r.client.ContainerAnnounceUsedSpace(ctx, cliPrm)
return err
}

View file

@ -100,7 +100,7 @@ func (c *announceContext) announce() {
}
// finish writing
err = targetWriter.Close()
err = targetWriter.Close(c.ctx)
if err != nil {
c.log.Debug("could not finish writing local announcements",
zap.String("error", err.Error()),
@ -301,7 +301,7 @@ func (c *stopContext) report() {
}
// finish writing
err = resultWriter.Close()
err = resultWriter.Close(c.ctx)
if err != nil {
c.log.Debug("could not finish writing load estimations",
zap.String("error", err.Error()),

View file

@ -69,7 +69,7 @@ func (s *testAnnouncementStorage) Put(v container.SizeEstimation) error {
return nil
}
func (s *testAnnouncementStorage) Close() error {
func (s *testAnnouncementStorage) Close(context.Context) error {
return nil
}

View file

@ -2,7 +2,6 @@ package loadcontroller
import (
"context"
"io"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
)
@ -70,7 +69,7 @@ type Writer interface {
// the Close's return.
//
// Methods must not be called after Close.
io.Closer
Close(ctx context.Context) error
}
// WriterProvider is a group of methods provided

View file

@ -154,9 +154,9 @@ func (w *loadWriter) Put(a container.SizeEstimation) error {
return nil
}
func (w *loadWriter) Close() error {
func (w *loadWriter) Close(ctx context.Context) error {
for key, wRemote := range w.mServers {
err := wRemote.Close()
err := wRemote.Close(ctx)
if err != nil {
w.router.log.Debug("could not close remote server writer",
zap.String("key", key),

View file

@ -1,6 +1,7 @@
package loadstorage
import (
"context"
"sort"
"sync"
@ -89,7 +90,7 @@ func (s *Storage) Put(a container.SizeEstimation) error {
return nil
}
func (s *Storage) Close() error {
func (s *Storage) Close(context.Context) error {
return nil
}