1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00

In-memory reaper. TtlSet needs tests.

This commit is contained in:
Simo Kinnunen 2015-06-01 17:39:59 +09:00
parent 89aedcef06
commit 25544d1a1a
10 changed files with 231 additions and 87 deletions

View file

@ -128,7 +128,6 @@ dbapi.saveDevice = function(serial, device) {
, status: device.status
, ready: false
, statusChangedAt: r.now()
, lastHeartbeatAt: r.now()
, reverseForwards: []
}
return db.run(r.table('devices').get(serial).update(data))
@ -164,8 +163,6 @@ dbapi.unsetDeviceOwner = function(serial) {
dbapi.setDeviceAbsent = function(serial) {
return db.run(r.table('devices').get(serial).update({
present: false
, ready: false
, lastHeartbeatAt: null
}))
}
@ -263,33 +260,14 @@ dbapi.loadDevices = function() {
return db.run(r.table('devices'))
}
dbapi.loadPresentDevices = function() {
return db.run(r.table('devices').getAll(true, {
index: 'present'
}))
}
dbapi.loadDevice = function(serial) {
return db.run(r.table('devices').get(serial))
}
dbapi.updateProviderHeartbeat = function(channel) {
return db.run(
r.table('devices').getAll(channel, {
index: 'providerChannel'
})
.update({
lastHeartbeatAt: r.now()
})
, {
noreply: true
, durability: 'soft'
}
)
}
dbapi.getDeadDevices = function(timeout) {
return db.run(
r.table('devices')
.between(null, r.now().sub(timeout / 1000), {
index: 'lastHeartbeatAt'
})
.pluck('serial')
)
}
module.exports = dbapi