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

blezer

v0.12.7

Published

[![npm](https://img.shields.io/npm/v/blezer.svg)](https://www.npmjs.com/package/blezer) [![npm](https://img.shields.io/npm/dm/blezer.svg)](https://www.npmjs.com/package/blezer)

Downloads

11

Readme

blezer

npm npm

Blezer is a simple background job/task processing queue for Node.js (>= 7.6) using cluster & separate Node processes, powered by Redis.

Features

  • [x] each worker runs its tasks in a separate Node.js process
  • [x] RESTful JSON API
  • [x] integrated UI
  • [x] logging per job/task
  • [ ] delay job/task execution
  • [ ] job/task expiry value for being in active state

Install

npm install -g blezer

Usage

Step 1: Create a task

Each job triggers an execution of a Task i.e. a recipe what to do for that job. It is defined as a class with perform method. Task corresponds to Worker from similar projects such as resque or sidekiq. It is named this way to avoid the clash with cluster workers.

const { Task } = require('blezer');  

class LoopTask extends Task {
  perform(args) {
    this.log(`Running inside: ${process.pid}`);
    this.log(`Args: ${args}`);

    let progress = 0;
    for (var i = 0; i < 1e10; i++) {
      if (i % 1e8 == 0) {
        this.log(i)
        this.progress(progress, 100);
        progress++;
      }
    }
  }
}

module.exports = LoopTask

Step 2: Run the server

Put your tasks in tasks/ directory and run

blezer start

By default, it checks available number of cores and it instantiates the number of Node processes accordingly. You can specify number of process by hand using -c option. Type blezer start --help to see all available options.

Step 3: Enqueue a job

You can enqueue a job to perform given task from a JavaScript application

const { enqueue } = require('blezer');

enqueue('LoopTask', '[1, 2, 3]');

By default, the enqueue function puts the new job on default queue; this can be changed with the name parameter from options.

enqueue('LoopTask', '[1, 2, 3]', { name: 'high' });

A job can be scheduled to run at a specific time using scheduledAt parameter.

enqueue('LoopTask', '[1, 2, 3]', { name: 'high', scheduledAt: Date.now() + Sugar.Number.days(4) });

It is also possible to enqueue a job through Blezer REST API

http POST :3000/api/enqueue task=LoopTask args='[1,2,3]'

(optional) Step 4: Check the progress via UI

Go to localhost:3000 to check the job proegress through Blezer UI.

Blezer UI

Blezer comes with a built-in web UI that allows to quickly see the status of all jobs. Here's a preview of what it looks like:

Blezer UI

Environments

You can distinguish visually the UI between staging and production environments by specifying BLEZER_ENV variable accordingly. You can set this variable when launching Blezer with blezer start e.g.

BLEZER_ENV=production blezer start

It will add a small color bar at the top to help you identify at a glance which UI instance you are currently using.


Concepts

Queues

Queue is a list of Job items, stored so as to be retrievable and handled in the order of insertion. You can create a Queue by giving it a name. This is a lower level API which usually shouldn't be used directly - it's advised to use enqueue helper.

const { Queue } = require('blezer');
const highQueue = new Queue('high');

Logging

You can log on per job/task basis by using this.log(message) method, where message is an object or a string.

this.log("This is my log message");
this.log({ a: 1, b: 2});

Create tasks from CLI

You can create a task in tasks using CLI

blezer create foo

This command will create FooTask.js task in tasks/ directory.

Roadmap

Blezer keeps track of the upcoming fixes and features on GitHub Projects: Blezer Roadmap

Bug reports

We use Github Issues for managing bug reports and feature requests. If you run into problems, please search the issues or submit a new one here: https://github.com/zaiste/blezer/issues

Detailed bug reports are always great; it's event better if you are able to include test cases.

Roadmap

  • [ ] visualisation with Clui https://github.com/nathanpeck/clui

Contributing

  • run the code through prettier