dwyl / hapi-postgres-connection

:zap: Creates a PostgreSQL Connection (Pool) available anywhere in your Hapi App
GNU General Public License v2.0
40 stars 13 forks source link

connect to postgres *before* server.ext #11

Closed nelsonic closed 8 years ago

nelsonic commented 8 years ago

Instead of connecting to PostgreSQL inside the plugin, we connect before registering the plugin. That way, we re-use the same connection (pool) for all routes and never close it until we server.stop ...

fixes https://github.com/dwyl/hapi-postgres-connection/issues/10

codecov-io commented 8 years ago

Current coverage is 100.00%

Merging #11 into master will not affect coverage as of f00e294

@@            master     #11   diff @@
======================================
  Files            1       1       
  Stmts           23      24     +1
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit             23      24     +1
  Partial          0       0       
  Missed           0       0       

Review entire Coverage Diff as of f00e294

Powered by Codecov. Updated on successful CI builds.

nelsonic commented 8 years ago

@rjmk @Conorc1000 @roryc89 @naazy instead of opening a connection for each endpoint/route onPreAuth and then closing it onPostHandler I've decided to open a single connection pool before registering the plugin.

Then all urls have access to the same (single) connection pool and we don't ever have to close the connection.

(this was the _original objective_ of this plugin... but for some reason I was unable to get it working last week...)

Tested it for routes that don't make any postgres queries and wrote a "perf" test see: https://travis-ci.org/dwyl/hapi-postgres-connection/builds/117279687#L1321

Please feel free to comment/improve on this.

iteles commented 8 years ago

Looking forward to seeing this being exercised fully in one of our projects @Conorc1000 @naazy :+1: