Skip to content

Commit b58ee1d

Browse files
committed
Start working on scrud-realtime module
1 parent 9e83ecd commit b58ee1d

7 files changed

Lines changed: 527 additions & 0 deletions

File tree

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,11 @@ db.json
4646
_db.json
4747
database.json
4848
_database.json
49+
50+
# Anything other than gitkeep in realtime/gopath dirs
51+
realtime/gopath/bin/*
52+
!realtime/gopath/bin/.gitkeep
53+
realtime/gopath/pkg/*
54+
!realtime/gopath/pkg/.gitkeep
55+
realtime/gopath/src/*
56+
!realtime/gopath/src/.gitkeep

realtime/gopath/bin/.gitkeep

Whitespace-only changes.

realtime/gopath/pkg/.gitkeep

Whitespace-only changes.

realtime/gopath/src/.gitkeep

Whitespace-only changes.

realtime/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
const { join } = require('path')
4+
const ngoOpts = {goPath: join(__dirname, 'gopath')}
5+
const ngo = require('ngo')
6+
const EMITTER_LISTEN = `:6788`
7+
let broker
8+
9+
async function startBroker (brokerOpts = {EMITTER_LISTEN}) {
10+
await ngo(ngoOpts)(['get', 'github.com/emitter-io/emitter'])
11+
let emitter = ngo(ngoOpts).bin('emitter')
12+
let { stderr } = await emitter()
13+
brokerOpts.EMITTER_LICENSE = stderr.match(/license: (.+)/)[1]
14+
// let key = stderr.match(/key: (.+)/)[1]
15+
let getBroker = () => {
16+
broker = ngo(Object.assign({env: brokerOpts}, ngoOpts)).bin('emitter')()
17+
broker.on('exit', getBroker)
18+
}
19+
getBroker()
20+
}
21+
22+
startBroker()

0 commit comments

Comments
 (0)