npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

anton2

v1.0.1

Published

Fantastic Job Queue Worker

Downloads

5

Readme

anton2

Build Status Coverage Status

Anton is designed to help you to process hard jobs made easy =D

Instalation

npm install anton2

How it works

Anton is a queue manager build on top of bull that simplify the way to process hard jobs. The lifecycle in Anton is:

  • Register your tasks.
  • Register your transporters.
  • Create your jobs.
  • Send postback

After the bootstrap of Anton(loading tasks and transporters) you can create your jobs. When the jobs is done, with errors or not, the postback is called and notify you about the result of the job.

How to use

var Anton = require('anton2');
var emailJob = Anton.sample.tasks.email; // Load a simple job that send emails in batch.
var transporter = Anton.sample.transport.email; // Load a simple transport for the postback information about the jobs finished. On this case send to your email.

var anton = new Anton();

//One time the jobs and transporters are loaded its loaded in memory every time.

anton
.loadTask(emailJob)
.loadTransporter(transporter)
.createJob('email.job', {
	email: {
		subject: 'Just a simple test',
		from: '[email protected]',
		text: 'Hello {{name}}',
		html: '<html><body>Hello {{name}}</body></html>',
		data: [{ 
			to: '[email protected]', 
			name: 'Marcos'
		}]
	},
	credentials: {
		sendgrid_api_key: process.env.SENDGRID_API_KEY
	}
});

// you can listen for jobs in the queue.
anton.jobs['email.job'].on('completed', function(job){
	console.log(job.jobId, 'is complete');
});

anton.jobs['email.job'].on('failed', function(job, error){
	console.log(job.jobId, 'is failed', error);
});

Public Methods

loadTask(task) -> this

The task need be a function that will receive a Task object to create a new taskQueue. Redis connection information will be setted in the task function. See more in this example

loadTransporter(transporter) - this

The transporter need be a function that will receibe a data object with the information about the job results(data.results) and send to anywhere you must be! See more in this example

createJobs(type, data) -> Promise

Both type and data are required to create an job. The return is a promise with a job object where you can find the jobId.

deleteJob(type, id) -> Promise

Both type and id are required to delete a job. The return will be a promise with the job object of the removed job.

clearJobs(taskName) -> Promise

taskName is required to identify the right task and clear the jobs errored with least 5 seconds. The return will be a list with the removed jobs.

Contribuing

All help is very welcomed! Just send a Pull Requests or open an Issue