Adding tests
This commit is contained in:
@ -189,7 +189,6 @@ SubscriptionOperation.prototype.dropSubscription = function(reason, err, connect
|
||||
if (reason !== SubscriptionDropReason.UserInitiated && this._subscription === null)
|
||||
{
|
||||
if (err === null) throw new Error(util.format("No exception provided for subscription drop reason '%s", reason));
|
||||
//TODO: this should be last thing to execute
|
||||
this._cb(err);
|
||||
return;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ var BufferSegment = require('../common/bufferSegment');
|
||||
var InspectionDecision = require('../systemData/inspectionDecision');
|
||||
var InspectionResult = require('./../systemData/inspectionResult');
|
||||
var results = require('../results');
|
||||
var VolatileEventStoreSubscription = require('../volatileEventStoreConnection');
|
||||
var VolatileEventStoreSubscription = require('../volatileEventStoreSubscription');
|
||||
|
||||
function VolatileSubscriptionOperation(
|
||||
log, cb, streamId, resolveLinkTos, userCredentials, eventAppeared,
|
||||
|
@ -43,13 +43,21 @@ function merge(a,b) {
|
||||
/**
|
||||
* Create an EventStore connection
|
||||
* @param {object} settings
|
||||
* @param {object} tcpEndPoint
|
||||
* @param {string|object} endPoint
|
||||
* @param {string} [connectionName]
|
||||
* @returns {EventStoreNodeConnection}
|
||||
*/
|
||||
module.exports.create = function(settings, tcpEndPoint, connectionName) {
|
||||
//TODO: cluster connection
|
||||
var mergedSettings = merge(defaultConnectionSettings, settings || {});
|
||||
var endpointDiscoverer = new StaticEndpointDiscoverer(tcpEndPoint, settings.useSslConnection);
|
||||
return new EventStoreNodeConnection(mergedSettings, endpointDiscoverer, connectionName || null);
|
||||
module.exports.create = function(settings, endPoint, connectionName) {
|
||||
if (typeof endPoint === 'object') {
|
||||
var mergedSettings = merge(defaultConnectionSettings, settings || {});
|
||||
var endpointDiscoverer = new StaticEndpointDiscoverer(endPoint, settings.useSslConnection);
|
||||
return new EventStoreNodeConnection(mergedSettings, endpointDiscoverer, connectionName || null);
|
||||
}
|
||||
if (typeof endPoint === 'string') {
|
||||
//TODO: tcpEndpoint represented as tcp://hostname:port
|
||||
//TODO: cluster discovery via dns represented as discover://dns:?port
|
||||
throw new Error('Not implemented.');
|
||||
}
|
||||
//TODO: cluster discovery via gossip seeds in settings
|
||||
throw new Error('Not implemented.');
|
||||
};
|
@ -381,8 +381,10 @@ EventStoreNodeConnection.prototype.readAllEventsBackward = function(
|
||||
EventStoreNodeConnection.prototype.subscribeToStream = function(
|
||||
stream, resolveLinkTos, eventAppeared, subscriptionDropped, userCredentials
|
||||
) {
|
||||
if (typeof stream !== 'string' || stream === '') throw new TypeError("stream must be a non-empty string.");
|
||||
if (typeof eventAppeared !== 'function') throw new TypeError("eventAppeared must be a function.");
|
||||
ensure.notNullOrEmpty(stream, "stream");
|
||||
ensure.isTypeOf(Function, eventAppeared, "eventAppeared");
|
||||
if (subscriptionDropped)
|
||||
ensure.isTypeOf(Function, subscriptionDropped, "subscriptionDropped");
|
||||
|
||||
var self = this;
|
||||
return new Promise(function(resolve,reject) {
|
||||
|
@ -10,15 +10,15 @@ var EventStoreSubsription = require('./eventStoreSubscription');
|
||||
* @constructor
|
||||
* @augments {EventStoreSubscription}
|
||||
*/
|
||||
function VolatileEventStoreConnection(subscriptionOperation, streamId, lastCommitPosition, lastEventNumber) {
|
||||
function VolatileEventStoreSubscription(subscriptionOperation, streamId, lastCommitPosition, lastEventNumber) {
|
||||
EventStoreSubsription.call(this, streamId, lastCommitPosition, lastEventNumber);
|
||||
|
||||
this._subscriptionOperation = subscriptionOperation;
|
||||
}
|
||||
util.inherits(VolatileEventStoreConnection, EventStoreSubsription);
|
||||
util.inherits(VolatileEventStoreSubscription, EventStoreSubsription);
|
||||
|
||||
VolatileEventStoreConnection.prototype.unsubscribe = function() {
|
||||
VolatileEventStoreSubscription.prototype.unsubscribe = function() {
|
||||
this._subscriptionOperation.unsubscribe();
|
||||
};
|
||||
|
||||
module.exports = VolatileEventStoreConnection;
|
||||
module.exports = VolatileEventStoreSubscription;
|
Reference in New Issue
Block a user