Skip to content
Browse files

Added timeout and retry defaults

  • Loading branch information...
1 parent f7c4b97 commit f328b0ec460adfa594c390484ec728da91a071ef @joeybaker committed Apr 12, 2013
Showing with 14 additions and 7 deletions.
  1. +9 −2 lib/db.js
  2. +4 −4 package.json
  3. +1 −1 test/specs/db.js
View
11 lib/db.js
@@ -120,7 +120,10 @@ function install(db, callback) {
}
}
}, function(err){
- if (err) throw new Error(err)
+ if (err) {
+ console.error('error: database create err: ' + err)
+ throw err
+ }
callback()
})
}
@@ -134,6 +137,8 @@ exports.attach = function(opts){
host: config.host || 'localhost'
, port: config.port || 5984
, name: config.name || pkg.name
+ , retries: config.retries || 3
+ , retryTimeout: config.retryTimeout || 30 * 1000
// turn off cache by default in development
, cache: app.env !== 'development'
, raw: false
@@ -149,11 +154,13 @@ exports.attach = function(opts){
cradle.setup({
host: options.host
, port: options.port
+ , retries: options.retries
+ , retryTimeout: options.retryTimeout
})
db = new(cradle.Connection)().database(options.name)
db.exists(function (err, exists) {
- if (err) throw new Error(err)
+ if (err) throw err
if (exists) return options.callback()
app.log.info('CouchDB database ' + options.name + ' did not exist; creating.');
install(db, options.callback)
View
8 package.json
@@ -1,6 +1,6 @@
{
"name": "wheelhouse-couch",
- "version": "0.2.1",
+ "version": "0.2.2",
"description": "A wheelhouse library to use couchdb as a database while useing backbone on ther server.",
"main": "index.js",
"scripts": {
@@ -36,8 +36,8 @@
"grunt-simple-mocha": "~0.3",
"union": "~0.3",
"grunt-shell": "~0.2"
- }
- , "peerDependencies": {
+ },
+ "peerDependencies": {
"flatiron": "~0.3"
}
-}
+}
View
2 test/specs/db.js
@@ -1,4 +1,4 @@
-/*globals describe, it, after */
+/*global describe, it, after */
'use strict';
var App = require('../fixtures/app')
, Backbone = require('backbone')

0 comments on commit f328b0e

Please sign in to comment.
Something went wrong with that request. Please try again.