-
Notifications
You must be signed in to change notification settings - Fork 18
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
Synchronous connection pool initialisation r.connectPool()
#60
Comments
connectPool should be a Promise because by default it checks if the pool is healthy. I don't think, that this behavior is redundant, so I am closing an issue. And yes, we are going to make more changes to the library, so don't think that this library is strongly based on |
Okay, I have reviewed the code and, maybe, we can change an API and create an event when connectPool is ready. I'll discuss this with a team. |
Has there been any update on this, @atassis? |
@Sven65 I was working on 3.0 version of library, where r is only used for generating queries, connection logic was moved out of single r object. 1 test was broken, have to fix it, but have no time to finish it. Several improvements were made there, but this is what we have now |
Thanks for the response, I'm loolking forward to v3! |
Ok, I have prepared the new version in |
at this very moment you are able to synchronously instantiate the connection pool by using import { MasterConnectionPool } from "rethinkdb-ts/lib/connection/master-pool"; I am working on making API clear, and also maybe adding some more stuff, thats why still not |
We encountered an issue when migrating our expressjs app from
rethinkdbdash
→rethinkdb-ts
. Withrethinkdbdash
, creating our express app and initialising the database was synchronous:After moving to
rethinkdb-ts
we needed to runr.connectPool(...)
when the app initialised. The (apparent) way to handle this sort of async initialisation is to return an app promise rather than an app and handle it in the thing that attaches the app to a http server. For example:and then in
./bin/www
The problem with this is that it would have required us to change over 100 test files that all import the
app
for integration tests.Our "solution" (for which I'm hoping someone can suggest a better approach) was to add an express middleware that runs
r.connectPool()
the first time it runs and otherwise does nothing:We're not very happy with this method and it adds a (very very) small amount of overhead to every API request but seemed like the easiest way to migrate from
rethinkdbdash
without having to modify hundreds of files and generally would (if it's possible) love a synchronous version ofr.connectPool()
.The text was updated successfully, but these errors were encountered: