Jump To …

interfaces.js

lib/interfaces.js v0.5.0
under MIT License
(by) Jan Muehlemann (jamuhl)
   , Adriano Raiano (adrai)

Definition of modules used in eventstore. You can check an object against the interface with the checkInterface function.
Example:

 var util =  require('./util');
 util.checkInterface(myPublisher, interfaces.IPublisher);
var root = this
  , interfaces;

if (typeof exports !== 'undefined') {
    interfaces = exports;
} else {
    interfaces = root.eventStore.interfaces = {};
}

interfaces.VERSION = '0.5.0';

storage interface

interfaces.IStorage = {

addEvents: add events to the underlaying storage:

storage.addEvents(events, callback)

  • events: array of events
  • callback: function(err){}
    addEvents: function(){},
    

getEvents: get events from the underlaying storage:

storage.getEvents(streamId, minRev, maxRev, callback)

  • streamId: id for requested stream (equal to aggregateId)
  • minRev: revision startpoint . maxRev: revision endpoint (hint: -1 = to end)
  • callback: function(err, events){}
    getEvents: function(){},
    

getUndispatchedEvents: get undispatched events from the underlaying storage:

storage.getUndispatchedEvents(callback)

  • callback: function(err, events){}
    getUndispatchedEvents: function(){},
    

setEventToDispatched: sets an undispatched event to dispatched:

storage.setEventToDispatched(event)

  • event: undispatched event
    setEventToDispatched: function(){},
    

getId: gets a unique id from storage:

storage.getId(callback)

  • callback: function(err, id){}
    getId: function(){}
};

publisher interface

interfaces.IPublisher = {

publish: publishes an event:

publisher.publish(event)

  • event: undispatched event
    publish: function(){}
};

logger interface

interfaces.ILogger = {

info: logs a message with level info:

logger.info(message)

  • message: string to log
    info: function(){},
    

warn: logs a message with level warning:

logger.warn(message)

  • message: string to log
    warn: function(){},
    

error: logs a message with level error:

logger.error(message)

  • message: string to log
    error: function(){}
}