New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pulsecron/pulse

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pulsecron/pulse - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

24

dist/job/fail.js

@@ -8,11 +8,19 @@ "use strict";

const fail = function (reason) {
if (reason instanceof Error) {
reason = reason.message;
const failReason = reason instanceof Error ? reason.message : reason;
const attrs = this.attrs;
attrs.failReason = failReason;
attrs.failCount = (attrs.failCount || 0) + 1;
attrs.runCount = attrs.runCount || 1;
const now = new Date();
attrs.failedAt = attrs.lastFinishedAt = now;
debug('[%s:%s] fail() called [%d] times so far', attrs.name, attrs._id, attrs.failCount);
const attempts = attrs.attempts || 0;
const step = attrs.runCount <= attempts * (attempts + 1) ? Math.ceil(attrs.runCount / (attempts + 1)) : attempts;
const retryCount = attrs.failCount - step;
const backoff = attrs.backoff;
if (attempts && backoff && retryCount < step * attempts) {
const delayMultiplier = backoff.type === 'fixed' ? 1 : Math.pow(2, retryCount);
attrs.nextRunAt = new Date(now.getTime() + delayMultiplier * backoff.delay);
debug('[%s:%s] setting retry at time [%s]', attrs.name, attrs._id, attrs.nextRunAt);
}
this.attrs.failReason = reason;
this.attrs.failCount = (this.attrs.failCount || 0) + 1;
const now = new Date();
this.attrs.failedAt = now;
this.attrs.lastFinishedAt = now;
debug('[%s:%s] fail() called [%d] times so far', this.attrs.name, this.attrs._id, this.attrs.failCount);
return this;

@@ -19,0 +27,0 @@ };

@@ -43,2 +43,3 @@ import * as mongodb from 'mongodb';

lastRunAt?: Date;
runCount?: number;
lastFinishedAt?: Date;

@@ -48,2 +49,3 @@ startDate?: Date | number | null;

skipDays?: string | null;
finishedCount?: number;
failReason?: string;

@@ -54,2 +56,7 @@ failCount?: number;

shouldSaveResult?: boolean;
attempts?: number;
backoff?: {
type: 'exponential' | 'fixed';
delay: number;
};
result?: unknown;

@@ -56,0 +63,0 @@ }

@@ -13,2 +13,3 @@ "use strict";

this.attrs.lastRunAt = new Date();
this.attrs.runCount = (this.attrs.runCount || 0) + 1;
debug('[%s:%s] setting lastRunAt to: %s', this.attrs.name, this.attrs._id, this.attrs.lastRunAt.toISOString());

@@ -28,2 +29,3 @@ this.computeNextRunAt();

this.attrs.lastFinishedAt = new Date();
this.attrs.finishedCount = (this.attrs.finishedCount || 0) + 1;
if (this.attrs.shouldSaveResult && result) {

@@ -30,0 +32,0 @@ this.attrs.result = result;

@@ -12,3 +12,18 @@ "use strict";

const shouldSaveResult = this._definitions[name] ? this._definitions[name].shouldSaveResult || false : false;
const job = new job_1.Job({ name, data, type: 'normal', priority, shouldSaveResult, pulse: this });
const attempts = this._definitions[name] ? this._definitions[name].attempts || 0 : 0;
const backoff = attempts
? this._definitions[name]
? this._definitions[name].backoff || { type: 'exponential', delay: 1000 }
: { type: 'exponential', delay: 1000 }
: undefined;
const job = new job_1.Job({
name,
data,
type: 'normal',
priority,
shouldSaveResult,
attempts,
backoff,
pulse: this,
});
return job;

@@ -15,0 +30,0 @@ };

@@ -15,2 +15,7 @@ import { Job, JobAttributesData } from '../job';

shouldSaveResult?: boolean;
attempts?: number;
backoff?: {
type: 'exponential' | 'fixed';
delay: number;
};
}

@@ -17,0 +22,0 @@ export type Processor<T extends JobAttributesData> = (job: Job<T>, done: (error?: Error, result?: unknown) => void) => unknown | Promise<unknown>;

@@ -25,2 +25,7 @@ "use strict";

shouldSaveResult: options?.shouldSaveResult || false,
attempts: options?.attempts || 0,
backoff: options?.attempts && {
type: options?.backoff?.type || 'exponential',
delay: options?.backoff?.delay || 1000,
},
};

@@ -27,0 +32,0 @@ debug('job [%s] defined with following options: \n%O', name, this._definitions[name]);

{
"name": "@pulsecron/pulse",
"version": "1.3.0",
"version": "1.4.0",
"description": "The modern MongoDB-powered scheduling library for Node.js",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -30,3 +30,3 @@ <p align="center">

- [Related Projects](#related-projects)
- [Features](#features)
- [Unique Features in Pulse](#unique-features-in-pulse)
- [Repository Structure](#repository-structure)

@@ -60,8 +60,6 @@ - [Modules](#modules)

## Features
## Unique Features in Pulse
- **High Scalability**: Designed to efficiently manage large-scale job processing.
- **Modern Architecture**: Employs the latest Node.js features and best practices for superior performance.
- **Flexible Scheduling**: Offers support for cron, one-time, and recurring jobs with fine-tuned control.
- **Seamless Integration**: Easily integrates with existing Node.js applications and MongoDB setups.
- **Resume Incomplete Tasks After System Restart**: hen the system restarts, Pulse resumes incomplete tasks that were in progress or queued for execution, providing seamless continuation without manual intervention.
- **Retry Failed Tasks**: Pulse uses an intelligent retry mechanism with configurable attempts and backoff strategies, ensuring failed tasks are retried efficiently.
- **Extensive Documentation**: Provides detailed guides and examples for a quick and easy start.

@@ -68,0 +66,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc