Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

anton2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anton2

Fantastic Job Queue Worker

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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: 'noreply@antonproj.org',
		text: 'Hello {{name}}',
		html: '<html><body>Hello {{name}}</body></html>',
		data: [{ 
			to: 'marcos@thedon.com.br', 
			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

Keywords

FAQs

Package last updated on 28 Oct 2015

Did you know?

Socket

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.

Install

Related posts

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