---
title: SourceJob
slug: data-platform/connect-platform/app-sdk-api-reference-classes-sourcejob
docTags: 
createdAt: 2026-08-05T20:06:34.632Z
---

[OCP App SDK](docId\:gxEU_0AA37IEZJK-uoVcT)

***

[OCP App SDK](docId\:gxEU_0AA37IEZJK-uoVcT) / SourceJob

# Class: `abstract` SourceJob

Defined in: [src/app/SourceJob.ts:48](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L48)

## Constructors

### Constructor

:::BlockQuote
**new SourceJob**(`invocation`, `source`): `SourceJob`
:::

Defined in: [src/app/SourceJob.ts:68](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L68)

Initializes a job to be run

### Parameters

### invocation

[`` `SourceJobInvocation` ``](docId\:HZjcmlYspTRqOF3F6C32v)

details of the job invocation

### source

[`` `Source` ``](docId\:sb5mvK6SX820iaqn0CSmJ)

### Returns

`SourceJob`

## Properties

### invocation

:::BlockQuote
`protected` **invocation**: [`` `SourceJobInvocation` ``](docId\:HZjcmlYspTRqOF3F6C32v)
:::

Defined in: [src/app/SourceJob.ts:68](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L68)

details of the job invocation

***

### isInterruptible

:::BlockQuote
**isInterruptible**: `boolean` = `false`
:::

Defined in: [src/app/SourceJob.ts:60](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L60)

Set this to true during an interruptible operation, such as waiting for a long running export.
When true, a job can be interrupted and resumed with the PREVIOUS Job state (the one perform was last called with).
A job is normally expected to complete a job loop (perform) within \< 60s. Your job CAN perform a loop for longer
than 60 seconds if isInterruptible is set to true for a significant part of each 60 seconds of runtime
and is performing NON-BLOCKING operations.

### IMPORTANT

You MUST ensure the process is **NOT BLOCKED** while interruptible. This can be achieved
by manually calling `await this.sleep()` regularly or is automatic if you are waiting on non-blocking calls.

`SourceJob::sleep` and `SourceJob::performInterruptibleTask` will set this value automatically.

***

### source

:::BlockQuote
`protected` **source**: [`` `Source` ``](docId\:sb5mvK6SX820iaqn0CSmJ)
:::

Defined in: [src/app/SourceJob.ts:68](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L68)

## Methods

### perform()

:::BlockQuote
`abstract` **perform**(`status`): `Promise`\<[`` `SourceJobStatus` ``](docId\:UdCu5uL4sWaDv948AMa1d)>
:::

Defined in: [src/app/SourceJob.ts:88](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L88)

Performs a unit of work. Jobs should perform a small unit of work and then return the current state.
Perform is automatically called in a loop where the previously returned state will be given to the next iteration.
Iteration will continue until complete is set to true in the returned job status.

### Parameters

### status

[`` `SourceJobStatus` ``](docId\:UdCu5uL4sWaDv948AMa1d)

last known job state and status

### Returns

`Promise`\<[`` `SourceJobStatus` ``](docId\:UdCu5uL4sWaDv948AMa1d)>

The current JobStatus/state that can be used to perform the next iteration or resume a job if interrupted.

***

### performInterruptibleTask()

:::BlockQuote
`protected` **performInterruptibleTask**\<`T`>(`task`): `Promise`\<`T`>
:::

Defined in: [src/app/SourceJob.ts:97](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L97)

Wrapper for interruptible tasks, such as waiting for a long api call or a timeout loop waiting for a result.
Interruptible tasks MUST BE NON-BLOCKING or must manually call `await this.sleep()` regularly (every few seconds).

### Type Parameters

### T

`T`

### Parameters

### task

() => `Promise`\<`T`>

### Returns

`Promise`\<`T`>

### Usage

`const result = await this.performInterruptibleTask(() => fetch(...)));`
In this example, the job can be interrupted during the fetch operation, and if interrupted will be resumed
with the previous job state.

***

### prepare()

:::BlockQuote
`abstract` **prepare**(`params`, `status?`, `resuming?`): `Promise`\<[`` `SourceJobStatus` ``](docId\:UdCu5uL4sWaDv948AMa1d)>
:::

Defined in: [src/app/SourceJob.ts:79](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L79)

Prepares to run a job. Prepare is called at the start of a job
and again only if the job was interrupted and is being resumed.
Use this function to read secrets and establish connections to simplify the job loop (perform).

### Parameters

### params

[`` `ValueHash` ``](docId\:iBlCGxR75KaoapohMUe5k)

a hash if params were supplied to the job run, otherwise an empty hash

### status?

[`` `SourceJobStatus` ``](docId\:UdCu5uL4sWaDv948AMa1d)

provided ONLY if the job was interrupted and should continue from the last known state

### resuming?

`boolean`

if the job was interrupted, resuming will be set to true when it is resumed

### Returns

`Promise`\<[`` `SourceJobStatus` ``](docId\:UdCu5uL4sWaDv948AMa1d)>

***

### sleep()

:::BlockQuote
`protected` **sleep**(`miliseconds?`, `options?`): `Promise`\<`void`>
:::

Defined in: [src/app/SourceJob.ts:117](https://github.com/ZaiusInc/app-sdk/blob/8c7209817facb226c91abb960e6d54a7692b9aa2/src/app/SourceJob.ts#L117)

Sleep the job without CPU thrashing. Use this method to wait for long running tasks, like an export API.

### Parameters

### miliseconds?

`number`

duration to sleep in miliseconds

### options?

[`` `SourceSleepOptions` ``](docId:2FofKq2laLyqqgvbufrOO)

`{interruptible: true}` if the job can be interrupted while sleeping.
A sleep that is not interruptible cannot safely be longer than about 55 seconds.

### Returns

`Promise`\<`void`>

### Usage

`await this.sleep(5000);`
