Store and run cron jobs with firebase.
Install with npm
$ npm i firebase-cron --save
var Cron = require('firebase-cron');
Main Cron
class for creating a new instance to manage cron jobs.
Params
ref
{Object}: Instance of a firebase reference pointing to the root of a firebase.queue
{Object}: Instance of a firebase refernece pointing to a firebase-queue.options
{Object}: Options specifying where the cron jobs are stored.options.endpoint
{String}: Specific endpoint relative to theref
where the cron jobs are stored (defaults tojobs
.
Example
var Firebase = require('firebase');
var ref = new Firebase('https://{your-firebase}.firebaseio.com');
var queueRef = new Firebase('https://{your-firebase}.firebaseio.com/queue');
var options = {endpoint: 'jobs'};
var cron = new Cron(ref, queueRef, options);
Add a new cron job.
Params
name
{String}: Name of the cron job.pattern
{String}: Cron job pattern. See cron job patterns for specifics.data
{Object}: Data to be pushed onto the firebase-queue when job is run.cb
{Function}: Callback function that is called after the job is added to the database.
Update a cron job.
Params
name
{String}: Name of the cron job.pattern
{String}: Cron job pattern. See cron job patterns for specifics.data
{Object}: Data to be pushed onto the firebase-queue when job is run.cb
{Function}: Callback function that is called after the job is updated in the database.
Remove a cron job.
Params
name
{String}: Name of the cron job.cb
{Function}: Callback function that is called after the job is removed from the database.
Get a cron job.
Params
name
{String}: Name of the cron job.cb
{Function}: Callback function that is called with any errors or the job.
Get all of the cron jobs.
Params
cb
{Function}: Callback function that is called retrieving all of the jobs.
Get all of the scheduled/waiting jobs.
Params
cb
{Function}: Callback function that is called after retrieveing all of the waiting jobs.
Start running the cron manager.
Params
cb
{Function}: Callback function that is called each time manager checks for jobs to run.error
{Function}: Callback function that is called if an error occurrs.
- firebase: Firebase library for Node.js | homepage
- firebase-queue: A fault-tolerant, multi-worker, multi-stage job pipeline built on Firebase | homepage
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Brian Woodward
Copyright © 2016 Brian Woodward Released under the MIT license.
This file was generated by verb on January 01, 2016.