Minor fixes after merging PR #33, adding cluster connection example in samples/simple.js

This commit is contained in:
Nicolas Dextraze 2017-04-26 18:10:27 -07:00
parent a1b9d6db9b
commit 917b89cf3d
4 changed files with 22 additions and 14 deletions

View File

@ -1,22 +1,30 @@
// const client = require('../src/client') const client = require('../src/client')
const client = require("eventstore-node") // const client = require("eventstore-node")
const uuid = require("uuid") const uuid = require("uuid")
const settings = { const settings = {
verboseLogging: true, verboseLogging: true,
log: new client.FileLogger("./simple-verbose.log") log: new client.FileLogger("./simple-verbose.log")
} }
/*
// connecting to Cluster using hard-coded gossip seeds
const gossipSeeds = [ const gossipSeeds = [
new client.GossipSeed({host: "192.168.33.10", port: 2113}), new client.GossipSeed({host: "192.168.33.10", port: 2113}),
new client.GossipSeed({host: "192.168.33.11", port: 2113}), new client.GossipSeed({host: "192.168.33.11", port: 2113}),
new client.GossipSeed({host: "192.168.33.12", port: 2113}) new client.GossipSeed({host: "192.168.33.12", port: 2113})
] ]
const connection = client.createConnection(settings, gossipSeeds) const connection = client.createConnection(settings, gossipSeeds)
*/
/*
// connecting to Cluster using dns discovery, note that cluster gossip over external http port not tcp port
const connection = client.createConnection(settings, 'discover://my.dns:2113')
*/
const connection = client.createConnection(settings, 'tcp://localhost:1113')
connection.connect().catch(err => console.log(err)) connection.connect().catch(err => console.log(err))
connection.on("connected", endPoint => { connection.on("connected", tcpEndPoint => {
console.log(`connected to endPoint ${endPoint}`) console.log(`connected to endPoint ${tcpEndPoint.host}:${tcpEndPoint.port}`)
setInterval(() => { setInterval(() => {
connection.appendToStream( connection.appendToStream(

View File

@ -1,9 +1,9 @@
// const client = require('../src/client') const client = require('../src/client')
const client = require("eventstore-node") // const client = require("eventstore-node")
const uuid = require("uuid") const uuid = require("uuid")
const settings = {} const settings = {}
const endpoint = { host: "localhost", port: 1113 } const endpoint = "tcp://localhost:1113"
const connection = client.createConnection(settings, endpoint) const connection = client.createConnection(settings, endpoint)
connection.connect().catch(err => console.log(err)) connection.connect().catch(err => console.log(err))

View File

@ -1,7 +1,7 @@
// Subscribe to all new events on the $all stream. Filter out any which aren"t about "user" aggregates. // Subscribe to all new events on the $all stream. Filter out any which aren"t about "user" aggregates.
// const client = require('../src/client') const client = require('../src/client')
const client = require("eventstore-node") // const client = require("eventstore-node")
const resolveLinkTos = false const resolveLinkTos = false
@ -24,7 +24,7 @@ const subscriptionDropped = (subscription, reason, error) =>
const credentials = new client.UserCredentials("admin", "changeit") const credentials = new client.UserCredentials("admin", "changeit")
const settings = {} const settings = {}
const endpoint = { host: "localhost", port: 1113 } const endpoint = "tcp://localhost:1113"
const connection = client.createConnection(settings, endpoint) const connection = client.createConnection(settings, endpoint)
connection.connect().catch(err => console.log(err)) connection.connect().catch(err => console.log(err))

View File

@ -1,10 +1,10 @@
// Subscribe to all events on the $all stream. Catch up from the beginning, then listen for any new events as they occur. // Subscribe to all events on the $all stream. Catch up from the beginning, then listen for any new events as they occur.
// This could be used for subscribers which populate read models. // This could be used for subscribers which populate read models.
// const client = require('../src/client') const client = require('../src/client')
const client = require("eventstore-node") // const client = require("eventstore-node")
const eventAppeared => (stream, event) => const eventAppeared = (stream, event) =>
console.log( console.log(
event.originalEvent.eventStreamId, event.originalEvent.eventStreamId,
event.originalEvent.eventId, event.originalEvent.eventId,
@ -22,7 +22,7 @@ const subscriptionDropped = (subscription, reason, error) =>
const credentials = new client.UserCredentials("admin", "changeit") const credentials = new client.UserCredentials("admin", "changeit")
const settings = {} const settings = {}
const endpoint = { host: "localhost", port: 1113 } const endpoint = "tcp://localhost:1113"
const connection = client.createConnection(settings, endpoint) const connection = client.createConnection(settings, endpoint)
connection.connect().catch(err => console.log(err)) connection.connect().catch(err => console.log(err))