Browse Source

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

v4_proto
Nicolas Dextraze 5 years ago
parent
commit
917b89cf3d
  1. 16
      samples/simple.js
  2. 6
      samples/store-event.js
  3. 6
      samples/subscribe-all-events.js
  4. 8
      samples/subscribe-catchup-all-events.js

16
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(

6
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))

6
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))

8
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))

Loading…
Cancel
Save