mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
[CORL-1002] Queue Improvements (#2931)
* fix: improved count handler for stories not found * feat: removed performance-now * feat: cleaned up processors, exposed counts * feat: increased verb of schd jobs * fix: removed dead code
This commit is contained in:
@@ -28,4 +28,5 @@ export const Query: Required<GQLQueryTypeResolver<void>> = {
|
||||
sites: (source, args, ctx) => ctx.loaders.Sites.connection(args),
|
||||
site: (source, { id }, ctx) => (id ? ctx.loaders.Sites.site.load(id) : null),
|
||||
webhookEndpoint: (source, { id }, ctx) => getWebhookEndpoint(ctx.tenant, id),
|
||||
queues: () => ({}),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import {
|
||||
GQLQueueCounts,
|
||||
GQLQueueTypeResolver,
|
||||
} from "../schema/__generated__/types";
|
||||
|
||||
export interface QueueInput {
|
||||
counts(): Promise<GQLQueueCounts>;
|
||||
}
|
||||
|
||||
export const Queue: Required<GQLQueueTypeResolver<QueueInput>> = {
|
||||
counts: t => t.counts(),
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
import { GQLQueuesTypeResolver } from "../schema/__generated__/types";
|
||||
|
||||
import GraphContext from "../context";
|
||||
import { QueueInput } from "./Queue";
|
||||
|
||||
/**
|
||||
* get produces a resolver that maps the context to a QueueInput.
|
||||
*
|
||||
* @param fn the function to map the ctx to the queue.
|
||||
*/
|
||||
const get = (fn: (ctx: GraphContext) => QueueInput) => (
|
||||
parent: any,
|
||||
args: any,
|
||||
ctx: GraphContext
|
||||
) => fn(ctx);
|
||||
|
||||
export const Queues: Required<GQLQueuesTypeResolver> = {
|
||||
mailer: get(ctx => ctx.mailerQueue),
|
||||
scraper: get(ctx => ctx.scraperQueue),
|
||||
notifier: get(ctx => ctx.notifierQueue),
|
||||
webhook: get(ctx => ctx.webhookQueue),
|
||||
rejector: get(ctx => ctx.rejectorQueue),
|
||||
};
|
||||
@@ -35,6 +35,8 @@ import { PremodStatus } from "./PremodStatus";
|
||||
import { PremodStatusHistory } from "./PremodStatusHistory";
|
||||
import { Profile } from "./Profile";
|
||||
import { Query } from "./Query";
|
||||
import { Queue } from "./Queue";
|
||||
import { Queues } from "./Queues";
|
||||
import { RecentCommentHistory } from "./RecentCommentHistory";
|
||||
import { RejectCommentPayload } from "./RejectCommentPayload";
|
||||
import { Secret } from "./Secret";
|
||||
@@ -99,6 +101,8 @@ const Resolvers: GQLResolver = {
|
||||
Tag,
|
||||
Time,
|
||||
User,
|
||||
Queue,
|
||||
Queues,
|
||||
UsernameHistory,
|
||||
UsernameStatus,
|
||||
UserStatus,
|
||||
|
||||
Reference in New Issue
Block a user