Bumping version to 0.0.7, exposing loggers, minor bug fixes, cluster connection (wip)
This commit is contained in:
parent
f951a625f4
commit
830a317f0d
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "eventstore-node",
|
"name": "eventstore-node",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"description": "A port of the EventStore .Net ClientAPI to Node.js",
|
"description": "A port of the EventStore .Net ClientAPI to Node.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
39
samples/simple.js
Normal file
39
samples/simple.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
var client = require('../src/client');
|
||||||
|
var uuid = require('uuid');
|
||||||
|
|
||||||
|
var settings = {
|
||||||
|
verboseLogging: true,
|
||||||
|
log: new client.FileLogger('./simple-verbose.log')
|
||||||
|
};
|
||||||
|
var gossipSeeds = [
|
||||||
|
new client.GossipSeed({hostname: 'localhost', port: 1113}),
|
||||||
|
new client.GossipSeed({hostname: 'localhost', port: 2113}),
|
||||||
|
new client.GossipSeed({hostname: 'localhost', port: 3113})
|
||||||
|
];
|
||||||
|
var conn = client.createConnection(settings, gossipSeeds);
|
||||||
|
conn.connect()
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
//process.exit(-1);
|
||||||
|
});
|
||||||
|
conn.on('connected', function (endPoint) {
|
||||||
|
console.log('connected to endPoint', endPoint);
|
||||||
|
//Start some work
|
||||||
|
setInterval(function () {
|
||||||
|
conn.appendToStream('test-' + uuid.v4(), client.expectedVersion.noStream, [
|
||||||
|
client.createJsonEventData(uuid.v4(), {abc: 123}, null, 'MyEvent')
|
||||||
|
]).then(function (writeResult) {
|
||||||
|
console.log(writeResult);
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
conn.on('error', function (err) {
|
||||||
|
console.log('Error occurred on connection:', err);
|
||||||
|
});
|
||||||
|
conn.on('closed', function (reason) {
|
||||||
|
console.log('Connection closed, reason:', reason);
|
||||||
|
//process.exit(-1);
|
||||||
|
});
|
||||||
|
process.stdin.setRawMode(true);
|
||||||
|
process.stdin.resume();
|
||||||
|
process.stdin.on('data', process.exit.bind(process, 0));
|
|
@ -38,24 +38,27 @@ function eventDataFactory(eventId, type, isJson, data, metadata) {
|
||||||
return new EventData(eventId, type, isJson, data, metadata);
|
return new EventData(eventId, type, isJson, data, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exporting classes
|
// Expose classes
|
||||||
module.exports.EventStoreConnection = require('./eventStoreConnection');
|
module.exports.EventStoreConnection = require('./eventStoreConnection');
|
||||||
module.exports.UserCredentials = require('./systemData/userCredentials');
|
module.exports.UserCredentials = require('./systemData/userCredentials');
|
||||||
module.exports.EventData = EventData;
|
module.exports.EventData = EventData;
|
||||||
module.exports.PersistentSubscriptionSettings = require('./persistentSubscriptionSettings');
|
module.exports.PersistentSubscriptionSettings = require('./persistentSubscriptionSettings');
|
||||||
module.exports.SystemConsumerStrategies = require('./systemConsumerStrategies');
|
module.exports.SystemConsumerStrategies = require('./systemConsumerStrategies');
|
||||||
module.exports.GossipSeed = require('./gossipSeed');
|
module.exports.GossipSeed = require('./gossipSeed');
|
||||||
// Exporting errors
|
// Expose errors
|
||||||
module.exports.WrongExpectedVersionError = require('./errors/wrongExpectedVersionError');
|
module.exports.WrongExpectedVersionError = require('./errors/wrongExpectedVersionError');
|
||||||
module.exports.StreamDeletedError = require('./errors/streamDeletedError');
|
module.exports.StreamDeletedError = require('./errors/streamDeletedError');
|
||||||
module.exports.AccessDeniedError = require('./errors/accessDeniedError');
|
module.exports.AccessDeniedError = require('./errors/accessDeniedError');
|
||||||
// Exporting enums/constants
|
// Expose enums/constants
|
||||||
module.exports.expectedVersion = expectedVersion;
|
module.exports.expectedVersion = expectedVersion;
|
||||||
module.exports.positions = positions;
|
module.exports.positions = positions;
|
||||||
module.exports.systemMetadata = require('./common/systemMetadata');
|
module.exports.systemMetadata = require('./common/systemMetadata');
|
||||||
module.exports.eventReadStatus = results.EventReadStatus;
|
module.exports.eventReadStatus = results.EventReadStatus;
|
||||||
module.exports.sliceReadStatus = require('./sliceReadStatus');
|
module.exports.sliceReadStatus = require('./sliceReadStatus');
|
||||||
// Helper functions
|
// Expose loggers
|
||||||
|
module.exports.NoopLogger = require('./common/log/noopLogger');
|
||||||
|
module.exports.FileLogger = require('./common/log/fileLogger');
|
||||||
|
// Expose Helper functions
|
||||||
module.exports.createConnection = module.exports.EventStoreConnection.create;
|
module.exports.createConnection = module.exports.EventStoreConnection.create;
|
||||||
module.exports.createEventData = eventDataFactory;
|
module.exports.createEventData = eventDataFactory;
|
||||||
module.exports.createJsonEventData = jsonEventDataFactory;
|
module.exports.createJsonEventData = jsonEventDataFactory;
|
|
@ -6,7 +6,7 @@ function FileLogger(filePath, append) {
|
||||||
this._filePath = filePath;
|
this._filePath = filePath;
|
||||||
if (!append) {
|
if (!append) {
|
||||||
try {
|
try {
|
||||||
fs.unlink(filePath);
|
fs.unlinkSync(filePath);
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ SimpleQueuedHandler.prototype.registerHandler = function(type, handler) {
|
||||||
try {
|
try {
|
||||||
handler(msg);
|
handler(msg);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log('ERROR: ', e);
|
console.log('ERROR: ', e.stack);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,8 @@ function setUp(cb) {
|
||||||
settings.log.error(error, "Connection to %j failed.", tcpEndPoint);
|
settings.log.error(error, "Connection to %j failed.", tcpEndPoint);
|
||||||
cb(error);
|
cb(error);
|
||||||
});
|
});
|
||||||
this.conn.on('connected', function () {
|
this.conn.on('connected', function (tcpEndPoint) {
|
||||||
|
if (connected) return;
|
||||||
settings.log.debug("Connected to %j.", tcpEndPoint);
|
settings.log.debug("Connected to %j.", tcpEndPoint);
|
||||||
connected = true;
|
connected = true;
|
||||||
cb();
|
cb();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user