Comparing version 0.11.4 to 0.12.0
// The changes_couchdb API | ||
// | ||
// Copyright 2011 Iris Couch | ||
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors | ||
// | ||
@@ -5,0 +5,0 @@ // Licensed under the Apache License, Version 2.0 (the "License"); |
#!/usr/bin/env node | ||
// Export Follow in browser-friendly format. | ||
// | ||
// Copyright 2011 Iris Couch | ||
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors | ||
// | ||
@@ -6,0 +6,0 @@ // Licensed under the Apache License, Version 2.0 (the "License"); |
#!/usr/bin/env node | ||
// The follow command-line interface. | ||
// | ||
// Copyright 2011 Iris Couch | ||
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors | ||
// | ||
@@ -6,0 +6,0 @@ // Licensed under the Apache License, Version 2.0 (the "License"); |
// Core routines for event emitters | ||
// | ||
// Copyright 2011 Iris Couch | ||
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors | ||
// | ||
@@ -47,5 +47,7 @@ // Licensed under the Apache License, Version 2.0 (the "License"); | ||
self.feed = 'continuous'; | ||
self.heartbeat = DEFAULT_HEARTBEAT; | ||
self.max_retry_seconds = DEFAULT_MAX_RETRY_SECONDS; | ||
self.heartbeat = opts.heartbeat || DEFAULT_HEARTBEAT; | ||
self.max_retry_seconds = opts.max_retry_seconds || DEFAULT_MAX_RETRY_SECONDS; | ||
self.inactivity_ms = null; | ||
self.initial_retry_delay = opts.initial_retry_delay || INITIAL_RETRY_DELAY; | ||
self.response_grace_time = opts.response_grace_time || RESPONSE_GRACE_TIME; | ||
@@ -58,3 +60,3 @@ self.headers = {}; | ||
self.caught_up = false | ||
self.retry_delay = INITIAL_RETRY_DELAY; // ms | ||
self.retry_delay = self.initial_retry_delay; | ||
@@ -67,3 +69,4 @@ self.query_params = {}; // Extra `req.query` values for filter functions | ||
Object.keys(opts).forEach(function(key) { | ||
self[key] = opts[key]; | ||
if (typeof self[key] !== 'function') | ||
self[key] = opts[key]; | ||
}) | ||
@@ -238,3 +241,3 @@ | ||
// The response headers must arrive within one heartbeat. | ||
var response_timer = setTimeout(response_timed_out, self.heartbeat + RESPONSE_GRACE_TIME) | ||
var response_timer = setTimeout(response_timed_out, self.heartbeat + self.response_grace_time) | ||
, timed_out = false | ||
@@ -274,3 +277,3 @@ | ||
self.log.debug('Good response: ' + feed_id); | ||
self.retry_delay = INITIAL_RETRY_DELAY; | ||
self.retry_delay = self.initial_retry_delay; | ||
@@ -463,2 +466,5 @@ self.emit('response', resp); | ||
var self = this; | ||
if (self.dead) | ||
return self.log.debug('No timeout: change listener stopped this feed'); | ||
self.log.debug('Timeout') | ||
@@ -565,12 +571,20 @@ | ||
if(!change.doc) | ||
return self.die(new Error('Internal filter needs .doc in change ' + change.seq)); | ||
// Don't let the filter mutate the real data. | ||
var doc = lib.JDUP(change.doc); | ||
var req = lib.JDUP({'query': self.pending.request.changes_query}); | ||
var filter_args; | ||
if (self.is_db_updates) { | ||
if(!change.db_name || !change.type) | ||
return self.die(new Error('Internal _db_updates filter needs .db_name and .type in change ', change)); | ||
filter_args = [change.db_name, change.type, req]; | ||
} else { | ||
if(!change.doc) | ||
return self.die(new Error('Internal filter needs .doc in change ' + change.seq)); | ||
// Don't let the filter mutate the real data. | ||
var doc = lib.JDUP(change.doc); | ||
filter_args = [doc, req]; | ||
} | ||
var result = false; | ||
try { | ||
result = self.filter.apply(null, [doc, req]); | ||
result = self.filter.apply(null, filter_args); | ||
} catch (er) { | ||
@@ -577,0 +591,0 @@ self.log.debug('Filter error', er); |
@@ -1,2 +0,2 @@ | ||
// Copyright 2011 Iris Couch | ||
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors | ||
// | ||
@@ -3,0 +3,0 @@ // Licensed under the Apache License, Version 2.0 (the "License"); |
// Changes stream | ||
// | ||
// Copyright 2011 Iris Couch | ||
// Copyright 2011 Jason Smith, Jarrett Cruger and contributors | ||
// | ||
@@ -5,0 +5,0 @@ // Licensed under the Apache License, Version 2.0 (the "License"); |
{ "name": "follow" | ||
, "version": "0.11.4" | ||
, "version": "0.12.0" | ||
, "author": { "name": "Jason Smith" | ||
@@ -12,6 +12,6 @@ , "email": "jhs@iriscouch.com" } | ||
, "url": "git://github.com/iriscouch/follow" } | ||
, "engines": { "node": "0.10.x || 0.8.x" } | ||
, "dependencies" : { "request" : "^2.44.0" | ||
, "engines": { "node": "0.12.x || 0.10.x || 0.8.x" } | ||
, "dependencies" : { "request" : "~2.55.0" | ||
, "browser-request" : "~0.3.0" | ||
, "debug": "~0.7.2" | ||
, "debug": "^2.1.0" | ||
} | ||
@@ -18,0 +18,0 @@ , "devDependencies": { "tap": "~0.4.0" |
@@ -53,2 +53,8 @@ # Follow: CouchDB changes and db updates notifier for NodeJS | ||
For each change, Follow will emit a `change` event containing: | ||
* `type`: `created`, `updated` or `deleted`. | ||
* `db_name`: Name of the database where the change occoured. | ||
* `ok`: Event operation status (boolean). | ||
Note that this feature is available as of CouchDB 1.4. | ||
@@ -84,2 +90,5 @@ | ||
* `inactivity_ms` | Maximum time to wait between **changes**. Omitting this means no maximum. | ||
* `max_retry_seconds` | Maximum time to wait between retries (default: 360 seconds) | ||
* `initial_retry_delay` | Time to wait before the first retry, in milliseconds (default 1000 milliseconds) | ||
* `response_grace_time` | Extra time to wait before timing out, in milliseconds (default 5000 milliseconds) | ||
@@ -86,0 +95,0 @@ ## Object API |
@@ -12,2 +12,3 @@ // CouchDB tests | ||
, DB = process.env.db || 'http://localhost:5984/follow_test' | ||
, DB_UPDATES = process.env.db_updates || 'http://localhost:5984/_db_updates' | ||
, RTT = null | ||
@@ -17,2 +18,3 @@ | ||
module.exports = { 'DB': DB | ||
, 'DB_UPDATES': DB_UPDATES | ||
, 'rtt' : get_rtt | ||
@@ -22,2 +24,3 @@ , 'redo': redo_couch | ||
, 'make_data': make_data | ||
, 'create_and_delete_db': create_and_delete_db | ||
} | ||
@@ -91,3 +94,14 @@ | ||
function create_and_delete_db(t, callback) { | ||
request.put({ uri: DB + 1, json: true}, function (er, res) { | ||
t.false(er, 'create test db'); | ||
request.del({uri: DB +1, json: true}, function (er, res) { | ||
t.false(er, 'Clear old test DB: ' + DB) | ||
t.ok(!res.body.error); | ||
callback(); | ||
}); | ||
}); | ||
} | ||
function make_data(minimum_size, callback) { | ||
@@ -115,3 +129,3 @@ var payload = {'docs':[]} | ||
request.post({'uri':DB+'/_bulk_docs', 'json':payload}, function(er, res) { | ||
request.post({'uri':DB+'/_bulk_docs', 'json':payload}, function(er, res, body) { | ||
if(er) throw er | ||
@@ -125,6 +139,3 @@ | ||
if(res.body.length < 1500) | ||
throw new Error('Seems like at least 1,500 docs should have been added: ' + res.body.length) | ||
res.body.forEach(function(result) { | ||
body.forEach(function(result) { | ||
if(!result || !result.id || !result.rev) | ||
@@ -131,0 +142,0 @@ throw new Error('Bad bulk_docs response: ' + util.inspect(result)) |
@@ -248,1 +248,24 @@ var tap = require('tap') | ||
}) | ||
test('Follow _db_updates', function (t) { | ||
t.plan(4); | ||
var count = 0; | ||
var types = ['created']; | ||
var db_name = couch.DB.split('/').slice(-1)[0]; | ||
var feed = new follow.Feed({db: couch.DB_UPDATES}); | ||
feed.on('error', function (error) { | ||
t.false(error, 'Error in feed ' + error); | ||
}); | ||
feed.on('change', function (change) { | ||
t.ok(change, 'Received a change ' + JSON.stringify(change)); | ||
t.equal(change.type, types[count], 'Change should be of type "' + types[count] + '"'); | ||
t.equal(change.db_name, db_name + 1, 'Change should have db_name with the name of the db where the change occoured.'); | ||
feed.stop(); | ||
}); | ||
feed.start(); | ||
couch.create_and_delete_db(t, function () { | ||
t.ok(true, 'things happened'); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
228462
2993
208
22
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedasn1@0.1.11(transitive)
+ Addedassert-plus@0.1.5(transitive)
+ Addedasync@0.9.2(transitive)
+ Addedaws-sign2@0.5.0(transitive)
+ Addedbl@0.9.5(transitive)
+ Addedbluebird@2.11.0(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedcaseless@0.9.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcombined-stream@0.0.7(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addedctype@0.5.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddelayed-stream@0.0.5(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedform-data@0.2.0(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedhar-validator@1.8.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhawk@2.3.1(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedhttp-signature@0.10.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedmime-db@1.12.0(transitive)
+ Addedmime-types@2.0.14(transitive)
+ Addedms@2.0.0(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedoauth-sign@0.6.0(transitive)
+ Addedqs@2.4.2(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedrequest@2.55.0(transitive)
+ Addedsntp@1.0.9(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedtldts@6.1.61(transitive)
+ Addedtldts-core@6.1.61(transitive)
+ Addedtough-cookie@5.0.0(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddebug@0.7.4(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updateddebug@^2.1.0
Updatedrequest@~2.55.0