INNER CODE UNIT · TypeScript

refreshGaugeCaches

jonwiggins/optio · apps/api/src/index.ts:139

  async function refreshGaugeCaches() {
    try {
      const rows = await db
        .select({ state: tasksTable.state, count: sqlFn<number>`count(*)` })
        .from(tasksTable)
        .where(sqlFn`${tasksTable.state} IN ('queued', 'provisioning', 'running')`)
        .groupBy(tasksTable.state);
      cachedQueueDepth = {};
      cachedActiveTasks = 0;
      for (const row of rows) {
        cachedQueueDepth[row.state] = Number(row.count);
        if (row.state === "running" || row.state === "provisioning") {
          cachedActiveTasks += Number(row.count);
        }
      }
    } catch {
      /* non-fatal */
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…