Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
feat: note専用ワーカーを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Sep 29, 2023
1 parent 99d4858 commit f47a1c0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"build-gulp": "gulp build",
"export": "pnpm build-ts && node ./built/migration/migrateAyuskeyNext.js",
"worker": "node ./built/migration/worker.js",
"note-worker": "node ./built/migration/noteWorker.js",
"bull-board": "node ./built/migration/bullDashboard.js",
"next": "node ./built/migration/migrateAyuskeyNext.js",
"clean-com": "node ./built/migration/clean-complete.js",
Expand Down
2 changes: 1 addition & 1 deletion src/migration/jobqueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const queueRedisConf: Queue.QueueOptions = {
},
prefix: "ayuskey_next",
limiter: {
max: 50,
max: 150,
duration: 1000,
},
};
Expand Down
35 changes: 35 additions & 0 deletions src/migration/noteWorker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { initDb } from "@/db/postgre";
import { logger } from "./common";
import {
noteQueue,
} from "./jobqueue";
import noteProcessor from "./processor/note.processor";
import { createConnection } from "typeorm";
import config from "@/config";
import { AyuskeyNextEntities } from "@/v13/models";

async function main() {
await initDb();
await createConnection({
name: "nextDb",
type: "postgres",
host: config.db.nextDb.host,
port: config.db.nextDb.port,
username: config.db.nextDb.user,
password: config.db.nextDb.pass,
database: config.db.nextDb.db,
entities: AyuskeyNextEntities,
});

noteQueue.process(noteProcessor);


noteQueue.on("completed", (job) => {
logger.succ(`Note: ${job.data.id} の処理が完了しました`);
});

}
main().catch((e) => {
console.warn(e);
process.exit(1);
});

0 comments on commit f47a1c0

Please sign in to comment.