[#956] policer: Remove WithMaxCapacity option

We already provide the pool and this argument is used only for
preallocation. No functional changes.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-02-02 20:14:47 +03:00 committed by Evgenii Stratonikov
parent 053a195ac2
commit cbfeb72466
4 changed files with 9 additions and 12 deletions

View file

@ -263,7 +263,6 @@ func addPolicer(c *cfg, keyStorage *util.KeyStorage, clientConstructor *cache.Cl
)
}
}),
policer.WithMaxCapacity(c.cfgObject.pool.replicatorPoolSize),
policer.WithPool(c.cfgObject.pool.replication),
policer.WithMetrics(c.metricsCollector.PolicerMetrics()),
)

View file

@ -64,8 +64,6 @@ type cfg struct {
taskPool *ants.Pool
maxCapacity int
batchSize, cacheSize uint32
rebalanceFreq, evictDuration, sleepDuration time.Duration
@ -158,14 +156,6 @@ func WithRedundantCopyCallback(cb RedundantCopyCallback) Option {
}
}
// WithMaxCapacity returns option to set max capacity
// that can be set to the pool.
func WithMaxCapacity(capacity int) Option {
return func(c *cfg) {
c.maxCapacity = capacity
}
}
// WithPool returns option to set pool for
// policy and replication operations.
func WithPool(p *ants.Pool) Option {

View file

@ -66,7 +66,7 @@ func New(opts ...Option) *Policer {
cfg: c,
cache: cache,
objsInWork: &objectsInWork{
objs: make(map[oid.Address]struct{}, c.maxCapacity),
objs: make(map[oid.Address]struct{}, c.taskPool.Cap()),
},
}
}

View file

@ -239,6 +239,7 @@ func TestProcessObject(t *testing.T) {
gotReplicateTo = append(gotReplicateTo, int(node.PublicKey()[0]))
}
})),
WithPool(testPool(t)),
)
addrWithType := objectcore.AddressWithType{
@ -276,6 +277,7 @@ func TestProcessObjectError(t *testing.T) {
p := New(
WithContainerSource(source),
WithBuryFunc(buryFn),
WithPool(testPool(t)),
)
addrWithType := objectcore.AddressWithType{
@ -348,6 +350,12 @@ func TestIteratorContract(t *testing.T) {
}, it.calls)
}
func testPool(t *testing.T) *ants.Pool {
pool, err := ants.NewPool(4)
require.NoError(t, err)
return pool
}
type nextResult struct {
objs []objectcore.AddressWithType
err error