feat: add neon for serverless postgres
#191
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
part of #32
This PR introduces 3 integration options.
As opposed to the existing Postgres integration (that works with
pg), this one works with Neon's Serverless Driver.The driver offer 3 connection options.
Poolis a client that connects via HTTP and WebSockets, it has a few operation differences than a regular client, most noticiable in the code is that it does not need to be disposed.Clientthe most similar to thepgconnector, this is an HTTP client.Testing
@pi0 what are your thoughts on testing, the way I see it we have 3 options.
get-dblibrary to create and seed a new DB per connector during CI runs. These DBs are ephemeral and need no credentials. (Neon Launchpadunjsaccount in Neon and have one DB for each test setup, makes it easier to debug if tests misbehave because we have access to the dashboard.Imho, the quickest and easiest is number 2. But it requires adding the
env_varsto the repository and setting up the account (which I'm more than happy to do and make sure you have access to it).Going forward for Postgres
Since both the Neon and Postgres connectors work in a very very similar fashion, I'd love to create a
postgres/serverlessconnector and have Neon be an alias to it. So, the way I'd like to suggest is:postgres/serverlesspostgres/tcpneon/httpneon/wsneon(as an alias topostgres/serverless)I can expand the docs with clear reasons when to choose which of each options.
Auto-generating connection strings
How do you feel about leveraging
import { instantPostgres } from 'get-db'to generate a connection string to people who choose one of the above connectors but did not pass a url? We do that only in dev (to avoid weirdness in CI and deploy), and extend the docs to make it clearer, something likeThoughts?