Search…
Job

Cron

The new min jobs per day for cortex will be 1 every 10 seconds (8640). This allows up to 6 * * * * * type cron jobs until limits are reached. This is a minimum allowance which supercedes the maximum allowance if it is lower. Effectively Math.max( min, env max). The new default is also 8640 per day.x

Job

1
@job('1 * * * *', {
2
name: 'update_check',
3
weight: 5
4
})
5
updateCheck({ context, runtime }) {
6
7
console.log(runtime.configuration.cron, script.principal.email)
8
9
}
Copied!

@job(options)

Arguments
  • options { Object } Options object
    • name { String }
    • type { String }
    • principal { String }
    • environment { String = "*" }
    • weight { Number = 0 }
    • cron { String } Cron job syntax

@job(cron, options)

Arguments
  • cron { String } Cron job syntax
  • options { Object } Options object
    • name { String }
    • type { String }
    • principal { String }
    • environment { String = "*" }
    • weight { Number = 0 }

@job(cron, principal, options)

Arguments
  • cron { String } Cron job syntax
  • principal { String }
  • options { Object } Options object
    • name { String }
    • type { String }
    • environment { String = "*" }
    • weight { Number = 0 }

Method Options

  • methodOptions { Object } Options passed to the method
    • runtime { Object }
      • name { String }
      • type { String }
      • principal { String }
      • environment { String = "*" }
      • weight { Number = 0 }
      • configuration { Object }
        • cron { String }
      • metadata { Object }
        • resource { String }
        • className { String }
        • methodName { String }
        • static { Boolean }
        • loc { Object }
          • line { String }
          • column { String }

Examples

Override Jobs
1
const { job } = require('decorators')
2
3
class JobTest {
4
5
@job('*/1 * * * *', { name: 'hello_job' })
6
maintenance({ context, runtime }) {
7
return {
8
context,
9
runtime,
10
value: 'hello from job'
11
}
12
}
13
14
}
15
16
class JobTestOverride {
17
// JobTest hello_job will be overwritten by this new job
18
@job('*/2 * * * *', { name: 'hello_job', weight: 1 })
19
maintenance({ context, runtime }) {
20
return {
21
context,
22
runtime,
23
value: 'hello from overwritten job'
24
}
25
}
26
27
}
Copied!
Last modified 2mo ago
Copy link