Socket
Book a DemoInstallSign in
Socket

tbs-cron-queue

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tbs-cron-queue

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 inte

0.1.6
latest
Source
npmnpm
Version published
Weekly downloads
19
11.76%
Maintainers
1
Weekly downloads
 
Created
Source

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:

  • add-queue => will add your cron job to redis queue
  • clean-queue => will remove all redis queue
  • single-queue => will remove single cron job data from redis queue
  • 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.

FAQs

Package last updated on 10 May 2024

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.