From ea8e1b3b1987910602c2557855f173fdec8bb089 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 4 May 2022 13:00:14 +0300 Subject: [PATCH] [#426] internal/neofs: Use custom poll interval 1 second interval drastically improves experience in neofs-dev-env and does not produce much load in production. Signed-off-by: Alex Vanin --- internal/neofs/neofs.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/internal/neofs/neofs.go b/internal/neofs/neofs.go index 143ed6c6..9c5c19f5 100644 --- a/internal/neofs/neofs.go +++ b/internal/neofs/neofs.go @@ -32,12 +32,25 @@ import ( // It is used to provide an interface to dependent packages // which work with NeoFS. type NeoFS struct { - pool *pool.Pool + pool *pool.Pool + await pool.WaitParams } +const ( + defaultPollInterval = time.Second // overrides default value from pool + defaultPollTimeout = 120 * time.Second // same as default value from pool +) + // NewNeoFS creates new NeoFS using provided pool.Pool. func NewNeoFS(p *pool.Pool) *NeoFS { - return &NeoFS{pool: p} + var await pool.WaitParams + await.SetPollInterval(defaultPollInterval) + await.SetTimeout(defaultPollTimeout) + + return &NeoFS{ + pool: p, + await: await, + } } // TimeToEpoch implements neofs.NeoFS interface method. @@ -132,6 +145,7 @@ func (x *NeoFS) CreateContainer(ctx context.Context, prm neofs.PrmContainerCreat var prmPut pool.PrmContainerPut prmPut.SetContainer(*cnr) + prmPut.SetWaitParams(x.await) // send request to save the container idCnr, err := x.pool.PutContainer(ctx, prmPut) @@ -159,6 +173,7 @@ func (x *NeoFS) UserContainers(ctx context.Context, id user.ID) ([]cid.ID, error func (x *NeoFS) SetContainerEACL(ctx context.Context, table eacl.Table) error { var prm pool.PrmContainerSetEACL prm.SetTable(table) + prm.SetWaitParams(x.await) err := x.pool.SetEACL(ctx, prm) if err != nil { @@ -186,6 +201,7 @@ func (x *NeoFS) DeleteContainer(ctx context.Context, id cid.ID, token *session.T var prm pool.PrmContainerDelete prm.SetContainerID(id) prm.SetSessionToken(*token) + prm.SetWaitParams(x.await) err := x.pool.DeleteContainer(ctx, prm) if err != nil {