mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:10:43 +00:00
refactor(cron): share execution id helper
This commit is contained in:
3
src/cron/run-id.ts
Normal file
3
src/cron/run-id.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function createCronExecutionId(jobId: string, startedAt: number): string {
|
||||
return `cron:${jobId}:${startedAt}`;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
createRunningTaskRun,
|
||||
failTaskRunByRunId,
|
||||
} from "../../tasks/detached-task-runtime.js";
|
||||
import { createCronExecutionId } from "../run-id.js";
|
||||
import type { CronJob, CronJobCreate, CronJobPatch } from "../types.js";
|
||||
import {
|
||||
applyJobPatch,
|
||||
@@ -394,10 +395,6 @@ type ManualRunPreflightResult =
|
||||
|
||||
let nextManualRunId = 1;
|
||||
|
||||
function createCronTaskRunId(jobId: string, startedAt: number): string {
|
||||
return `cron:${jobId}:${startedAt}`;
|
||||
}
|
||||
|
||||
async function skipInvalidPersistedManualRun(params: {
|
||||
state: CronServiceState;
|
||||
job: CronJob;
|
||||
@@ -445,7 +442,7 @@ function tryCreateManualTaskRun(params: {
|
||||
job: CronJob;
|
||||
startedAt: number;
|
||||
}): string | undefined {
|
||||
const runId = createCronTaskRunId(params.job.id, params.startedAt);
|
||||
const runId = createCronExecutionId(params.job.id, params.startedAt);
|
||||
try {
|
||||
createRunningTaskRun({
|
||||
runtime: "cron",
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "../../tasks/detached-task-runtime.js";
|
||||
import { clearCronJobActive, markCronJobActive } from "../active-jobs.js";
|
||||
import { resolveCronDeliveryPlan } from "../delivery-plan.js";
|
||||
import { createCronExecutionId } from "../run-id.js";
|
||||
import { sweepCronRunSessions } from "../session-reaper.js";
|
||||
import type {
|
||||
CronDeliveryStatus,
|
||||
@@ -130,16 +131,12 @@ export function normalizeCronRunErrorText(err: unknown): string {
|
||||
return String(err);
|
||||
}
|
||||
|
||||
function createCronTaskRunId(jobId: string, startedAt: number): string {
|
||||
return `cron:${jobId}:${startedAt}`;
|
||||
}
|
||||
|
||||
function tryCreateCronTaskRun(params: {
|
||||
state: CronServiceState;
|
||||
job: CronJob;
|
||||
startedAt: number;
|
||||
}): string | undefined {
|
||||
const runId = createCronTaskRunId(params.job.id, params.startedAt);
|
||||
const runId = createCronExecutionId(params.job.id, params.startedAt);
|
||||
try {
|
||||
createRunningTaskRun({
|
||||
runtime: "cron",
|
||||
|
||||
Reference in New Issue
Block a user