Options
All
  • Public
  • Public/Protected
  • All
Menu

pinus-scheduler

Index

Variables

CRON_JOB

CRON_JOB: number = 2

DOM

DOM: number = 3

DOW

DOW: number = 5

HOUR

HOUR: number = 2

Limit

Limit: number[][] = [[0, 59],[0, 59],[0, 24],[1, 31],[0, 11],[0, 6]]

MIN

MIN: number = 1

MONTH

MONTH: number = 4

SECOND

SECOND: number = 0

SIMPLE_JOB

SIMPLE_JOB: number = 1

SKIP_OLD_JOB

SKIP_OLD_JOB: boolean = false

This is the tirgger that use an object as trigger.

accuracy

accuracy: number = 10

jobCount

jobCount: number = 0

jobId

jobId: number = 0

lateCount

lateCount: number = 0

limit

limit: number[][] = [[0, 59], [0, 59], [0, 24], [1, 31], [1, 12], [0, 6]]

logger

logger: any = require('log4js').getLogger(__filename)

map

map: object

Type declaration

  • [key: number]: Job

queue

queue: PriorityQueue = PriorityQueue.createPriorityQueue(comparator)

timer

timer: any

timerCount

timerCount: number = 0

warnLimit

warnLimit: number = 500

Functions

cancelJob

  • cancelJob(id: number): boolean
  • Cancel Job

    Parameters

    • id: number

    Returns boolean

checkNum

  • checkNum(nums: any, min: number, max: number): boolean
  • Check if the numbers are valid

    Parameters

    • nums: any

      The numbers array need to check

    • min: number

      Minimus value

    • max: number

      Maximam value

    Returns boolean

    If all the numbers are in the data range

comparator

  • comparator(e1: object, e2: object): boolean
  • Parameters

    • e1: object
      • time: number
    • e2: object
      • time: number

    Returns boolean

createJob

  • The Interface to create Job

    Parameters

    • trigger: SimpleTriggerOpts | string

      The trigger to use

    • jobFunc: Function

      The function the job to run

    • jobData: any

    Returns Job

    The new instance of the give job or null if fail

createPriorityQueue

createTrigger

  • Create Simple trigger

    Parameters

    • trigger: object

      The Cron Trigger string

      • Optional count?: number
      • Optional period?: number
      • Optional start?: number
    • job: Job

    Returns SimpleTrigger

    The Cron trigger

decodeCronTime

  • decodeCronTime(cronTime: string): any[]

decodePeriodTime

  • decodePeriodTime(map: object, timeStr: string, type: number): void
  • Compute the period timer

    Parameters

    • map: object
      • [key: number]: number
    • timeStr: string
    • type: number

    Returns void

decodeRangeTime

  • decodeRangeTime(map: object, timeStr: string): void
  • Decode time range

    Parameters

    • map: object

      The decode map

      • [key: number]: number
    • timeStr: string

      The range string, like 2-5

    Returns void

decodeTimeStr

  • decodeTimeStr(timeStr: any): string[] | -1

excuteJob

  • excuteJob(): void
  • The function used to ran the schedule job, and setTimeout for next running job

    Returns void

getDomLimit

  • getDomLimit(year: number, month: number): number
  • Get the date limit of given month

    month

    The given month

    Parameters

    • year: number
    • month: number

    Returns number

    The date count of given month

getNextJob

  • getNextJob(): Job
  • Return and remove the next valid job

    Returns Job

    Next valid job

nexExcuteTime

  • nexExcuteTime(time: number, timer?: Timer): number
  • Parameters

    • time: number
    • Default value timer: Timer = {second: -1, min: -1, hour: -1, dom: -1, month: -1, dow: -1, executeTime: -1}

    Returns number

nextCronTime

  • nextCronTime(value: number, cronTime: Array<number>): number
  • return the next match time of the given value

    Parameters

    • value: number

      The time value

    • cronTime: Array<number>

      The cronTime need to match

    Returns number

    The match value or null if unmatch(it offten means an error occur).

nextTime

  • nextTime(value: number, cronTime: number | Array<number>): number
  • return the next match time of the given value

    Parameters

    • value: number
    • cronTime: number | Array<number>

    Returns number

peekNextJob

  • peekNextJob(): Job
  • Return, but not remove the next valid job

    Returns Job

    Next valid job

scheduleJob

  • scheduleJob<T>(trigger: SimpleTriggerOpts | string, jobFunc: function, jobData?: T): number
  • Schedule a new Job

    Type parameters

    • T

    Parameters

    • trigger: SimpleTriggerOpts | string

      The trigger to use

    • jobFunc: function

      The function the job to run

        • (data?: T): void
        • Parameters

          • Optional data: T

          Returns void

    • Optional jobData: T

      The data the job use

    Returns number

    The job id, which can be canceled by cancelJob(id:number)

setTimer

  • setTimer(job: Job): void
  • Clear last timeout and schedule the next job, it will automaticly run the job that need to run now

    Parameters

    • job: Job

      The job need to schedule

    Returns void

    void

timeMatch

  • timeMatch(value: number, cronTime: Array<number>): boolean
  • Match the given value to the cronTime

    Parameters

    • value: number

      The given value

    • cronTime: Array<number>

      The cronTime

    Returns boolean

    The match result