/** * @license * Copyright 2023 Qlever LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type Moment } from 'moment'; import type { OADAClient } from '@oada/client'; import type { Json, JsonCompatible } from './index.js'; import { Job } from './Job.js'; import type { Service } from './Service.js'; export declare class JobError extends Error { 'JobError'?: string; constructor(m: string, t?: string); } /** * Manages a job and updates the associated job object as needed */ export declare class Runner { #private; /** * Create a Runner * @param service The service which the Runner is completing a job for * @param jobKey The key used in the lists of the Job * @param job The associated job * @param oada The OADAClient to use when runing the job */ constructor(service: Service, jobKey: string, job: Job, oada: OADAClient); /** * Runs the job's associated work function. This function is in charge of * detecting success failure and updating the Job object and event logs as * appropriate. */ run(): Promise; /** * Posts an update message to the Job's OADA object. * @param status The value of the current status * @param meta Arbitrary JSON serializeable meta data about update */ postUpdate(status: string, meta: Json): Promise; /** * Wrap up a job by finalizing the status, storing the result, and moving to * the correct event log. * @param status Final finish state of the job * @param result Arbitrary JSON serializeable result data * @param time Finish time of the job */ finish>(status: 'success' | 'failure', result: T, time: string | Moment, failType?: string): Promise; }