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

tbs-cron-queue

v0.1.6

Published

Package for handling cron job queue issue. Will queueing every cron job added with redis distribution between pods. <br><br> ___Note: This package will running on 5s interval on background to check and pick the queue. Also every cron will be run with inte

Downloads

57

Readme

TBS Cron Job Queue Service

Package for handling cron job queue issue. Will queueing every cron job added with redis distribution between pods. Note: This package will running on 5s interval on background to check and pick the queue. Also every cron will be run with internal api call with axios. So remind that your cron job API with block API mechanism

Installation

Yarn

yarn add tbs-cron-queue tbs-site-config global-body-validator-tbs

NPM

npm install tbs-cron-queue tbs-site-config global-body-validator-tbs

Getting Started

For initializing package you need to write in 2 file

app.module.ts

import { TbsCronQueueModule } from 'tbs-cron-queue';

@Module({
  imports: [
    TbsCronQueueModule.register({
      options: { 
        port: +process.env.REDIS_PORT, 
        host: process.env.REDIS_HOST 
      },
      prefix: process.env.CRON_JOB_QUEUE_PREFIX,
      baseUrl: process.env.CRON_JOB_BASE_URL,
      site_config_prefix: process.env.KAFKA_TOPIC_PREFIX,
    })
  ],
  controllers: [],
  providers: [],
})
export class ExampleModule {}

Adding Cron Job

After initialize this module on your app.module, you can see the controller below on swagger with tags name Queue Worker. Just redirect your cron job url to this controller.

How Package Works

In package controller will have 4 API, with detail:

  1. add-queue => will add your cron job to redis queue
  2. clean-queue => will remove all redis queue
  3. single-queue => will remove single cron job data from redis queue
  4. health-check => will return 200 when there's no queue running on pods and 403 when any queue is running on pods

How the add queue works ?

add-queue will check in redis queue, is that cron job url and method is registered unleash on processing queue or waiting queue. When that cron is in that state, so cron will be rejected, and vice versa when cron is not in any state then will be inserted to waiting queue.

How the clean queue works ?

clean-queue will remove all of processing queue and waiting queue

How the single queue works ?

single-queue will remove a single cron from processing queue and waiting queue based on http method and url target combination you gave

How health check works ?

health-check will check is this pods is running any queue or not. When the pods running any queue then response will be 403 and cant receive any traffic, vice versa will return response 200. So we recommend that your liveness probe and rediness probe of your kubernetes is directed here.