TaskDependency.expire = async function(now) { assert(now instanceof Date, 'now must be given as option'); var count = 0; await Entity.scan.call(this, { expires: Entity.op.lessThan(now), }, { limit: 250, // max number of concurrent delete operations handler: entry => { count++; return entry.remove(true); }, }); return count; };
WorkerType.listWorkerTypes = async function() { let names = []; try { await Entity.scan.call(this, {}, { handler: function(item) { names.push(item.workerType); }, }); } catch (err) { throw err; } return names; };
WorkerType.loadAll = async function() { let workers = []; try { await Entity.scan.call(this, {}, { handler: function(item) { workers.push(item); }, }); } catch (err) { throw err; } return workers; };
Worker.expire = async function(now) { assert(now instanceof Date, 'now must be given as option'); let count = 0; await Entity.scan.call(this, { expires: Entity.op.lessThan(now), // don't expire quarantined hosts (as they might come out of quarantine..) quarantineUntil: Entity.op.lessThan(now), }, { limit: 250, // max number of concurrent delete operations handler: entry => { count++; return entry.remove(true); }, }); return count; };