MinEvictableIdleTime: code and documentation discrepancy
PROger4ever opened this issue · 0 comments
PROger4ever commented
Introduction:
In the documentation of MinEvictableIdleTime we have:
When non-positive no objects will be evicted from the pool due to idle time alone.
But in the code we have:
evictionConfig := EvictionConfig{
IdleEvictTime: pool.Config.MinEvictableIdleTime,
//...
}
and then:
func (p *DefaultEvictionPolicy) Evict(/* ... */) bool {
if /* ... */ config.IdleEvictTime < idleTime {
return true
}
}
Problem:
So, when the parameter is "non-positive" - the expression is always true and all objects will be evicted contrary to the documentation (idleTime
is a-priory non-negative).
Possible stubs:
I've created the following config:
p := pool.NewObjectPool(nil, smtpClientFactory, &pool.ObjectPoolConfig{
//...
MinEvictableIdleTime: time.Duration(math.MaxInt64), //default: 30 * time.Minute
SoftMinEvictableIdleTime: c.Config.MaxIdleTime, //default: time.Duration(math.MaxInt64)
})
It works as expected this way.
Possible solutions:
- Fix the documentation;
- Fix the code;
- Explain me how I should read the documentation :)