[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:
Wyatt Johnson
2020-04-10 16:15:09 +00:00
committed by GitHub
parent 98e6a3ccc7
commit 4194b08a12
33 changed files with 353 additions and 332 deletions
+1
View File
@@ -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: () => ({}),
};
+12
View File
@@ -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(),
};
+23
View File
@@ -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),
};
+4
View File
@@ -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,