co-rethinkdb
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -45,3 +45,5 @@ // When installing co-rethinkdb for an application that uses the same version | ||
var conn = yield r.getConnection | ||
done(null, yield run.call(query, conn)) | ||
var res = yield run.call(query, conn) | ||
yield r.releaseConnection(conn) | ||
done(null, res) | ||
})() | ||
@@ -61,2 +63,5 @@ } | ||
r.releaseConnection = function*() { | ||
} | ||
module.exports = r |
{ | ||
"name": "co-rethinkdb", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Markus Ast <npm.m@rkusa.st>", | ||
@@ -5,0 +5,0 @@ "description": "Generator based querying goodness for RethinkDB", |
@@ -6,3 +6,3 @@ # co-rethinkdb | ||
[![NPM](http://img.shields.io/npm/v/co-rethinkdb.svg?style=flat)](https://npmjs.org/package/co-rethinkdb) | ||
[![Dependency Status](http://img.shields.io/gemnasium/rkusa/co-rethinkdb.svg?style=flat)](https://david-dm.org/rkusa/co-rethinkdb) | ||
[![Dependency Status](http://img.shields.io/david/rkusa/co-rethinkdb.svg?style=flat)](https://david-dm.org/rkusa/co-rethinkdb) | ||
@@ -67,2 +67,33 @@ With [RethinkDB 1.13](http://rethinkdb.com/blog/1.13-release/) the official JavaScript driver supports Promises. Since `co` supports Promises directly, a wrapper is not required anymore. However, `co-rethinkdb` still supports some API goodness by not having to call `.run()` all the time. | ||
### Load Balancer | ||
The counterpart to `r.getConnection()` is `r.releaseConnection()`. This can be used to plug in a load balancer, e.g.: | ||
```js | ||
var Pool = require('jacuzzi').Pool | ||
var r = require('co-rethinkdb') | ||
r.getConnection = function*() { | ||
return yield pool.acquire.bind(pool) | ||
} | ||
r.releaseConnection = function*(conn) { | ||
pool.release(conn) | ||
} | ||
var pool = new Pool({ | ||
create: function(callback) { | ||
r.connect({ db: 'tdengine' }) | ||
.then(function(conn) { callback(null, conn) }) | ||
.catch(callback) | ||
}, | ||
destroy: function(conn, callback) { | ||
conn.close(callback) | ||
}, | ||
check: function(conn) { | ||
return conn.open === true | ||
} | ||
}) | ||
``` | ||
## MIT License | ||
@@ -69,0 +100,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7078
53
105