Skip to content

Commit 208a85a

Browse files
committed
Restructure README for better user experience
- Move Quick Start section to top - Position Demo after Quick Start - Move Why JobGuard section after Features - Update Table of Contents - Update badges format
1 parent ec2a52c commit 208a85a

File tree

1 file changed

+77
-83
lines changed

1 file changed

+77
-83
lines changed

README.md

Lines changed: 77 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,73 @@
11
# JobGuard
22

3-
[![npm version](https://img.shields.io/npm/v/jobguard.svg)](https://www.npmjs.com/package/jobguard)
4-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5-
[![TypeScript](https://img.shields.io/badge/TypeScript-5.6-blue.svg)](https://www.typescriptlang.org/)
6-
[![Node.js](https://img.shields.io/badge/Node.js-22+-green.svg)](https://nodejs.org/)
3+
[![npm](https://img.shields.io/npm/v/jobguard?logo=npm)](https://www.npmjs.com/package/jobguard)
4+
[![node](https://img.shields.io/node/v/jobguard)](https://nodejs.org/)
5+
[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?logo=typescript)](https://www.typescriptlang.org/)
6+
[![CI](https://github.com/alexpota/jobguard/workflows/CI/badge.svg)](https://github.com/alexpota/jobguard/actions)
7+
[![coverage](https://img.shields.io/badge/coverage-85%25-brightgreen)](https://github.com/alexpota/jobguard)
8+
[![License](https://img.shields.io/npm/l/jobguard)](https://opensource.org/licenses/MIT)
9+
[![downloads](https://img.shields.io/npm/dm/jobguard)](https://www.npmjs.com/package/jobguard)
710

811
PostgreSQL durability for Redis-backed job queues (Bull, BullMQ, Bee-Queue) with minimal integration.
912

13+
## Quick Start
14+
15+
### Installation
16+
17+
```bash
18+
npm install jobguard pg
19+
```
20+
21+
### Basic Usage
22+
23+
```typescript
24+
import Bull from 'bull';
25+
import { JobGuard } from 'jobguard';
26+
27+
// Create your queue as usual
28+
const queue = new Bull('my-queue', 'redis://localhost:6379');
29+
30+
// Add JobGuard for durability
31+
const jobGuard = await JobGuard.create(queue, {
32+
postgres: 'postgresql://localhost:5432/mydb',
33+
});
34+
35+
// Use your queue normally - JobGuard works transparently
36+
await queue.add('email', { to: 'user@example.com' });
37+
38+
// Gracefully shutdown when done
39+
process.on('SIGTERM', async () => {
40+
await jobGuard.shutdown();
41+
await queue.close();
42+
});
43+
```
44+
45+
## 🎬 Demo
46+
47+
![JobGuard Stress Test](./assets/demo.gif)
48+
49+
**10,000 jobs • 60 workers • Redis crash at peak load • Zero jobs lost**
50+
51+
[▶️ Run the interactive demo yourself →](./demo#readme)
52+
53+
## Features
54+
55+
- 🔒 **Drop-In Integration**: Wraps existing queues without modifying your queue code
56+
- 🔄 **Automatic Recovery**: Client-side reconciliation detects and recovers stuck jobs
57+
- 💓 **Heartbeat Support**: Long-running jobs signal liveness for accurate stuck detection
58+
- 📊 **Multi-Queue Support**: Works with Bull, BullMQ, and Bee-Queue
59+
-**Low Overhead**: <5ms per job operation, minimal memory footprint
60+
- 🛡️ **Fault Tolerant**: Circuit breaker pattern protects against PostgreSQL failures
61+
- 🎯 **Type Safe**: Full TypeScript support with strict typing
62+
1063
## Table of Contents
1164

12-
- [Why JobGuard?](#why-jobguard)
65+
- [Quick Start](#quick-start)
1366
- [Demo](#-demo)
1467
- [Features](#features)
15-
- [Installation](#installation)
16-
- [Quick Start](#quick-start)
17-
- [Configuration](#configuration)
68+
- [Why JobGuard?](#why-jobguard)
1869
- [Database Setup](#database-setup)
70+
- [Configuration](#configuration)
1971
- [Advanced Usage](#advanced-usage)
2072
- [API Reference](#api-reference)
2173
- [Queue Library Support](#queue-library-support)
@@ -76,63 +128,34 @@ const jobGuard = await JobGuard.create(queue, {
76128

77129
[▶️ Run the interactive stress test yourself](./demo#readme)
78130

79-
### Choose JobGuard If You:
80-
81-
- ✅ Already use Bull/BullMQ/Bee-Queue and want to keep Redis performance
82-
- ✅ Need 100% durability without rewriting existing queue code
83-
- ✅ Want automatic recovery from Redis crashes
84-
- ✅ Need to support multiple queue libraries in one codebase
85-
- ✅ Want minimal integration effort (3 lines of code)
86-
87-
## 🎬 Demo
88-
89-
![JobGuard Stress Test](./assets/demo.gif)
90-
91-
**10,000 jobs • 60 workers • Redis crash at peak load • Zero jobs lost**
92-
93-
[▶️ Run the interactive demo yourself →](./demo#readme)
94-
95-
## Features
96-
97-
- 🔒 **Drop-In Integration**: Wraps existing queues without modifying your queue code
98-
- 🔄 **Automatic Recovery**: Client-side reconciliation detects and recovers stuck jobs
99-
- 💓 **Heartbeat Support**: Long-running jobs signal liveness for accurate stuck detection
100-
- 📊 **Multi-Queue Support**: Works with Bull, BullMQ, and Bee-Queue
101-
-**Low Overhead**: <5ms per job operation, minimal memory footprint
102-
- 🛡️ **Fault Tolerant**: Circuit breaker pattern protects against PostgreSQL failures
103-
- 🎯 **Type Safe**: Full TypeScript support with strict typing
131+
## Database Setup
104132

105-
## Quick Start
133+
**One-time setup:** Create the JobGuard table in your PostgreSQL database.
106134

107-
### Installation
135+
### Option 1: Using psql (Recommended)
108136

109137
```bash
110-
npm install jobguard pg
138+
psql -d mydb -f node_modules/jobguard/schema/001_initial.sql
111139
```
112140

113-
### Basic Usage
141+
### Option 2: Programmatically
114142

115143
```typescript
116-
import Bull from 'bull';
117-
import { JobGuard } from 'jobguard';
118-
119-
// Create your queue as usual
120-
const queue = new Bull('my-queue', 'redis://localhost:6379');
144+
import { Pool } from 'pg';
145+
import { readFileSync } from 'fs';
146+
import { join } from 'path';
121147

122-
// Add JobGuard for durability
123-
const jobGuard = await JobGuard.create(queue, {
124-
postgres: 'postgresql://localhost:5432/mydb',
125-
});
148+
const pool = new Pool({ connectionString: 'postgresql://localhost:5432/mydb' });
149+
const schema = readFileSync(
150+
join(__dirname, 'node_modules/jobguard/schema/001_initial.sql'),
151+
'utf8'
152+
);
153+
await pool.query(schema);
154+
```
126155

127-
// Use your queue normally - JobGuard works transparently
128-
await queue.add('email', { to: 'user@example.com' });
156+
### Option 3: Add to Your Existing Migrations
129157

130-
// Gracefully shutdown when done
131-
process.on('SIGTERM', async () => {
132-
await jobGuard.shutdown();
133-
await queue.close();
134-
});
135-
```
158+
Copy `node_modules/jobguard/schema/001_initial.sql` into your project's migration system (Knex, TypeORM, Prisma, etc.).
136159

137160
## Configuration
138161

@@ -181,35 +204,6 @@ const jobGuard = await JobGuard.create(queue, {
181204
});
182205
```
183206

184-
## Database Setup
185-
186-
**One-time setup:** Create the JobGuard table in your PostgreSQL database.
187-
188-
### Option 1: Using psql (Recommended)
189-
190-
```bash
191-
psql -d mydb -f node_modules/jobguard/schema/001_initial.sql
192-
```
193-
194-
### Option 2: Programmatically
195-
196-
```typescript
197-
import { Pool } from 'pg';
198-
import { readFileSync } from 'fs';
199-
import { join } from 'path';
200-
201-
const pool = new Pool({ connectionString: 'postgresql://localhost:5432/mydb' });
202-
const schema = readFileSync(
203-
join(__dirname, 'node_modules/jobguard/schema/001_initial.sql'),
204-
'utf8'
205-
);
206-
await pool.query(schema);
207-
```
208-
209-
### Option 3: Add to Your Existing Migrations
210-
211-
Copy `node_modules/jobguard/schema/001_initial.sql` into your project's migration system (Knex, TypeORM, Prisma, etc.).
212-
213207
## Advanced Usage
214208

215209
### Force Reconciliation

0 commit comments

Comments
 (0)