Skip to content

Commit 95effe6

Browse files
authored
Merge pull request #8 from noxify/updates
Updates
2 parents 5277995 + a2273e1 commit 95effe6

File tree

84 files changed

+3025
-1377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3025
-1377
lines changed

.changeset/core-changes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@vorsteh-queue/core": minor
3+
---
4+
5+
- Updated `BaseQueueAdapter` to use `setQueueName()` method
6+
- Updated `Queue` class to automatically set queue name on adapter
7+
- Updated `QueueAdapter` interface with optional `setQueueName()` method
8+
- Updated all core tests

.changeset/cruel-eggs-call.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
"@vorsteh-queue/adapter-prisma": minor
3+
---
4+
5+
Initial Prisma adapter release with UTC-first timezone support
6+
7+
**Features:**
8+
- `PostgresPrismaQueueAdapter`: PostgreSQL support using Prisma ORM
9+
- Raw SQL with `SKIP LOCKED` for race condition prevention
10+
- UTC-first design with proper timezone handling
11+
- Database schema uses UTC defaults: `timezone('utc', now())` for PostgreSQL
12+
- All timestamps explicitly stored as UTC for consistent behavior
13+
14+
**Usage:**
15+
16+
```typescript
17+
import { PrismaClient } from '@prisma/client'
18+
import { PostgresPrismaQueueAdapter } from '@vorsteh-queue/adapter-prisma'
19+
import { Queue } from '@vorsteh-queue/core'
20+
21+
const prisma = new PrismaClient()
22+
const adapter = new PostgresPrismaQueueAdapter(prisma)
23+
const queue = new Queue(adapter, { name: 'my-queue' })
24+
25+
// Register job handlers
26+
queue.register('send-email', async (payload: { to: string }) => {
27+
// Send email logic
28+
return { sent: true }
29+
})
30+
31+
// Add jobs
32+
await queue.add('send-email', { to: '[email protected]' })
33+
34+
// Start processing
35+
queue.start()
36+
```

.changeset/drizzle-changes.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
"@vorsteh-queue/drizzle-adapter": minor
3+
---
4+
5+
- `PostgresQueueAdapter`: Constructor simplified
6+
- **BREAKING**: Removed MariaDB/MySQL support due to timezone handling complexities
7+
- I tried my best to make it work, but failed successfully
8+
- **BREAKING**: Fixed UTC-first timezone handling - all timestamps now stored as UTC
9+
10+
**Before (duplicate queue name)**
11+
12+
```ts
13+
const adapter = new PostgresQueueAdapter(db, "my-queue")
14+
const queue = new Queue(adapter, { name: "my-queue" })
15+
```
16+
17+
**After (single queue name):**
18+
19+
```ts
20+
const adapter = new PostgresQueueAdapter(db)
21+
const queue = new Queue(adapter, { name: "my-queue" })
22+
```
23+
24+
**Timezone Changes:**
25+
26+
- Database schema now uses UTC defaults: `timezone('utc', now())` for PostgreSQL
27+
- Application timestamps stored as UTC using `toISOString()::timestamptz`
28+
- Consistent UTC-first behavior for reliable timezone handling

.github/workflows/ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- name: Setup
3838
uses: ./.github/setup
3939

40+
- name: Generate prisma client
41+
run: pnpm -F adapter-prisma prisma:generate
42+
4043
- name: Lint
4144
run: pnpm lint
4245

@@ -59,6 +62,9 @@ jobs:
5962
- name: Setup
6063
uses: ./.github/setup
6164

65+
- name: Generate prisma client
66+
run: pnpm -F adapter-prisma prisma:generate
67+
6268
- name: Typecheck
6369
run: pnpm typecheck
6470

@@ -86,16 +92,20 @@ jobs:
8692
run: pnpm install
8793

8894
- name: Build packages
89-
run: pnpm --filter "./packages/*" build
95+
run: |
96+
pnpm -F adapter-prisma prisma:generate
97+
pnpm --filter "./packages/*" build
9098
9199
- name: Test Core Package
92100
run: pnpm test:core
93101

94102
- name: Test Drizzle PostgreSQL (PGlite)
95103
run: pnpm test:drizzle-postgres
96104

97-
- name: Test Drizzle MariaDB (Testcontainers)
98-
run: pnpm test:drizzle-mariadb
105+
- name: Test Prisma (Testcontainers - Postgres)
106+
run: |
107+
pnpm -F adapter-prisma prisma:generate
108+
pnpm test:prisma-postgres
99109
env:
100110
# Ensure Docker is available for Testcontainers
101111
TESTCONTAINERS_RYUK_DISABLED: true
@@ -110,7 +120,10 @@ jobs:
110120
- name: Setup
111121
uses: ./.github/setup
112122

123+
- name: Generate prisma client
124+
run: pnpm -F adapter-prisma prisma:generate
125+
113126
- name: Build
114-
run: pnpm --filter "./packages/*" build
127+
run: pnpm build:pkg
115128

116129
- run: pnpx pkg-pr-new publish ./packages/*

README.md

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div align="center">
22
<img src="./assets/vorsteh-queue-logo-nobg.png" alt="Vorsteh Queue" height="200" />
33
<h1>Vorsteh Queue</h1>
4-
<p>A powerful, ORM-agnostic queue engine that works with any orm. Handle background jobs, scheduled tasks, and recurring processes with ease.</p>
4+
<p>A powerful, ORM-agnostic queue engine for PostgreSQL 12+. Handle background jobs, scheduled tasks, and recurring processes with ease.</p>
55
</div>
66

77
## Features
88

99
- **Type-safe**: Full TypeScript support with generic job payloads
10-
- **Multiple adapters**: Drizzle ORM (PostgreSQL + MariaDB/MySQL) and in-memory implementations
10+
- **Multiple adapters**: Drizzle ORM (PostgreSQL), Prisma ORM (PostgreSQL), and in-memory implementations
1111
- **Priority queues**: Numeric priority system (lower = higher priority)
1212
- **Delayed jobs**: Schedule jobs for future execution
1313
- **Recurring jobs**: Cron expressions and interval-based repetition
@@ -22,8 +22,8 @@
2222
.
2323
├── packages/
2424
│ ├── core/ # Core queue logic and interfaces
25-
│ ├── adapter-drizzle/ # Drizzle ORM adapter (PostgreSQL + MariaDB/MySQL)
26-
│ └── adapter-prisma/ # Prisma adapter (coming soon)
25+
│ ├── adapter-drizzle/ # Drizzle ORM adapter (PostgreSQL)
26+
│ └── adapter-prisma/ # Prisma ORM adapter (PostgreSQL)
2727
├── examples/ # Standalone usage examples
2828
│ ├── drizzle-pg/ # Drizzle + node-postgres
2929
│ ├── drizzle-postgres/ # Drizzle + postgres.js
@@ -53,40 +53,53 @@ pnpm add @vorsteh-queue/core @vorsteh-queue/adapter-drizzle
5353
### Basic Usage
5454

5555
```typescript
56-
// PostgreSQL
56+
// Drizzle ORM with PostgreSQL
5757
import { drizzle } from "drizzle-orm/node-postgres"
5858
import { Pool } from "pg"
5959
import { PostgresQueueAdapter } from "@vorsteh-queue/adapter-drizzle"
6060
import { Queue } from "@vorsteh-queue/core"
6161

62+
interface EmailPayload {
63+
to: string
64+
subject: string
65+
body: string
66+
}
67+
68+
interface EmailResult {
69+
messageId: string
70+
sent: boolean
71+
}
72+
6273
const pool = new Pool({ connectionString: "postgresql://..." })
6374
const db = drizzle(pool)
64-
const adapter = new PostgresQueueAdapter(db, "my-queue")
65-
const queue = new Queue(adapter, { name: "my-queue" })
66-
67-
// MariaDB/MySQL
68-
import { drizzle } from "drizzle-orm/mysql2"
69-
import mysql from "mysql2/promise"
70-
import { MariaDBQueueAdapter } from "@vorsteh-queue/adapter-drizzle"
71-
72-
const connection = await mysql.createConnection({
73-
host: "localhost",
74-
user: "root",
75-
password: "password",
76-
database: "queue_db",
77-
})
78-
const db = drizzle(connection, { mode: "default" })
79-
const adapter = new MariaDBQueueAdapter(db, "my-queue")
80-
const queue = new Queue(adapter, { name: "my-queue" })
75+
const queue = new Queue(new PostgresQueueAdapter(db), { name: "my-queue" })
76+
77+
// Prisma ORM with PostgreSQL
78+
import { PrismaClient } from "@prisma/client"
79+
import { PostgresPrismaQueueAdapter } from "@vorsteh-queue/adapter-prisma"
80+
81+
const prisma = new PrismaClient()
82+
const queue = new Queue(new PostgresPrismaQueueAdapter(prisma), { name: "my-queue" })
8183

8284
// Register job handlers
83-
queue.register("send-email", async (payload: { to: string; subject: string }) => {
84-
// Send email logic
85-
return { sent: true }
85+
queue.register<EmailPayload, EmailResult>("send-email", async (job) => {
86+
console.log(`Sending email to ${job.payload.to}`)
87+
88+
// Send email logic here
89+
await sendEmail(job.payload)
90+
91+
return {
92+
messageId: "msg_123",
93+
sent: true
94+
}
8695
})
8796

8897
// Add jobs
89-
await queue.add("send-email", { to: "[email protected]", subject: "Welcome!" })
98+
await queue.add("send-email", {
99+
100+
subject: "Welcome!",
101+
body: "Welcome to our service!"
102+
})
90103
await queue.add(
91104
"send-email",
92105
{ to: "[email protected]", subject: "Report" },

apps/docs/next.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ const nextConfig = {
3333
trailingSlash: true,
3434
poweredByHeader: false,
3535
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
36+
/** Enables hot reloading for local packages without a build step */
37+
transpilePackages: [
38+
"@vorsteh-queue/core",
39+
"@vorsteh-queue/adapter-drizzle",
40+
"@vorsteh-queue/adapter-prisma",
41+
"create-vorsteh-queue",
42+
],
3643
eslint: {
3744
ignoreDuringBuilds: true,
3845
},

apps/docs/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
"dependencies": {
2020
"@getcanary/web": "1.0.12",
2121
"@giscus/react": "3.1.0",
22+
"@icons-pack/react-simple-icons": "13.5.0",
2223
"@mdx-js/loader": "3.1.0",
2324
"@mdx-js/node-loader": "3.1.0",
2425
"@mdx-js/react": "3.1.0",
2526
"@next/mdx": "15.4.2",
27+
"@radix-ui/react-tabs": "1.1.12",
2628
"class-variance-authority": "0.7.1",
2729
"clsx": "2.1.1",
2830
"cmdk": "1.1.1",
@@ -39,14 +41,18 @@
3941
"remark-squeeze-paragraphs": "6.0.0",
4042
"remark-strip-badges": "7.0.0",
4143
"renoun": "8.14.0",
44+
"tm-themes": "1.10.7",
4245
"ts-morph": "26.0.0",
4346
"zod": "4.0.5"
4447
},
4548
"devDependencies": {
4649
"@tailwindcss/postcss": "4.1.11",
50+
"@types/mdx": "2.0.13",
4751
"@types/node": "22.16.5",
4852
"@types/react": "19.1.8",
4953
"@types/react-dom": "19.1.6",
54+
"@vorsteh-queue/adapter-drizzle": "workspace:*",
55+
"@vorsteh-queue/core": "workspace:*",
5056
"@vorsteh-queue/eslint-config": "workspace:*",
5157
"@vorsteh-queue/prettier-config": "workspace:*",
5258
"@vorsteh-queue/tsconfig": "workspace:*",

apps/docs/renoun.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"siteUrl": "https://vorsteh-queue.dev",
99

1010
"theme": {
11-
"dark": "github-dark-default",
12-
"light": "github-light-default"
11+
"dark": "monokai",
12+
"light": "monokai"
1313
},
1414
"languages": [
1515
"css",

0 commit comments

Comments
 (0)