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

beems

v0.7.1

Published

a bee-queue based minimalist toolkit for building fast, decentralized, fault tolerant and scalable microservices

Downloads

9

Readme

beems (formerly dot-bee)

a bee-queue based minimalist toolkit for building fast, decentralized, scalable and fault tolerant microservices

Install

npm i --save beems

You can also clone this repository and make use of it yourself.

git clone https://github.com/umuplus/beems.git
cd beems
npm i
npm test

Before running tests, please make sure that you have Redis available on localhost. If you don't know how to do that temporarily, please use following command to run it via docker.

docker run -p 6379:6379 --name beems_redis redis:4-alpine

Configuration

  • bee: options for initializing a bee queue instance. please see more details at Bee Queue Settings.
  • job: options for creating a bee queue job. only setId, retries, backoff, delayUntil and timeout methods allowed. please see more details at Bee Queue Job Settings.
  • on: event handlers for server. please see more details at Queue Local Events
  • pino: options for pino logger. it's { "level": "error" } by default.

Server Methods

  • .addServices(services, concurrency = cpus().length, options): adds list of services and automatically creates their queues and consumers
  • .addService(service, concurrency = cpus().length, options): adds a new service and automatically creates related queue and its consumer
  • .close(): stops all existing queues for a clean shutdown
  • .destroy(): removes everything about existing queues from redis

Client Methods

  • .acceptServices(services, options): accepts existing services to send jobs
  • .acceptService(service, options): accepts an existing service to send jobs
  • .forward(service, method, data, options): sends a new job to an existing service and returns a Job instance
  • .health(service): returns number of jobs for each state
  • .job(service, id): returns an existing Job by id
  • .send(service, method, data, options): sends a new job to an existing service and retrieves its response
  • .close(): stops all existing queues for a clean shutdown

Examples

const { Client, Service, Server } = require('beems');
const { cpus } = require('os');

class TestService extends Service {
    async echo(job) {
        return job.data;
    }
}

const client = new Client();
const server = new Server({
    on: { failed: (j, e) => server.logger.error(j.id, e.message) }
});
server.addServices([ new TestService('test') ], cpus().length);
client.acceptServices([ 'test' ]);

try {
    const data = { t: Date.now() };
    const { job, response } = await client.send('test', 'echo', data);
    console.log(job.id, response);
} catch({ job, error: e }) {
    console(job.id, e.message);
}

await client.close();
await server.destroy();
await server.close();

Optional Job Configuration

please see more details at Bee Queue Job Settings.

await client.send('test', 'echo', { t: Date.now() }, {
    setId: 'my-custom-job-id',
    retries: 2,
    backoff: [ 'fixed', 1000 ],
    delayUntil: Date.parse('2082-08-23T00:00:01.000Z'),
    timeout: 10000
});

TODO

  • Add some useful logs