Error if unable to resolve endpoints.

This commit is contained in:
Simo Kinnunen
2014-12-18 16:29:15 +09:00
parent 2f8116dfe6
commit eb841161ac
6 changed files with 66 additions and 24 deletions

View File

@@ -12,15 +12,15 @@ module.exports = syrup.serial()
// Output
var push = zmq.socket('push')
Promise.map(options.endpoints.push, function(endpoint) {
return srv.resolve(endpoint).then(function(records) {
return srv.attempt(records, function(record) {
log.info('Sending output to "%s"', record.url)
push.connect(record.url)
return Promise.resolve(true)
return Promise.map(options.endpoints.push, function(endpoint) {
return srv.resolve(endpoint).then(function(records) {
return srv.attempt(records, function(record) {
log.info('Sending output to "%s"', record.url)
push.connect(record.url)
return Promise.resolve(true)
})
})
})
})
return push
.return(push)
})

View File

@@ -6,6 +6,7 @@ var Promise = require('bluebird')
var logger = require('../../../util/logger')
var wireutil = require('../../../wire/util')
var srv = require('../../../util/srv')
var lifecycle = require('../../../util/lifecycle')
module.exports = syrup.serial()
.define(function(options) {
@@ -13,21 +14,22 @@ module.exports = syrup.serial()
// Input
var sub = zmq.socket('sub')
Promise.map(options.endpoints.sub, function(endpoint) {
return srv.resolve(endpoint).then(function(records) {
return srv.attempt(records, function(record) {
log.info('Receiving input from "%s"', record.url)
sub.connect(record.url)
return Promise.resolve(true)
return Promise.map(options.endpoints.sub, function(endpoint) {
return srv.resolve(endpoint).then(function(records) {
return srv.attempt(records, function(record) {
log.info('Receiving input from "%s"', record.url)
sub.connect(record.url)
return Promise.resolve(true)
})
})
})
})
// Establish always-on channels
;[wireutil.global].forEach(function(channel) {
log.info('Subscribing to permanent channel "%s"', channel)
sub.subscribe(channel)
})
return sub
.then(function() {
// Establish always-on channels
;[wireutil.global].forEach(function(channel) {
log.info('Subscribing to permanent channel "%s"', channel)
sub.subscribe(channel)
})
})
.return(sub)
})