DanielYWoo/fast-object-pool

More intelligent logics of borrowing objects

Closed this issue · 3 comments

Is it possible to introduce better logics of populating objects? Not just 3-times retrying.. I use if for thrift-clients, where every connection behind client could be closed by server-side, so I face the problem where 3 times is too small amount of tries...

I guess that’s what happens: pool generates some initial amount of opened connections and then tries to use them, creating a new ones once it is needed. But since initial connections were created almost at the same time, they become disconnected at the same time as well.. so even with random distribution among the partitions I get the errors not valid object

I think will add some Strategy classes for that purpose, thus you can add your own customized retry/random strategy. Meanwhile, any pull request is welcomed.

Since 2.0, a new parameter scavengeRatio is added to PoolConfig. By default, the scavenger close 50% idle connections only. This is a simple strategy, if you need more complicated strategy, let me know.