Class BaseJobsServiceAbstract

Service for managing jobs.

Constructors

  • Parameters

    Returns BaseJobsService

Properties

appConfig: AppConfigType
cloudRunJobsService: CloudRunJobsService
dataSource: DataSource
eventEmitter: EventEmitter2
gpuJobs: Type<Job>[]
idService: IdService
jobRegistry: JobRegistry
jobTypeToWorkerType: Record<string, string>
loggerFactory: WinstonLoggerFactory
scheduledJobRegistry: ScheduledJobRegistryItem[]
workerTypeToCloudRunJobName: Record<string, string>

Accessors

  • get repository(): Repository<Job>

    Returns Repository<Job>

Methods

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Create a new job.

    Type Parameters

    Parameters

    Returns Promise<J>

    The created job.

    InternalServerErrorException if the job creation fails.

  • Generates a new ID for a job entity.

    Returns string

    The generated ID.

  • Get the Cloud Run job name for a worker type.

    Parameters

    • workerType: string

      The worker type.

    Returns null | string

    The Cloud Run job name or null if the worker not running on CloudRun Job.

  • Parameters

    Returns Promise<number>

  • Retrieves the class reference for a job entity of the specified type or throws a NotFoundException if it is not found.

    Parameters

    Returns Type<Job>

    The class reference for the specified job entity type.

    If the job entity is not found.

  • Retrieves multiple job entities based on the provided options.

    Parameters

    Returns Promise<[Job[], ListMeta]>

    A promise that resolves to an array containing the retrieved job entities and list metadata.

  • Retrieves the next job entity from the queue for the specified worker type.

    Parameters

    • workerType: string

      The worker type for which to retrieve the next job entity.

    Returns Promise<MaybeNull<Job>>

    A promise that resolves to the retrieved job entity, or null if there are no available job entities in the queue.

  • Retrieves a single job entity of the specified class by the given ID.

    Type Parameters

    • J extends Job

      The type of the job entity to retrieve.

    Parameters

    • classRef: Type<J>

      The class reference of the job entity to retrieve.

    • id: string

      The ID of the job entity to retrieve.

    Returns Promise<MaybeNull<J>>

    A promise that resolves to the retrieved job entity, or null if it was not found.

  • Retrieves a single job entity of the specified class by the given options.

    Type Parameters

    • J extends Job

      The type of the job entity to retrieve.

    Parameters

    Returns Promise<MaybeNull<J>>

    A promise that resolves to the retrieved job entity, or null if it was not found.

  • Retrieves a single job entity of the specified class by the given options or throws a NotFoundException if it is not found.

    Type Parameters

    • J extends Job

      The type of the job entity to retrieve.

    Parameters

    • classRef: Type<J>

      The class reference of the job entity to retrieve.

    • opts: GetJobByOptions

      The options to use when retrieving the job entity.

    • ctx: BaseServiceMethodContext

      The context of the service method.

    Returns Promise<J>

    A promise that resolves to the retrieved job entity.

    If the options object is empty.

    If the job entity is not found.

  • Retrieves a single job entity of the specified class by the given ID or throws a NotFoundException if it is not found.

    Type Parameters

    • J extends Job

      The type of the job entity to retrieve.

    Parameters

    • classRef: Type<J>

      The class reference of the job entity to retrieve.

    • id: string

      The ID of the job entity to retrieve.

    • ctx: BaseServiceMethodContext

      The context of the service method.

    Returns Promise<J>

    A promise that resolves to the retrieved job entity.

    If the options object is empty.

    If the job entity is not found.

  • Get the options for creating a scheduled job.

    Parameters

    • job: Type<Job>

      The job class reference.

    Returns CreateJobOptions

    The options for creating the scheduled job.

  • Get the worker type for a job.

    Type Parameters

    Parameters

    Returns Promise<null | string>

    The worker type for the job or null if the worker type not found.

  • Lock a job for processing.

    Parameters

    Returns Promise<boolean>

    True if the job was successfully locked, false otherwise.

  • Returns void

  • Runs queued jobs up to the maximum available parallel jobs count.

    Parameters

    Returns Promise<void>

    A promise that resolves when all queued jobs have been processed.

  • Runs scheduled jobs every minute.

    Parameters

    Returns Promise<void>

    A promise that resolves when all scheduled jobs have been processed.

  • Parameters

    Returns Promise<void>