Skip to content

Conversation

@beeequeue
Copy link

this is a wip implementation of my idea described in #202.

it adds a new acquireConnection() function to databases and connectors that allows users to grab a connection from the connection pool of a connector if it supports it.

for connectors that don't it will block other queries until the connection is disposed of, allowing to run transactions without them possibly being disturbed by other queries being ran in between.

to do this i also restructured the types to be based on Connections, which Connector and Database then extend. im not sure if this is the best way to do it, but it made it quite clean code-wise... there are a lot of re-used function definitions between them all.

ultimately this pr will have to implement the connection logic for every connector which will make it quite big, but im not sure how to split it up right now...


the branch is currently based on the one from #204 since i need it to build the project :^)

fixes #202
part of work towards #49

@@ -1,63 +1,79 @@
import pg from "pg";
import { type ClientConfig, Client, type QueryResult } from "pg";
import * as mutex from "ciorent/mutex";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ciorent should optimally be bundled instead of dependend on, as the used code from it is only around 150B minified, and the install size is 4kB

im not sure how to configure this with obuild though, im too used to tsdown :^)

@beeequeue beeequeue changed the title feat: connection pooling feat: connection pooling (wip) Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support pool connection for mysql and postgresql

1 participant