Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I "warm" a ConnectionPool? #85

Closed
rmosolgo opened this issue Feb 5, 2016 · 2 comments
Closed

Can I "warm" a ConnectionPool? #85

rmosolgo opened this issue Feb 5, 2016 · 2 comments

Comments

@rmosolgo
Copy link

rmosolgo commented Feb 5, 2016

Hi, thanks for the great gem! We use it in react-rails for server rendering.

Let's say my pool is:

ConnectionPool.new { really_long_setup }

And later I'm going to need 10 of those. Is there a way I can do the really_long_setup ahead of time?

I thought maybe

pool_size.times do 
  pool.with { |member| member }
end

but I would expect that to use the same member each time. (Also, I'm not sure how I could tell if the pool was initialized or not.)

@mperham
Copy link
Owner

mperham commented Feb 5, 2016

You can perform some work or instantiate the first resource in a Rails initializer but there's no easy way to make a connection pool eager load its resources. Do you mean that all 10 elements require a long setup to create? If so, I'm not sure there's any easy solution to your problem.

@rmosolgo
Copy link
Author

rmosolgo commented Feb 5, 2016

Fair 'nuf, I think one would be enough. (Basically, for production, I'd rather raise errors at startup instead of randomly at runtime whenever the pool gets hit.)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants