
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
arc-scheduler
Advanced tools
A thin task scheduler, for easily managing recurrent or single fire tasks.
A functional scheduler that enables easy functional task bindings.
$ npm install arc-scheduler --save
$ npm run test
const ArcScheduler = require('arc-scheduler');
//Create a new scheduler
const TestScheduler = new ArcScheduler();
TestScheduler.on(ArcScheduler.EVENT_NEW_DAY, ()=>{
//Do things when it's a new day!
})
//Start the scheduler
TestScheduler.startRealTime();
const ArcScheduler = require('arc-scheduler');
//Create a new scheduler
const TestScheduler = new ArcScheduler();
//Get a new task
const TestTask = TestScheduler.getNewTask('testTask1');
//Set the job to actually run
TestTask.setJob(async (_ArcDate) => {
//Do something
});
//Fire immediately, and then fire every five minutes in perpetuity
TestTask.setFireOnStart(true).setRepeatInterval(0, 5)
//Schedule it
TestScheduler.scheduleTask(TestTask);
//Start the scheduler
TestScheduler.startRealTime();
TODO: Fill in the API. For now refer to the healthyScheduler.js in the _tests_ folder to see usage patterns. Refer to the unhealthyScheduler.js in the _tests_ folder to see queueDepth management.
This system has two primary concepts. Exclusion filters (ie. check for configurations set, and identify when NOT to run), and then a repeat interval (ie. after a job CAN run, identify an interval before it can run again). By default the repeatInterval
value is set to one day. In effect, when you consider the following:
//Set days of week, time of day
TestTask.setDaysOfWeek(0,1,1).setTimeOfDay(8,9);
Every day the scheduler will check to see if it meets the exclusion criteria (is it Monday/Tuesday?). Assuming it's Monday, it will fire the job, and then use the repeatInterval to identify the minimum delay before the job can fire again. By default 24 hours later.
This keeps things relatively simple, regarding the flexibility of timing of when a job can fire based on cirucmstances (ie. if a queue is full, or a previous job is blocking, the job is comfortable at firing as close to 8:09 as possible, which may in fact be... 8:30). It can however introduce some unexpected behaviors.
For example, if you schedule a job to happen at the last second of the day (23:59:59) and it misses that window, it may now meet the exclusion criteria of the next day and not fire at all. Or, if you reduce the repeat interval to say 6 hours, and a job starts firing at 8:00, it would also fire at 14:00 and 20:00.
Or, if you try to set the repeatInterval
to say one week, after it fires the first job, even if you have it set to fire on different days of the week, it will wait a week before being eligible again.
There are ways around this, and I might eventually get annoyed and rework this approach, but for now the simplicity of the API, with consistent behavior seemed to do the trick.
FAQs
A thin task scheduler, for easily managing recurrent or single fire tasks.
The npm package arc-scheduler receives a total of 797 weekly downloads. As such, arc-scheduler popularity was classified as not popular.
We found that arc-scheduler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.