- Overview
- Installation
- Usage
- Integration Guidelines
- Examples
- Scaling and Performance
- Job Management UI
- API Endpoints
- gRPC Endpoints
- Configuration
- Error Handling
- Deployment Instructions
- Contributing
- License
- Core Features
- New Features
- Docker Instructions
- Sync Wiki to GitHub Wiki Repository
- Wiki Home
pop-queue
is a library for managing job queues using MongoDB, Redis, Memcached, and PostgreSQL. It allows you to define, enqueue, and process jobs with ease. The library is designed to handle high concurrency and large-scale systems.
For detailed documentation, please visit the GitHub wiki.
To install the library, use npm:
npm install pop-queue
To use the library, follow these steps:
- Import the library in your project.
- Create a queue by instantiating the
PopQueue
class with the required parameters. - Define jobs using the
define
method. - Enqueue jobs using the
now
method. - Start the queue using the
start
method.
For detailed usage instructions, please visit the Usage page in the GitHub wiki.
To integrate pop-queue
into your project, follow these steps:
- Install the library using npm.
- Import the library in your project.
- Create a queue by instantiating the
PopQueue
class with the required parameters. - Define jobs using the
define
method. - Enqueue jobs using the
now
method. - Start the queue using the
start
method.
For detailed integration guidelines, please visit the Integration Guidelines page in the GitHub wiki.
For examples of using the library, including basic usage, handling failures, using Memcached, using PostgreSQL, job rate limiting and concurrency control, job retries and backoff strategies, job progress tracking and completion callbacks, job data schema validation, job dependencies and flow control, built-in metrics and monitoring tools, job events and listeners, image resizing and processing job queue, and sending bulk emails to users, please visit the Examples page in the GitHub wiki.
To create a video transcoding job queue, use the ffmpeg
library:
const ffmpeg = require('fluent-ffmpeg');
queue.define('videoTranscodingJob', async (job) => {
console.log('Processing video transcoding job:', job);
const { inputPath, outputPath, format } = job.data;
await new Promise((resolve, reject) => {
ffmpeg(inputPath)
.output(outputPath)
.format(format)
.on('end', resolve)
.on('error', reject)
.run();
});
return true;
});
queue.now({ inputPath: 'input.mp4', outputPath: 'output.mp4', format: 'mp4' }, 'videoTranscodingJob', 'videoTranscodingJobIdentifier', Date.now());
queue.start();
To create an image resizing and processing job queue, use the sharp
library:
const sharp = require('sharp');
queue.define('imageResizingJob', async (job) => {
console.log('Processing image resizing job:', job);
const { inputPath, outputPath, width, height } = job.data;
await sharp(inputPath)
.resize(width, height)
.toFile(outputPath);
return true;
});
queue.now({ inputPath: 'input.jpg', outputPath: 'output.jpg', width: 800, height: 600 }, 'imageResizingJob', 'imageResizingJobIdentifier', Date.now());
queue.start();
To create a job queue for sending bulk emails to users, use the nodemailer
library:
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'your-email-password'
}
});
queue.define('bulkEmailJob', async (job) => {
console.log('Processing bulk email job:', job);
const { to, subject, text } = job.data;
await transporter.sendMail({
from: '[email protected]',
to,
subject,
text
});
return true;
});
queue.now({ to: '[email protected]', subject: 'Hello', text: 'This is a bulk email.' }, 'bulkEmailJob', 'bulkEmailJobIdentifier', Date.now());
queue.start();
For scaling and performance guidelines, including MongoDB sharding and Redis clustering, please visit the Scaling and Performance page in the GitHub wiki.
For documentation on the job management UI, including accessing the UI, UI structure, and UI files, please visit the Job Management UI page in the GitHub wiki.
For documentation on API endpoints, including getting job details and requeuing a job, please visit the API Endpoints page in the GitHub wiki.
For documentation on gRPC endpoints, including getting job details and requeuing a job, please visit the gRPC Endpoints page in the GitHub wiki.
For documentation on configuration and environment variables, please visit the Configuration page in the GitHub wiki.
For documentation on error handling in API endpoints and queue operations, please visit the Error Handling page in the GitHub wiki.
For deployment instructions, including Docker deployment, Kubernetes deployment, and CI/CD pipeline setup, please visit the Deployment Instructions page in the GitHub wiki.
For contributing guidelines, please visit the Contributing page in the GitHub wiki.
For license information, please visit the License page in the GitHub wiki.
For documentation on core features, including task scheduling, concurrency control, persistence, distributed execution, and fault tolerance, please visit the Core Features page in the GitHub wiki.
For documentation on new features, including job prioritization and delayed jobs, rate limiting and concurrency control, job retries and backoff strategies, job events and listeners, job progress tracking and completion callbacks, job data schema validation, job dependencies and flow control, and built-in metrics and monitoring tools, please visit the New Features page in the GitHub wiki.
For Docker instructions, including building the Docker image and running the Docker container, please visit the Docker Instructions page in the GitHub wiki.
A new GitHub Actions workflow has been added to sync the contents of the .github/wiki
directory to the GitHub Wiki repository on push. This workflow ensures that any changes made to the wiki files in the .github/wiki
directory are automatically reflected in the GitHub Wiki repository.
The purpose of this workflow is to automate the process of syncing the wiki files to the GitHub Wiki repository, ensuring that the documentation is always up-to-date.
The workflow triggers on push to the .github/wiki
directory. It includes the following steps:
- Checkout the main repository.
- Clone the GitHub Wiki repository.
- Copy files from the
.github/wiki
directory to the wiki repository. - Commit and push changes to the GitHub Wiki repository.
To trigger the workflow, simply push changes to the .github/wiki
directory. The workflow will automatically run and sync the changes to the GitHub Wiki repository.
To install the package from npm, use the following command:
npm install pop-queue
After installing the package from npm, you can use it in your project as follows:
const { PopQueue } = require('pop-queue');
const queue = new PopQueue('mongodb://localhost:27017', 'redis://localhost:6379', 'myDatabase', 'myCollection', 3);
queue.define('myJob', async (job) => {
console.log('Processing job:', job);
// Perform job processing logic here
return true;
});
queue.now({ data: 'jobData' }, 'myJob', 'jobIdentifier', Date.now());
queue.start();
Thank you for considering contributing to the pop-queue
project! We welcome contributions from the community to help improve and enhance the library. Please take a moment to review the following guidelines before getting started.
-
Fork the Repository: Start by forking the
pop-queue
repository to your GitHub account. -
Clone the Repository: Clone the forked repository to your local machine.
git clone https://github.com/your-username/pop-queue.git cd pop-queue
-
Create a Branch: Create a new branch for your contribution. Use a descriptive name for the branch to indicate the purpose of your changes.
git checkout -b my-feature-branch
-
Make Changes: Make your changes to the codebase. Ensure that your changes adhere to the project's coding standards and guidelines.
-
Write Tests: If applicable, write tests to cover your changes. Ensure that all existing tests pass.
-
Commit Changes: Commit your changes with a descriptive commit message.
git add . git commit -m "Add feature X"
-
Push Changes: Push your changes to your forked repository.
git push origin my-feature-branch
-
Create a Pull Request: Open a pull request (PR) on the original
pop-queue
repository. Provide a clear and concise description of your changes and the problem they solve.
We expect all contributors to adhere to the project's Code of Conduct. Please read and follow the Code of Conduct to ensure a positive and inclusive environment for everyone.
If you encounter any issues or bugs while using pop-queue
, please report them by opening an issue on the GitHub repository. Provide as much detail as possible to help us understand and resolve the issue.
We welcome feature requests and suggestions for improvements. If you have an idea for a new feature, please open an issue on the GitHub repository and provide a detailed description of the feature and its benefits.
If you have any questions or need further assistance, feel free to reach out to the project maintainers by opening an issue
Thank you for your contributions and support!
To track job progress and receive completion callbacks, use the progress
and completionCallback
methods:
queue.define('myJob', async (job) => {
console.log('Processing job:', job);
// Perform job processing logic here
queue.progress(job, 50); // Update job progress to 50%
// Perform more job processing logic here
queue.completionCallback(job, () => {
console.log('Job completed:', job);
});
return true;
});
For documentation on API endpoints, including getting job details, requeuing a job, registering and deregistering workers, redistributing jobs, enqueuing a job, starting the loop, failing a job, emitting events, registering event listeners, running a job, updating job progress, registering job completion callbacks, validating job data, checking job dependencies, fetching metrics, scheduling recurring jobs, handling job failures, notifying job events, and adding plugins, please visit the API Endpoints page in the GitHub wiki.