Permalink
Browse files

removed some functions and removed couchDb implementation

  • Loading branch information...
1 parent fdb22a2 commit 9eabd8440f59a00fedf95ca1db5bf1d006a4b9d0 @adrai committed Mar 30, 2012
@@ -20,11 +20,6 @@ util.prepare(function() {
deferred.resolve();
});
}, {defer: true})
- .add('couchDbStorage#addEvents', function(deferred) {
- util.couchDbStorage.addEvents([{streamId: uuid().toString(), commitId: uuid().toString(), payload: {event:'bla'}}], function() {
- deferred.resolve();
- });
- }, {defer: true})
// add listeners
.on('cycle', function(event, bench) {
console.log(String(bench));
@@ -30,14 +30,8 @@ util.prepare(function() {
util.redisStorage.addEvents(events, function(err) {
callback(err);
});
- },
-
- function(callback){
- util.couchDbStorage.addEvents(events, function(err) {
- callback(err);
- });
}
-
+
],
function(err, results){
@@ -57,11 +51,6 @@ util.prepare(function() {
deferred.resolve();
});
}, {defer: true})
- .add('couchDbStorage#getEvents', function(deferred) {
- util.couchDbStorage.getEvents('2', 0, -1, function(err, events) {
- deferred.resolve();
- });
- }, {defer: true})
// add listeners
.on('cycle', function(event, bench) {
console.log(String(bench));
@@ -19,11 +19,6 @@ util.prepare(function() {
//deferred.resolve();
});
}, {defer: false})
- .add('couchDbStorage#getId', function(deferred) {
- util.couchDbStorage.getId(function(err, id) {
- //deferred.resolve();
- });
- }, {defer: false})
// add listeners
.on('cycle', function(event, bench) {
console.log(String(bench));
View
@@ -33,13 +33,6 @@ index.prepare = function(clb) {
index.redisStorage = storage;
callback(err, storage);
});
- },
-
- function(callback){
- require('../storage/couchDb/storage').createStorage(options, function(err, storage) {
- index.couchDbStorage = storage;
- callback(err, storage);
- });
}
],
View
@@ -382,80 +382,47 @@ Store.prototype = {
this.storage.getId(callback);
},
-
- // __getAllEvents:__ loads the events from given storage.
- //
- // __warning:__ don't use this in production!!!
+
+ // __getEvents:__ loads the eventstream from _revMin_ to _revMax_.
//
- // `eventStore.getAllEvents(callback)`
+ // `eventStore.getEventStream(streamId, minRev, maxRev, callback)`
//
+ // - __streamId:__ id for requested stream (equal to aggregateId)
+ // - __revMin:__ revision startpoint [optional]
+ // - __revMax:__ revision endpoint (hint: -1 = to end) [optional]
// - __callback:__ `function(err, events){}`
- getAllEvents: function(callback) {
+ getEvents: function(streamId, revMin, revMax, callback) {
if (this.hasConfigurationErrors(callback)) return;
-
- this.storage.getAllEvents(function(err, events) {
-
- if (typeof callback === 'function') {
- callback(err, events);
- }
- });
-
- },
- // __getLastEventOfStream:__ loads the last event from the given stream in storage.
- //
- // `eventStore.getLastEventOfStream(streamId, callback)`
- //
- // - __streamId:__ the stream id
- // - __callback:__ `function(err, event){}`
- getLastEventOfStream: function(streamId, callback) {
+ if (typeof revMin === 'function') {
+ callback = revMin;
+ revMin = 0;
+ revMax = -1;
+ } else if (typeof revMax === 'function') {
+ callback = revMax;
+ revMax = -1;
+ }
- if (this.hasConfigurationErrors(callback)) return;
-
- this.storage.getLastEventOfStream(streamId, function(err, event) {
-
- if (typeof callback === 'function') {
- callback(err, event);
- }
- });
-
- },
-
- // __getEventRange:__ loads the events from given storage.
- //
- // `eventStore.getEventRange(index, amount, callback)`
- //
- // - __index:__ entry index
- // - __amount:__ amount of events
- // - __callback:__ `function(err, events){}`
- getEventRange: function(index, amount, callback) {
+ var self = this;
+ this.storage.getEvents(streamId, revMin, revMax, callback);
- if (this.hasConfigurationErrors(callback)) return;
-
- this.storage.getEventRange(index, amount, function(err, events) {
-
- if (typeof callback === 'function') {
- callback(err, events);
- }
- });
-
},
- // __getEventRangeMatching:__ loads the range of events from given storage.
+ // __getEventRange:__ loads the range of events from given storage.
//
- // `storage.getEventRangeMatching(match, amount, callback)`
+ // `storage.getEventRange(match, amount, callback)`
//
// - __match:__ match query in inner event (payload)
// - __amount:__ amount of events
// - __callback:__ `function(err, events){}`
- getEventRangeMatching: function(match, amount, callback) {
+ getEventRange: function(match, amount, callback) {
if (this.hasConfigurationErrors(callback)) return;
var self = this;
- this.storage.getEventRangeMatching(match, amount, function(err, events) {
+ this.storage.getEventRange(match, amount, function(err, events) {
events.next = function(callback) {
@@ -468,7 +435,7 @@ Store.prototype = {
}
}
- self.getEventRangeMatching(match, amount, callback);
+ self.getEventRange(match, amount, callback);
};
@@ -97,7 +97,7 @@ Storage.prototype = {
// - __streamId:__ id for requested stream
// - __minRev:__ revision startpoint
// - __maxRev:__ revision endpoint (hint: -1 = to end) [optional]
- // - __callback:__ `function(err, snapshot, eventStream){}`
+ // - __callback:__ `function(err, events){}`
getEvents: function(streamId, minRev, maxRev, callback) {
if (typeof maxRev === 'function') {
@@ -117,80 +117,15 @@ Storage.prototype = {
}
}
},
-
- // __getAllEvents:__ loads the events.
- //
- // __warning:__ don't use this in production!!!
- //
- // `storage.getAllEvents(callback)`
- //
- // - __callback:__ `function(err, events){}`
- getAllEvents: function(callback) {
- var events = [];
- for (var i in this.store) {
- events = events.concat(this.store[i]);
- }
-
- events.sort(function(a, b){
- return a.commitStamp - b.commitStamp;
- });
-
- callback(null, events);
- },
-
- // __getLastEventOfStream:__ loads the last event from the given stream in storage.
- //
- // `storage.getLastEventOfStream(streamId, callback)`
- //
- // - __streamId:__ the stream id
- // - __callback:__ `function(err, event){}`
- getLastEventOfStream: function(streamId, callback) {
-
- if (!this.store[streamId]) {
- callback(null, null);
- }
- else if (this.store[streamId].length) {
- callback(null, this.store[streamId][this.store[streamId].length - 1]);
- } else {
- callback(null, null);
- }
-
- },
// __getEventRange:__ loads the range of events from given storage.
//
- // `storage.getEventRange(index, amount, callback)`
- //
- // - __index:__ entry index
- // - __amount:__ amount of events
- // - __callback:__ `function(err, events){}`
- getEventRange: function(index, amount, callback) {
- var events = [];
- for (var i in this.store) {
- events = events.concat(this.store[i]);
-
- if (events.length >= (index + amount)) {
- break;
- }
- }
-
- events = events.slice(index, (index + amount));
-
- events.sort(function(a, b){
- return a.commitStamp - b.commitStamp;
- });
-
- callback(null, events);
- },
-
- // __getEventRangeMatching:__ loads the range of events from given storage.
- //
- // `storage.getEventRangeMatching(match, amount, callback)`
+ // `storage.getEventRange(match, amount, callback)`
//
// - __match:__ match query in inner event (payload)
// - __amount:__ amount of events
// - __callback:__ `function(err, events){}`
- getEventRangeMatching: function(match, amount, callback) {
+ getEventRange: function(match, amount, callback) {
var events = [];
for (var e in this.store) {
events = events.concat(this.store[e]);
@@ -1 +0,0 @@
-npmlink.js
View
@@ -1,12 +0,0 @@
-/*var index;
-
-if (typeof module.exports !== 'undefined') {
- index = module.exports;
-} else {
- index = root.index = {};
-}
-
-index.VERSION = '0.0.1';
-*/
-
-module.exports = require('./storage');
@@ -1,5 +0,0 @@
-module.exports = {
- global: true,
- dependencies: []
-};
-
@@ -1,24 +0,0 @@
-{
- "author": "Kaba MIC AWM"
- , "name": "eventstore.couchDb"
- , "version": "0.5.0"
- , "contributors": [
- { "name": "Jan Muehlemann", "email": "jan.muehlemann@gmail.com" },
- { "name": "Adriano Raiano", "email": "adriano.raiano@kaba.com" }
- ]
- , "private": false
- , "repository": {
- "type": "git"
- , "url": "git@github.com:KABA-CCEAC/nodeEventStore.git"
- }
- , "main": "./index.js"
- , "engines": {
- "node": ">= v0.6.0"
- }
- , "dependencies": {
- "cradle": ">= 0.0.1"
- }
- , "devDependencies": { }
- , "scripts" : {
- "test" : "vows test/* --spec" }
-}
Oops, something went wrong.

0 comments on commit 9eabd84

Please sign in to comment.