space.schedule.pause() and resume()
Stop a job from running for a while, then schedule it again.
pause() stops a job from running and keeps it with its history. resume() schedules it again from now.
function pause(id: string, options?: CallOptions): Promise<Job>
function resume(id: string, options?: CallOptions): Promise<Job>Parameters
Both take the same parameters.
idstringThe job’s ID: 26 lowercase letters and digits.
options.signalAbortSignalCancels the call.
options.timeoutMsnumberHow long the call may take, in milliseconds. The
timeoutMsset increateSpacewhen you leave it out, 30,000 by default.
Returns
A promise of the job. After pause(), its state is paused and its nextRunAt is null. After resume(), its state is enabled.
- Pausing cancels any run that is waiting to start or to retry. Its status becomes
cancelled. - Resuming schedules the job from now, so times missed while it was paused do not run.
Both calls are sent again, up to retries times, when they fail in a way that may pass, such as a network failure or 503, because sending one twice has the same effect as sending it once.
Errors
| Code | When |
|---|---|
validation_failed | id is not a job ID |
not_found | The project has no job with that ID |
Every call can also fail with the codes shared by all of space, such as missing_project or network_error. See SpaceError.
Example
import { space } from "digitospace"
const id = "01m3c081d2wj4g63qcr53pa1yh"
const paused = await space.schedule.pause(id)
console.log(paused.state)
const resumed = await space.schedule.resume(id)
console.log(resumed.state, resumed.nextRunAt)Last updated