-
Notifications
You must be signed in to change notification settings - Fork 8
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
Extend 'capabilities' to be more dynamic? #5
Comments
// $ suffix = promisified function
function getFoos(args, cb) {
var key = 'prepared:1';
return cluster.acquire$(key, false)
.tap(function (conn) {
if (!cluster.hasCapability(conn, key)) {
return prepareStatement$(conn, key)
.then(function () {
cluster.addCapability(conn, key);
});
}
})
.tap(function (conn) {
return execStatement$(conn, key, args);
})
.finally(function (conn) {
return cluster.release$(conn);
});
} Notes: Promise.using elided for clarity; I tried to write it as callbacks but almost killed myself |
Last thing (I hope!): Currently 'capabilities' is 1:1 with Pool objects; it's used to select specific Pools among many in a Cluster; the usage discussed here is 1:1 with resource objects and would be used to select specific resources from among a pool or a cluster of pools. This semantic difference could present a problem, but in practice not a very big one: the current syntax can be retained and simply flag every resource within a pool with the specified capabilities when using pools in a cluster, while additional syntax can be added to allow more fine-grained capability manipulation on individual resources. |
Any progress on this? I'm interested in knex adding support for PREPARED STATEMENTS and this appears to block that, maybe? |
This was kind of an interest-check at the time, but no, no development is planned. Knex has (unfortunately?) moved away from pool2 to a later version of generic pool due to some ongoing integration confusion that we never really got to the bottom of, so adding it here won't affect recent versions of knex anyway. |
Spawned by the discussion here: knex/knex#802
Use case: prepared statements are connection-specific; the capabilities function could be used to request connections from the pool which have a given prepared statement available.
For this to work, a few things are needed:
Also worth considering:
Questions:
The text was updated successfully, but these errors were encountered: