mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 09:53:21 +02:00
Make all zmq endpoints use srv records.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
var syrup = require('stf-syrup')
|
||||
|
||||
var zmq = require('zmq')
|
||||
var Promise = require('bluebird')
|
||||
|
||||
var logger = require('../../../util/logger')
|
||||
var srv = require('../../../util/srv')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.define(function(options) {
|
||||
@@ -10,9 +12,14 @@ module.exports = syrup.serial()
|
||||
|
||||
// Output
|
||||
var push = zmq.socket('push')
|
||||
options.endpoints.push.forEach(function(endpoint) {
|
||||
log.info('Sending output to %s', endpoint)
|
||||
push.connect(endpoint)
|
||||
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
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
var syrup = require('stf-syrup')
|
||||
|
||||
var zmq = require('zmq')
|
||||
var Promise = require('bluebird')
|
||||
|
||||
var logger = require('../../../util/logger')
|
||||
var wireutil = require('../../../wire/util')
|
||||
var srv = require('../../../util/srv')
|
||||
|
||||
module.exports = syrup.serial()
|
||||
.define(function(options) {
|
||||
@@ -11,9 +13,14 @@ module.exports = syrup.serial()
|
||||
|
||||
// Input
|
||||
var sub = zmq.socket('sub')
|
||||
options.endpoints.sub.forEach(function(endpoint) {
|
||||
log.info('Receiving input from %s', endpoint)
|
||||
sub.connect(endpoint)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user