sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.51k stars 82 forks source link

[Question] Can I use it as proxy ? #85

Closed b-barry closed 5 years ago

b-barry commented 5 years ago

Hello,

I have just found this library and I am wondering if you know a way to use it as a proxy.

I have a lambda function built-in node.js where I connect directly to my Postgres database. If my lambda scale, I reach the max connection to my DB.

So, I would like to know if I can host your library on a server, then connect my lambda to the pool to manage my connection.

Thanks for your answer

sfackler commented 5 years ago

You can definitely make a server that uses a connection pool to serve requests, if that’s what you’re asking. If you want that server to speak the underlying database protocol you should probably use something built for that, like pgpool.

On Tue, Jul 2, 2019 at 2:26 AM Bouba notifications@github.com wrote:

Hello,

I have just found this library and I am wondering if you know a way to use it as a proxy.

I have a lambda function built-in node.js where I connect directly to my Postgres database. If my lambda scale, I reach the max connection to my DB.

So, I would like to know if I can host your library on a server, then connect my lambda to the pool to manage my connection.

Thanks for your answer

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sfackler/r2d2/issues/85?email_source=notifications&email_token=AALDMUK7O6ILROKP536WE6TP5MNKTA5CNFSM4H4ZZ322YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G42U4KA, or mute the thread https://github.com/notifications/unsubscribe-auth/AALDMUJFND2LUH3CTJLXPW3P5MNKTANCNFSM4H4ZZ32Q .

-- Steven Fackler

b-barry commented 5 years ago

Hello @sfackler

Thanks for the quick answer. Yes, I would like to forward my request to your library that will manage all pool and then forward all request to my DB.

Do you have some docs or examples on how I could write this kind of stuff, I don't have any idea? Links are perfect for me, I don't want you lost your time

I found pgpool and pgbouncer are good but coupled to Postgres. I would like something agnostic like your library because I may have other kinds of database such as MongoDB or MySQL.

Thanks

sfackler commented 5 years ago

You could potentially use this crate by defining a connection manager over a raw socket or something, and making a server that proxies to those, but you're almost certainly going to need to bake in a lot of knowledge about the underlying protocol (e.g. Postgres, MongoDB, MySQL).

b-barry commented 5 years ago

Hello,

Thanks for the answer. I will try to implement that