mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 06:53:20 +02:00
In-memory reaper. TtlSet needs tests.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user