Skip to content

Commit 7c36125

Browse files
committed
what is the issue
1 parent 4b75795 commit 7c36125

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

nohup.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,3 +4354,5 @@ Error: Command failed: ./watch.sh 80 8888
43544354
}
43554355
watching ./src
43564356
watching ./src
4357+
change services/service-mesh/nats-mesh.js
4358+
change services/service-mesh/nats-mesh.js
Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1 @@
1-
const { connect, StringCodec } = require('nats')
2-
3-
const sc = StringCodec
4-
5-
exports.subscribe = async function (eventName, callback) {
6-
// to create a connection to a nats-server:
7-
const nc = await connect({ servers: 'demo.nats.io:4222' })
8-
9-
// create a simple subscriber and iterate over messages
10-
// matching the subscription
11-
const sub = nc.subscribe(eventName)
12-
;(async () => {
13-
for await (const m of sub) {
14-
const message = JSON.parse(sc.decode(m.data))
15-
console.log(`[${sub.getProcessed()}]: ${message}`)
16-
callback(eventName, message)
17-
}
18-
console.log('subscription closed')
19-
})()
20-
}
21-
22-
exports.publish = function (event, broker) {
23-
console.log('calling NATS publish')
24-
nc.publish(event.eventName, sc.encode(JSON.stringify(event)))
25-
}
26-
27-
exports.attachServer = function (server) {
28-
console.log('web socket server attached to NATS', server)
29-
}
1+
//

0 commit comments

Comments
 (0)