mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
feat: ✨ Split off queue workers into a separate worker process
This commit is contained in:
parent
0b3e74107e
commit
1b98381242
34 changed files with 987 additions and 676 deletions
20
classes/queues/delivery.ts
Normal file
20
classes/queues/delivery.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { Queue } from "bullmq";
|
||||
import type { KnownEntity } from "~/types/api";
|
||||
import { connection } from "~/utils/redis.ts";
|
||||
|
||||
export enum DeliveryJobType {
|
||||
FederateEntity = "federateEntity",
|
||||
}
|
||||
|
||||
export type DeliveryJobData = {
|
||||
entity: KnownEntity;
|
||||
recipientId: string;
|
||||
senderId: string;
|
||||
};
|
||||
|
||||
export const deliveryQueue = new Queue<DeliveryJobData, void, DeliveryJobType>(
|
||||
"delivery",
|
||||
{
|
||||
connection,
|
||||
},
|
||||
);
|
||||
17
classes/queues/fetch.ts
Normal file
17
classes/queues/fetch.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { Queue } from "bullmq";
|
||||
import { connection } from "~/utils/redis.ts";
|
||||
|
||||
export enum FetchJobType {
|
||||
Instance = "instance",
|
||||
User = "user",
|
||||
Note = "user",
|
||||
}
|
||||
|
||||
export type FetchJobData = {
|
||||
uri: string;
|
||||
refetcher?: string;
|
||||
};
|
||||
|
||||
export const fetchQueue = new Queue<FetchJobData, void, FetchJobType>("fetch", {
|
||||
connection,
|
||||
});
|
||||
31
classes/queues/inbox.ts
Normal file
31
classes/queues/inbox.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import type { Entity } from "@versia/federation/types";
|
||||
import { Queue } from "bullmq";
|
||||
import type { SocketAddress } from "bun";
|
||||
import { connection } from "~/utils/redis.ts";
|
||||
|
||||
export enum InboxJobType {
|
||||
ProcessEntity = "processEntity",
|
||||
}
|
||||
|
||||
export type InboxJobData = {
|
||||
data: Entity;
|
||||
headers: {
|
||||
"x-signature"?: string;
|
||||
"x-nonce"?: string;
|
||||
"x-signed-by"?: string;
|
||||
authorization?: string;
|
||||
};
|
||||
request: {
|
||||
url: string;
|
||||
method: string;
|
||||
body: string;
|
||||
};
|
||||
ip: SocketAddress | null;
|
||||
};
|
||||
|
||||
export const inboxQueue = new Queue<InboxJobData, Response, InboxJobType>(
|
||||
"inbox",
|
||||
{
|
||||
connection,
|
||||
},
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue