import * as pb from "../proto/orchestrator_service_pb"; import { CompletableTask } from "./completable-task"; /** * Represents the type of retryable task - activity or sub-orchestration. */ export type RetryTaskType = "activity" | "subOrchestration"; /** * Abstract base class for tasks that support retry behavior. * * @remarks * This class provides shared state and behavior for both policy-based retry * (RetryableTask) and handler-based retry (RetryHandlerTask). It manages the * action, attempt count, start time, task type, and failure tracking that are * common to both retry strategies. */ export declare abstract class RetryTaskBase extends CompletableTask { private _action; private readonly _startTime; private readonly _taskType; private _attemptCount; private _lastFailure; /** * Creates a new RetryTaskBase instance. * * @param action - The orchestrator action associated with this task * @param startTime - The time when the task was first scheduled * @param taskType - The type of task (activity or sub-orchestration) */ constructor(action: pb.OrchestratorAction, startTime: Date, taskType: RetryTaskType); /** * Gets the orchestrator action associated with this task. */ get action(): pb.OrchestratorAction; /** * Gets the current attempt count. */ get attemptCount(): number; /** * Gets the time when the task was first scheduled. */ get startTime(): Date; /** * Gets the type of task (activity or sub-orchestration). */ get taskType(): RetryTaskType; /** * Gets the name of the task from the underlying action. * For activities, this is the activity name; for sub-orchestrations, the orchestrator name. */ get taskName(): string; /** * Gets the last failure details. */ get lastFailure(): pb.TaskFailureDetails | undefined; /** * Increments the attempt count. */ incrementAttemptCount(): void; /** * Updates the action associated with this task. * This is called when the task is rescheduled for retry with a new sequence ID. * * @param action - The new orchestrator action */ updateAction(action: pb.OrchestratorAction): void; /** * Records a failure for potential retry. * * @param message - The failure message * @param details - The failure details from the protobuf */ recordFailure(message: string, details?: pb.TaskFailureDetails): void; /** * Completes the task with the given result. * Clears any previously recorded failure since the retry succeeded. * * @param result - The result of the task */ complete(result: T): void; /** * Marks the task as failed after all retry attempts are exhausted. * * @param message - The failure message * @param details - Optional failure details */ fail(message: string, details?: pb.TaskFailureDetails): void; }