feat: migrate from Redis to SQLite for event handling and notifications

This commit is contained in:
Arunavo Ray
2025-05-20 19:09:48 +05:30
parent c179953649
commit 6d13ff29ca
17 changed files with 470 additions and 202 deletions

View File

@@ -1,7 +1,7 @@
import type { RepoStatus } from "@/types/Repository";
import { db, mirrorJobs } from "./db";
import { v4 as uuidv4 } from "uuid";
import { redisPublisher } from "./redis";
import { publishEvent } from "./events";
export async function createMirrorJob({
userId,
@@ -40,10 +40,16 @@ export async function createMirrorJob({
};
try {
// Insert the job into the database
await db.insert(mirrorJobs).values(job);
// Publish the event using SQLite instead of Redis
const channel = `mirror-status:${userId}`;
await redisPublisher.publish(channel, JSON.stringify(job));
await publishEvent({
userId,
channel,
payload: job
});
return jobId;
} catch (error) {