jondot / sneakers

A fast background processing framework for Ruby and RabbitMQ
https://github.com/jondot/sneakers
MIT License
2.24k stars 333 forks source link

Documentation not very clear on how to handle DB connections when using the gem in a Rails application #478

Open vikram-a opened 1 year ago

vikram-a commented 1 year ago

Hi,

I find that the documentation is insufficient in describing how to handle DB connections when using the gem as a Rails worker. This example of having a hook close existing connection and create a new one for every worker does not seems efficient. Is there a recommended way to simply use the connection from the pool and return it cleanly?

Thanks!

michaelklishin commented 1 year ago

Opening a new connection for long running processes is perfectly efficient and matches how connections in the messaging protocols supported by RabbitMQ are expected to be used.

Due to fork(2) effects on previously opened file handles, you won't be able to avoid doing what the example does, one way or another.

vikram-a commented 1 year ago

Opening a new connection for long running processes is perfectly efficient and matches how connections in the messaging protocols supported by RabbitMQ are expected to be used.

Due to fork(2) effects on previously opened file handles, you won't be able to avoid doing what the example does, one way or another.

Hi! I was talking about database connections.