49 lines · 1.3 KB · TypeScript
RawDownload
import { logger } from "../../lib/logger";import { getBillingQueue } from "../queue-service";import { v4 as uuidv4 } from "uuid";import * as Sentry from "@sentry/node"; /** * Adds a job to the billing queue to trigger batch processing * This can be used when we want to ensure billing is processed without waiting for the next interval */export async function addBillingBatchJob() {  try {    const jobId = uuidv4();    logger.info("Adding billing batch job to queue", { jobId });     await getBillingQueue().add(      "process-batch",      {        timestamp: new Date().toISOString(),      },      {        jobId,        priority: 10,      },    );     return { success: true, jobId };  } catch (error) {    logger.error("Error adding billing batch job", { error });    Sentry.captureException(error, {      data: {        operation: "add_billing_batch_job",      },    });    return { success: false, error };  }} /** * Trigger immediate processing of any pending billing operations * This is useful for ensuring billing operations are processed without delay */export async function triggerImmediateBillingProcess() {  try {    return await addBillingBatchJob();  } catch (error) {    logger.error("Error triggering immediate billing process", { error });    return { success: false, error };  }}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t