arc-scheduler
Advanced tools
Comparing version
@@ -1,3 +0,4 @@ | ||
const ArcDate = require('arc-date'); | ||
const ArcScheduler = require('../src/index'); | ||
import {jest} from '@jest/globals'; | ||
import ArcDate from "arc-date"; | ||
import ArcScheduler from "../src/index.js"; | ||
@@ -4,0 +5,0 @@ jest.setTimeout(25000); |
@@ -1,7 +0,6 @@ | ||
const ArcDate = require('arc-date'); | ||
const ArcScheduler = require('../src/index'); | ||
import {jest} from '@jest/globals'; | ||
import ArcScheduler from "../src/index.js"; | ||
jest.setTimeout(25000); | ||
const sleep = async (_for) => { | ||
@@ -23,3 +22,3 @@ return new Promise(resolve => setTimeout(resolve, _for)); | ||
it('When queue depth is hit, additional jobs should not be added and a warning should be emitted',async ()=>{ | ||
expect.assertions(9); | ||
expect.assertions(6); | ||
@@ -30,13 +29,9 @@ //Create a new scheduler | ||
let increment = 0; | ||
TestScheduler.on(ArcScheduler.WARNING_QUEUE_DEPTH, (_depthPercent) => { | ||
//This will run 7 times (once for hitting 80%, 4 out of 5. Once for hitting 100%, and then 5 times for the other 7 jobs that complete) | ||
//This will run 2 times (before limit is hit, while we're adding jobs), and then an additional 4 times, once each time a job completes while our simulation is running (5th job ends at 126 simulation seconds, and we're only simulating 120 seconds) | ||
increment++; | ||
expect(_depthPercent).toBeGreaterThanOrEqual(0.7) | ||
}); | ||
//Now, we should receive a warning when queueLimit is hit | ||
TestScheduler.on(ArcScheduler.WARNING_QUEUE_LIMIT, (_depthPercent) => { | ||
//This should run twice (as we debounce the spam) | ||
expect(_depthPercent).toBe(1); | ||
}) | ||
//Get a new task | ||
@@ -50,3 +45,3 @@ TestTask = TestScheduler.getNewTask('testTask1'); | ||
TestTask.setJob(async (_Date) => { | ||
return sleep(250); //In this case, we would expect 8 jobs to successfully run | ||
return sleep(250); //In this case, we would expect 5 jobs to successfully run (first job on second 1, 26, 51, 76, 101). | ||
}); | ||
@@ -53,0 +48,0 @@ |
{ | ||
"name": "arc-scheduler", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "A thin task scheduler, for easily managing recurrent or single fire tasks.", | ||
"main": "./src/index.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "jest --coverage" | ||
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage", | ||
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watchAll" | ||
}, | ||
@@ -25,8 +27,8 @@ "repository": { | ||
"devDependencies": { | ||
"jest": "^27.5.1" | ||
"jest": "^29.2.2" | ||
}, | ||
"dependencies": { | ||
"arc-date": "^2.1.3", | ||
"arc-events": "^2.0.1" | ||
"arc-date": "^3.0.0", | ||
"arc-events": "^3.0.0" | ||
} | ||
} |
@@ -1,6 +0,5 @@ | ||
const ArcEvents = require('arc-events'); | ||
const ArcDate = require('arc-date'); | ||
import ArcEvents from "arc-events"; | ||
import ArcDate from "arc-date"; | ||
import TaskConfig from './TaskConfig.js' | ||
const TaskConfig = require('./TaskConfig'); | ||
class ArcScheduler { | ||
@@ -407,6 +406,4 @@ static get INTERVAL_SECONDS_1(){ return 's1'; } | ||
//If there hasn't been enough time since last run, skip. | ||
// console.log('Hit here???', _now, task.getNextRunnableTime()); | ||
continue; | ||
} | ||
// console.log('!!!'); | ||
@@ -515,2 +512,2 @@ //So, if month of year is set AND those months DO NOT include our current month, skip | ||
module.exports = ArcScheduler; | ||
export default ArcScheduler; |
@@ -1,3 +0,1 @@ | ||
const ArcDate = require('arc-date'); | ||
class TaskConfig { | ||
@@ -161,2 +159,2 @@ constructor(_Scheduler, _id, _lastRunTime) { | ||
module.exports = TaskConfig; | ||
export default TaskConfig; |
Yes
NaN40960
-0.09%796
-0.62%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated