add suspended flows to cli queues

This commit is contained in:
Ruben Fiszel
2024-09-26 16:52:09 +02:00
parent 5a191d83ca
commit 048625404d
5 changed files with 20 additions and 4 deletions
+2
View File
@@ -9987,6 +9987,8 @@ components:
type: number
aggregate_wait_time_ms:
type: number
suspend:
type: number
required:
- id
- running
+1 -1
View File
@@ -1258,7 +1258,7 @@ pub fn list_queue_jobs_query(
join_outstanding_wait_times: bool,
tags: Option<Vec<&str>>,
) -> SqlBuilder {
let (limit, offset) = paginate(pagination);
let (limit, offset) = paginate_without_limits(pagination);
let mut sqlb = SqlBuilder::select_from("queue")
.fields(fields)
.order_by("created_at", lq.order_desc.unwrap_or(true))
+6
View File
@@ -82,6 +82,12 @@ pub fn paginate(pagination: Pagination) -> (usize, usize) {
(per_page, offset)
}
pub fn paginate_without_limits(pagination: Pagination) -> (usize, usize) {
let per_page = pagination.per_page.unwrap_or(MAX_PER_PAGE);
let offset = (pagination.page.unwrap_or(1).max(1) - 1) * per_page;
(per_page, offset)
}
pub async fn now_from_db<'c, E: sqlx::PgExecutor<'c>>(
db: E,
) -> Result<chrono::DateTime<chrono::Utc>> {
+1
View File
@@ -160,6 +160,7 @@ export type QueuedJob = {
priority?: number;
self_wait_time_ms?: number;
aggregate_wait_time_ms?: number;
suspend?: number;
};
export type job_kind = 'script' | 'preview' | 'dependencies' | 'flowdependencies' | 'appdependencies' | 'flow' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlescriptflow';
+10 -3
View File
@@ -6,6 +6,7 @@ import { pickInstance } from "./instance.ts";
type Data = {
count: number;
later: number;
suspended: number;
waiting: number;
running: number;
rps30s: string;
@@ -29,6 +30,7 @@ function createRow(tag: string, data: Record<string, Data>) {
waiting: 0,
later: 0,
running: 0,
suspended: 0,
rps30s: "",
rps5min: "",
rps30min: "",
@@ -40,7 +42,7 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
const activeInstance = await pickInstance(opts, true);
if (activeInstance) {
try {
const queuedJobs = await wmill.listQueue({workspace: workspace ?? 'admins', allWorkspaces: workspace === undefined});
const queuedJobs = await wmill.listQueue({workspace: workspace ?? 'admins', allWorkspaces: workspace === undefined, perPage: 100000});
const jobCounts30s = await wmill.countJobsByTag({
horizonSecs: 30,
workspaceId: workspace,
@@ -68,7 +70,11 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
createRow(job.tag, data);
const scheduledFor = new Date(job.scheduled_for ?? "");
if (job.running) {
data[job.tag].running += 1;
if (job.suspend) {
data[job.tag].suspended += 1;
} else {
data[job.tag].running += 1;
}
} else if (scheduledFor <= nowFromDb) {
data[job.tag].waiting += 1;
} else {
@@ -104,6 +110,7 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
"Running",
"Waiting",
"Later",
"Suspended",
"RPS (30s)",
"RPS (5min)",
"RPS (30min)",
@@ -111,7 +118,7 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
]);
let body = []
for (const tag in data) {
body.push([tag, data[tag].running, data[tag].waiting, data[tag].later, data[tag].rps30s, data[tag].rps5min, data[tag].rps30min, data[tag].rps24h]);
body.push([tag, data[tag].running, data[tag].waiting, data[tag].later, data[tag].suspended, data[tag].rps30s, data[tag].rps5min, data[tag].rps30min, data[tag].rps24h]);
}
table.body(body).render();