@convex-dev/workpool
Version:
A Convex component for managing async work.
45 lines • 1.84 kB
TypeScript
import { Doc, Id } from "./_generated/dataModel.js";
import { MutationCtx } from "./_generated/server.js";
import { Config } from "./shared.js";
import { Logger } from "./logging.js";
/**
* Record stats about work execution. Intended to be queried by Axiom or Datadog.
* See the [README](https://github.com/get-convex/workpool) for example queries.
*/
export declare function recordEnqueued(console: Logger, data: {
workId: Id<"work">;
fnName: string;
runAt: number;
}): void;
export declare function recordStarted(console: Logger, work: Doc<"work">, lagMs: number): void;
export declare function recordCompleted(console: Logger, work: Doc<"work">, status: "success" | "failed" | "canceled" | "retrying"): void;
export declare function generateReport(ctx: MutationCtx, console: Logger, state: Doc<"internalState">, { maxParallelism, logLevel }: Config): Promise<void>;
export declare const calculateBacklogAndReport: import("convex/server").RegisteredMutation<"internal", {
report: {
failed: number;
canceled: number;
completed: number;
succeeded: number;
retries: number;
lastReportTs: number;
};
logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
running: number;
cursor: string;
startSegment: bigint;
endSegment: bigint;
}, Promise<void>>;
/**
* Warning: this should not be used from a mutation, as it will cause conflicts.
* Use this while developing to see the state of the queue.
*/
export declare const diagnostics: import("convex/server").RegisteredQuery<"internal", {}, Promise<{
canceling: any;
waiting: any;
running: number;
completing: any;
spareCapacity: number;
runStatus: "running" | "scheduled" | "idle" | undefined;
generation: bigint | undefined;
}>>;
//# sourceMappingURL=stats.d.ts.map