mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Make group timeout configurable.
This commit is contained in:
parent
d59c156297
commit
78c207c8d1
5 changed files with 30 additions and 12 deletions
16
lib/cli.js
16
lib/cli.js
|
@ -39,6 +39,10 @@ program
|
||||||
, 'public ip for global access'
|
, 'public ip for global access'
|
||||||
, String
|
, String
|
||||||
, ip())
|
, ip())
|
||||||
|
.option('-t, --group-timeout <seconds>'
|
||||||
|
, 'group timeout'
|
||||||
|
, Number
|
||||||
|
, 600)
|
||||||
.action(function() {
|
.action(function() {
|
||||||
var serials = cliutil.allUnknownArgs(arguments)
|
var serials = cliutil.allUnknownArgs(arguments)
|
||||||
, options = cliutil.lastArg(arguments)
|
, options = cliutil.lastArg(arguments)
|
||||||
|
@ -66,6 +70,7 @@ program
|
||||||
, '--connect-push', options.connectPush.join(',')
|
, '--connect-push', options.connectPush.join(',')
|
||||||
, '--ports', ports.join(',')
|
, '--ports', ports.join(',')
|
||||||
, '--public-ip', options.publicIp
|
, '--public-ip', options.publicIp
|
||||||
|
, '--group-timeout', options.groupTimeout
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
, endpoints: {
|
, endpoints: {
|
||||||
|
@ -98,6 +103,10 @@ program
|
||||||
, 'heartbeat interval'
|
, 'heartbeat interval'
|
||||||
, Number
|
, Number
|
||||||
, 10000)
|
, 10000)
|
||||||
|
.option('-t, --group-timeout <seconds>'
|
||||||
|
, 'group timeout'
|
||||||
|
, Number
|
||||||
|
, 600)
|
||||||
.action(function(serial, options) {
|
.action(function(serial, options) {
|
||||||
if (!options.connectSub) {
|
if (!options.connectSub) {
|
||||||
this.missingArgument('--connect-sub')
|
this.missingArgument('--connect-sub')
|
||||||
|
@ -122,6 +131,7 @@ program
|
||||||
, push: options.connectPush
|
, push: options.connectPush
|
||||||
}
|
}
|
||||||
, heartbeatInterval: options.heartbeatInterval
|
, heartbeatInterval: options.heartbeatInterval
|
||||||
|
, groupTimeout: options.groupTimeout * 1000 // change to ms
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -407,7 +417,6 @@ program
|
||||||
, ssid: options.ssid
|
, ssid: options.ssid
|
||||||
, authUrl: options.authUrl
|
, authUrl: options.authUrl
|
||||||
, storageUrl: options.storageUrl
|
, storageUrl: options.storageUrl
|
||||||
, groupTimeout: 600 * 1000
|
|
||||||
, endpoints: {
|
, endpoints: {
|
||||||
sub: options.connectSub
|
sub: options.connectSub
|
||||||
, push: options.connectPush
|
, push: options.connectPush
|
||||||
|
@ -520,6 +529,10 @@ program
|
||||||
, os.hostname())
|
, os.hostname())
|
||||||
.option('-d, --disable-watch'
|
.option('-d, --disable-watch'
|
||||||
, 'disable watching resources')
|
, 'disable watching resources')
|
||||||
|
.option('-t, --group-timeout <seconds>'
|
||||||
|
, 'group timeout'
|
||||||
|
, Number
|
||||||
|
, 600)
|
||||||
.action(function() {
|
.action(function() {
|
||||||
var log = logger.createLogger('cli:local')
|
var log = logger.createLogger('cli:local')
|
||||||
, args = arguments
|
, args = arguments
|
||||||
|
@ -574,6 +587,7 @@ program
|
||||||
, '--name', options.provider
|
, '--name', options.provider
|
||||||
, '--connect-sub', options.bindDevPub
|
, '--connect-sub', options.bindDevPub
|
||||||
, '--connect-push', options.bindDevPull
|
, '--connect-push', options.bindDevPull
|
||||||
|
, '--group-timeout', options.groupTimeout
|
||||||
].concat(cliutil.allUnknownArgs(args)))
|
].concat(cliutil.allUnknownArgs(args)))
|
||||||
|
|
||||||
// auth-mock
|
// auth-mock
|
||||||
|
|
|
@ -460,8 +460,8 @@ module.exports = function(options) {
|
||||||
, user.name
|
, user.name
|
||||||
, user.group
|
, user.group
|
||||||
)
|
)
|
||||||
, options.groupTimeout
|
, data.timeout || null
|
||||||
, wireutil.toDeviceRequirements(data)
|
, wireutil.toDeviceRequirements(data.requirements)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
@ -473,7 +473,7 @@ module.exports = function(options) {
|
||||||
, wireutil.transaction(
|
, wireutil.transaction(
|
||||||
responseChannel
|
responseChannel
|
||||||
, new wire.UngroupMessage(
|
, new wire.UngroupMessage(
|
||||||
wireutil.toDeviceRequirements(data)
|
wireutil.toDeviceRequirements(data.requirements)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
|
@ -44,7 +44,7 @@ module.exports = syrup.serial()
|
||||||
log.info('Now owned by "%s"', currentGroup.email)
|
log.info('Now owned by "%s"', currentGroup.email)
|
||||||
log.info('Subscribing to group channel "%s"', currentGroup.group)
|
log.info('Subscribing to group channel "%s"', currentGroup.group)
|
||||||
|
|
||||||
channels.register(currentGroup.group, timeout)
|
channels.register(currentGroup.group, timeout || options.groupTimeout)
|
||||||
sub.subscribe(currentGroup.group)
|
sub.subscribe(currentGroup.group)
|
||||||
|
|
||||||
push.send([
|
push.send([
|
||||||
|
|
|
@ -210,7 +210,7 @@ message OwnerMessage {
|
||||||
|
|
||||||
message GroupMessage {
|
message GroupMessage {
|
||||||
required OwnerMessage owner = 1;
|
required OwnerMessage owner = 1;
|
||||||
required uint32 timeout = 2;
|
optional uint32 timeout = 2;
|
||||||
repeated DeviceRequirement requirements = 3;
|
repeated DeviceRequirement requirements = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,11 @@ module.exports = function GroupServiceFactory(
|
||||||
groupService.invite = function (device) {
|
groupService.invite = function (device) {
|
||||||
var tx = TransactionService.create(device)
|
var tx = TransactionService.create(device)
|
||||||
socket.emit('group.invite', device.channel, tx.channel, {
|
socket.emit('group.invite', device.channel, tx.channel, {
|
||||||
serial: {
|
requirements: {
|
||||||
value: device.serial
|
serial: {
|
||||||
, match: 'exact'
|
value: device.serial
|
||||||
|
, match: 'exact'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return tx.promise.then(function(result) {
|
return tx.promise.then(function(result) {
|
||||||
|
@ -24,9 +26,11 @@ module.exports = function GroupServiceFactory(
|
||||||
groupService.kick = function (device) {
|
groupService.kick = function (device) {
|
||||||
var tx = TransactionService.create(device)
|
var tx = TransactionService.create(device)
|
||||||
socket.emit('group.kick', device.channel, tx.channel, {
|
socket.emit('group.kick', device.channel, tx.channel, {
|
||||||
serial: {
|
requirements: {
|
||||||
value: device.serial
|
serial: {
|
||||||
, match: 'exact'
|
value: device.serial
|
||||||
|
, match: 'exact'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return tx.promise.then(function(result) {
|
return tx.promise.then(function(result) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue