diff --git a/samples/simple.js b/samples/simple.js index 4a68699..629ce4b 100644 --- a/samples/simple.js +++ b/samples/simple.js @@ -1,22 +1,30 @@ -// const client = require('../src/client') -const client = require("eventstore-node") +const client = require('../src/client') +// const client = require("eventstore-node") const uuid = require("uuid") const settings = { verboseLogging: true, log: new client.FileLogger("./simple-verbose.log") } +/* +// connecting to Cluster using hard-coded gossip seeds const gossipSeeds = [ 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.12", port: 2113}) ] 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.on("connected", endPoint => { - console.log(`connected to endPoint ${endPoint}`) +connection.on("connected", tcpEndPoint => { + console.log(`connected to endPoint ${tcpEndPoint.host}:${tcpEndPoint.port}`) setInterval(() => { connection.appendToStream( diff --git a/samples/store-event.js b/samples/store-event.js index 07e9037..aa0be70 100644 --- a/samples/store-event.js +++ b/samples/store-event.js @@ -1,9 +1,9 @@ -// const client = require('../src/client') -const client = require("eventstore-node") +const client = require('../src/client') +// const client = require("eventstore-node") const uuid = require("uuid") const settings = {} -const endpoint = { host: "localhost", port: 1113 } +const endpoint = "tcp://localhost:1113" const connection = client.createConnection(settings, endpoint) connection.connect().catch(err => console.log(err)) diff --git a/samples/subscribe-all-events.js b/samples/subscribe-all-events.js index 568f109..92c7fad 100644 --- a/samples/subscribe-all-events.js +++ b/samples/subscribe-all-events.js @@ -1,7 +1,7 @@ // 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("eventstore-node") +const client = require('../src/client') +// const client = require("eventstore-node") const resolveLinkTos = false @@ -24,7 +24,7 @@ const subscriptionDropped = (subscription, reason, error) => const credentials = new client.UserCredentials("admin", "changeit") const settings = {} -const endpoint = { host: "localhost", port: 1113 } +const endpoint = "tcp://localhost:1113" const connection = client.createConnection(settings, endpoint) connection.connect().catch(err => console.log(err)) diff --git a/samples/subscribe-catchup-all-events.js b/samples/subscribe-catchup-all-events.js index 38daa03..2580ff9 100644 --- a/samples/subscribe-catchup-all-events.js +++ b/samples/subscribe-catchup-all-events.js @@ -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. // This could be used for subscribers which populate read models. -// const client = require('../src/client') -const client = require("eventstore-node") +const client = require('../src/client') +// const client = require("eventstore-node") -const eventAppeared => (stream, event) => +const eventAppeared = (stream, event) => console.log( event.originalEvent.eventStreamId, event.originalEvent.eventId, @@ -22,7 +22,7 @@ const subscriptionDropped = (subscription, reason, error) => const credentials = new client.UserCredentials("admin", "changeit") const settings = {} -const endpoint = { host: "localhost", port: 1113 } +const endpoint = "tcp://localhost:1113" const connection = client.createConnection(settings, endpoint) connection.connect().catch(err => console.log(err))