[#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 <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2022-05-04 13:00:14 +03:00 committed by Kira
parent 20f846ea9b
commit ea8e1b3b19

View file

@ -33,11 +33,24 @@ import (
// which work with NeoFS. // which work with NeoFS.
type NeoFS struct { 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. // NewNeoFS creates new NeoFS using provided pool.Pool.
func NewNeoFS(p *pool.Pool) *NeoFS { 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. // TimeToEpoch implements neofs.NeoFS interface method.
@ -132,6 +145,7 @@ func (x *NeoFS) CreateContainer(ctx context.Context, prm neofs.PrmContainerCreat
var prmPut pool.PrmContainerPut var prmPut pool.PrmContainerPut
prmPut.SetContainer(*cnr) prmPut.SetContainer(*cnr)
prmPut.SetWaitParams(x.await)
// send request to save the container // send request to save the container
idCnr, err := x.pool.PutContainer(ctx, prmPut) 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 { func (x *NeoFS) SetContainerEACL(ctx context.Context, table eacl.Table) error {
var prm pool.PrmContainerSetEACL var prm pool.PrmContainerSetEACL
prm.SetTable(table) prm.SetTable(table)
prm.SetWaitParams(x.await)
err := x.pool.SetEACL(ctx, prm) err := x.pool.SetEACL(ctx, prm)
if err != nil { if err != nil {
@ -186,6 +201,7 @@ func (x *NeoFS) DeleteContainer(ctx context.Context, id cid.ID, token *session.T
var prm pool.PrmContainerDelete var prm pool.PrmContainerDelete
prm.SetContainerID(id) prm.SetContainerID(id)
prm.SetSessionToken(*token) prm.SetSessionToken(*token)
prm.SetWaitParams(x.await)
err := x.pool.DeleteContainer(ctx, prm) err := x.pool.DeleteContainer(ctx, prm)
if err != nil { if err != nil {