-
Notifications
You must be signed in to change notification settings - Fork 0
Docs/adding documentation #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5a61fc8
add doc files
arxja 470ae84
update root readme file
arxja 62e74cd
add contributing guide
arxja 6592748
chore: remove unused readmes
arxja 476ec93
chore: update root package json and pnpm version in ci
arxja 2f41324
Update docs/client.md
arxja 04640d7
fix: typo in contributing file
arxja 7a5f3e7
Merge branch 'docs/adding-documentation' of https://github.com/arxja/…
arxja 3d36a95
chore: update pnpm and node versions in docs
arxja 1507d20
chore: update lock file
arxja 52d1980
chore: allow bun build script
arxja bbd39fb
update root package.json scripts
arxja 6fa7779
fix: build time errors
arxja 8ff489e
fix: build time errors
arxja bc22698
fix: build time errors
arxja 0e31439
update the ci
arxja fe64cbd
fix: demo error
arxja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # Contributing to JetQueue | ||
|
|
||
| Thank you for your interest in contributing! | ||
| JetQueue is an open‑source project and we welcome all contributions. | ||
|
|
||
| ## Code of Conduct | ||
|
|
||
| This project follows the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). Please read it before participating. | ||
|
|
||
| ## How Can I Contribute? | ||
|
|
||
| ### Reporting Bugs | ||
|
|
||
| - Check the [existing issues](https://github.com/arxja/jet-queue/issues) first. | ||
| - Use the bug report template (if available) or include: | ||
| - JetQueue version | ||
| - Runtime (Node.js / Bun) and version | ||
| - Clear description of the problem | ||
| - Steps to reproduce | ||
| - Expected vs actual behavior | ||
| - Any relevant error logs | ||
|
|
||
| ### Suggesting Features | ||
|
|
||
| - Open an issue with the label `enhancement`. | ||
| - Describe the use‑case and why it would be valuable. | ||
| - If you’re willing to implement it, mention that! | ||
|
|
||
| ### Pull Requests | ||
|
|
||
| 1. Fork the repository and create your branch from `main`. | ||
| 2. If you added code, please add tests. | ||
| 3. Ensure the test suite passes (`bun test`). | ||
| 4. Make sure your code passes type checking (`bun run --bun tsc --noEmit`). | ||
| 5. Follow the existing code style. | ||
| 6. Write a clear commit message (see below). | ||
| 7. Open a pull request against the `main` branch. | ||
|
|
||
| ## Development Setup | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - [Bun](https://bun.sh) (latest) | ||
| - [Node.js](https://nodejs.org) 20+ (for testing Node compatibility) | ||
| - [pnpm](https://pnpm.io) 8+ | ||
|
|
||
| ### Setup | ||
|
|
||
| ```bash | ||
| git clone https://github.com/arxja/jet-queue.git | ||
| cd jet-queue | ||
| pnpm install | ||
| ``` | ||
|
|
||
| ### Running Tests | ||
|
|
||
| ``` | ||
|
arxja marked this conversation as resolved.
Outdated
|
||
| bun test | ||
| ``` | ||
|
|
||
| ### Building | ||
|
|
||
| ```bash | ||
| pnpm build | ||
| ``` | ||
|
|
||
| ### Running the Demo | ||
|
|
||
| ```bash | ||
| # Terminal 1 (Bun) | ||
| cd examples/split-screen-demo | ||
| bun run server.ts | ||
|
|
||
| # Terminal 2 (Next.js) | ||
| cd examples/split-screen-demo | ||
| npm run dev | ||
| ``` | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ```text | ||
| jet-queue/ | ||
| ├── packages/ | ||
| │ ├── core/ # @jet-queue/core (engine) | ||
| │ ├── server/ # @jet-queue/server (Bun server) | ||
| │ ├── client/ # @jet-queue/client (SDK) | ||
| │ ├── cli/ # @jet-queue/cli (terminal dashboard) | ||
| │ └── dashboard/ # @jet-queue/dashboard (web UI) | ||
| ├── examples/ | ||
| ├── docs/ | ||
| └── scripts/ | ||
| ``` | ||
|
|
||
| ## Commit Message Guidelines | ||
|
|
||
| We use [Conventional Commits](https://conventionalcommits.org): | ||
|
|
||
| - `feat: add retry backoff strategy` | ||
| - `fix: handle job timeout correctly` | ||
| - `docs: update server API reference` | ||
| - `test: add coverage for priority queue` | ||
| - `chore: update dependencies` | ||
|
|
||
| ## Style Guide | ||
|
|
||
| - TypeScript strict mode | ||
| - Use `async/await` over raw promises | ||
| - Explicit function return types for public API | ||
| - Single responsibility per file | ||
| - Keep core package zero‑dependencies | ||
|
|
||
| ## License | ||
|
|
||
| By contributing, you agree that your contributions will be licensed under the MIT License. | ||
|
|
||
| --- | ||
|
|
||
| <br/> | ||
| <p align="center">Thank you for helping make JetQueue better!</p> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # JetQueue Architecture | ||
|
|
||
| ## Packages | ||
|
|
||
| - `@jet-queue/core` – engine (events, retries, storage) | ||
| - `@jet-queue/server` – Bun server (REST + WebSocket) | ||
| - `@jet-queue/client` – SDK for any environment | ||
| - `@jet-queue/cli` – terminal dashboard | ||
| - `@jet-queue/dashboard` – web dashboard (Next.js) | ||
|
|
||
| ## Data Flow | ||
|
|
||
| ```text | ||
| App → client.addJob() → HTTP POST /api/jobs → server → queue.add() → process | ||
| App ← client.onJobCompleted() ← WebSocket ← server ← queue.emit('job:completed') | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # @jet-queue/client SDK | ||
|
|
||
| ## Installation | ||
| ```bash | ||
| npm install @jet-queue/client | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```ts | ||
| import { JetQueueClient } from '@jet-queue/client'; | ||
| const client = new JetQueueClient({ baseUrl: 'http://localhost:3001' }); | ||
|
|
||
| // Add a job | ||
| const job = await client.addJob('send-email', { data: { to: 'user@test.com' } }); | ||
|
|
||
| // Check status | ||
| const status = await client.getJob(job.id); | ||
|
|
||
| // Real‑time events | ||
| client.connect(); | ||
| client.onJobCompleted(job.id, (job) => console.log('Done!', job.result)); | ||
| ``` | ||
|
|
||
| ## Methods | ||
| `addJob(handler, options?)`, `getJob(id)`, `getJobProgress(id)`, `cancelJob(id)`, `retryJob(id)`,` getStats()`, `health()`, `connect()`, `disconnect()`,` onJobCompleted(id, cb)`, `onJobFailed(id, cb)`, `onJobProgress(id, cb)`, `onEvent(type, cb)`. | ||
|
arxja marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # @jet-queue/core API | ||
|
|
||
| ## `new JetQueue(options?)` | ||
|
|
||
| | Option | Type | Default | Description | | ||
| | ----------------- | ------- | -------- | ---------------------------- | | ||
| | concurrency | number | 5 | Max simultaneous jobs | | ||
| | autoStart | boolean | true | Start processing immediately | | ||
| | maxQueuedJobs | number | Infinity | Max pending jobs | | ||
| | defaultJobOptions | object | {} | Default options for all jobs | | ||
|
|
||
| ## `queue.add(taskFn, options?)` | ||
|
|
||
| Returns job ID. | ||
|
|
||
| ```ts | ||
| queue.add( | ||
| async (job) => { | ||
| /* work */ | ||
| }, | ||
| { | ||
| name: "send-email", | ||
| priority: "high", // low | normal | high | critical | ||
| timeout: 30000, | ||
| maxAttempts: 3, | ||
| retryOptions: { strategy: "exponential", delay: 1000 }, | ||
| delay: 5000, // delay before first run | ||
| tags: ["email"], | ||
| }, | ||
| ); | ||
| ``` | ||
|
|
||
| ## Events | ||
|
|
||
| ```ts | ||
| queue.on("job:added", ({ job }) => {}); | ||
| queue.on("job:completed", ({ job, result, duration }) => {}); | ||
| queue.on("job:failed", ({ job, error, duration }) => {}); | ||
| queue.on("job:progress", ({ job, progress }) => {}); | ||
| queue.on("queue:drain", ({ stats }) => {}); | ||
| ``` | ||
| ## Storage | ||
|
|
||
| ```ts | ||
| import { MemoryStorage, SQLiteStorage } from '@jet-queue/core'; | ||
| new JetQueue({}, new MemoryStorage()); // volatile | ||
| new JetQueue({}, new SQLiteStorage('./queue.db')); // persistent | ||
| ``` | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Getting Started with JetQueue | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @jet-queue/core | ||
| ``` | ||
|
|
||
| ## Your First Queue | ||
|
|
||
| ```ts | ||
| import { JetQueue } from "@jet-queue/core"; | ||
|
|
||
| const queue = new JetQueue({ concurrency: 3 }); | ||
|
|
||
| queue.add( | ||
| async () => { | ||
| console.log("Job done!"); | ||
| }, | ||
| { name: "my-first-job" }, | ||
| ); | ||
|
|
||
| queue.on("queue:drain", () => { | ||
| console.log("All jobs finished"); | ||
| }); | ||
| ``` | ||
|
|
||
| ## Using the Server (Bun) | ||
|
|
||
| ```bash | ||
| npx @jet-queue/server --port 3001 | ||
| ``` | ||
|
|
||
| Then connect with the client: | ||
|
|
||
| ```bash | ||
| npm install @jet-queue/client | ||
| ``` | ||
|
|
||
| ```ts | ||
| import { JetQueueClient } from "@jet-queue/client"; | ||
| const client = new JetQueueClient({ baseUrl: "http://localhost:3001" }); | ||
| await client.addJob("send-email", { data: { to: "user@test.com" } }); | ||
| ``` | ||
|
|
||
| ## Next Steps | ||
| - [Core API](./core.md) | ||
| - [Server API](./server.md) | ||
| - [Client SDK](./client.md) | ||
| - [Architecture](./architecture.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # @jet-queue/server API | ||
|
|
||
| The server package provides a ready‑to‑run Bun server and building blocks for custom servers. | ||
|
|
||
| ## Quick Start (standalone) | ||
| ```bash | ||
| bun run @jet-queue/server | ||
| # or programmatically: | ||
| import { initQueue, createApp } from '@jet-queue/server'; | ||
| const queue = await initQueue({ concurrency: 3 }); | ||
| queue.registerHandler('email', async (job) => { … }); | ||
| const app = createApp(); | ||
| Bun.serve({ fetch: app.fetch, port: 3001, websocket: { … } }); | ||
| ``` | ||
|
|
||
| ## REST Endpoints | ||
|
|
||
| | Method | Path | Description | | ||
| |---|---|---| | ||
| | **POST** | `/api/jobs` | Add a job | | ||
| | **GET** | `/api/jobs/:id` | Job details | | ||
| | **DELETE** | `/api/jobs/:id` | Cancel job | | ||
| | **POST** | `/api/jobs/:id/retry` | Retry failed job | | ||
| | **GET** | `/api/queues/stats` | Queue statistics | | ||
| | **GET** | `/api/health` | Health check | | ||
| | **WS** | `/ws` | Real-time events | |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.