PHP Class Yalesov\Cron\Service\Cron

handle cron job registration, validation, scheduling, running, and cleanup
Author: yalesov ([email protected])
显示文件 Open project: heartsentwined/zf2-cron Class Usage Examples

Protected Properties

Property Type Description
$em Doctrine\ORM\EntityManager the Doctrine ORM Entity Manager
$failureLogLifetime how long to keep failed (missed / error) cron job logs
$maxRunningTime maximum running time of each cron job
$pending wrapped the Repo function here to implement a (crude) cache feature
$scheduleAhead how long ahead to schedule cron jobs
$scheduleLifetime how long before a scheduled job is considered missed
$successLogLifetime how long to keep successfully completed cron job logs

Public Methods

Method Description
cleanLog ( ) : self delete old cron job logs
cleanup ( ) : self perform various cleanup work
getEm ( )
getFailureLogLifetime ( )
getMaxRunningtime ( )
getPending ( )
getScheduleAhead ( )
getScheduleLifeTime ( )
getSuccessLogLifetime ( )
process ( ) : self run cron jobs
recoverRunning ( )
register ( $code, $frequency, $callback, array $args = [] ) wrapper function
resetPending ( )
run ( ) : self main entry function
schedule ( ) : self schedule cron jobs
setEm ( EntityManager $em )
setFailureLogLifetime ( $failureLogLifetime )
setMaxRunningTime ( $maxRunningTime )
setScheduleAhead ( $scheduleAhead )
setScheduleLifetime ( $scheduleLifetime )
setSuccessLogLifetime ( $successLogLifetime )
tryLockJob ( Job $job ) : boolean try to acquire a lock on a cron job

Method Details

cleanLog() public method

delete old cron job logs
public cleanLog ( ) : self
return self

cleanup() public method

perform various cleanup work
public cleanup ( ) : self
return self

getEm() public method

public getEm ( )

getFailureLogLifetime() public method

getMaxRunningtime() public method

public getMaxRunningtime ( )

getPending() public method

public getPending ( )

getScheduleAhead() public method

public getScheduleAhead ( )

getScheduleLifeTime() public method

public getScheduleLifeTime ( )

getSuccessLogLifetime() public method

process() public method

run cron jobs
public process ( ) : self
return self

recoverRunning() public method

public recoverRunning ( )

register() public static method

wrapper function
See also: Registry::register()
public static register ( $code, $frequency, $callback, array $args = [] )
$args array

resetPending() public method

public resetPending ( )

run() public method

1. schedule new cron jobs 2. process cron jobs 3. cleanup old logs
public run ( ) : self
return self

schedule() public method

schedule cron jobs
public schedule ( ) : self
return self

setEm() public method

public setEm ( EntityManager $em )
$em Doctrine\ORM\EntityManager

setFailureLogLifetime() public method

public setFailureLogLifetime ( $failureLogLifetime )

setMaxRunningTime() public method

public setMaxRunningTime ( $maxRunningTime )

setScheduleAhead() public method

public setScheduleAhead ( $scheduleAhead )

setScheduleLifetime() public method

public setScheduleLifetime ( $scheduleLifetime )

setSuccessLogLifetime() public method

public setSuccessLogLifetime ( $successLogLifetime )

tryLockJob() public method

set a job to 'running' only if it is currently 'pending'
public tryLockJob ( Job $job ) : boolean
$job Yalesov\Cron\Entity\Job
return boolean

Property Details

$em protected_oe property

the Doctrine ORM Entity Manager
protected EntityManager,Doctrine\ORM $em
return Doctrine\ORM\EntityManager

$failureLogLifetime protected_oe property

how long to keep failed (missed / error) cron job logs
protected $failureLogLifetime

$maxRunningTime protected_oe property

maximum running time of each cron job
protected $maxRunningTime

$pending protected_oe property

wrapped the Repo function here to implement a (crude) cache feature
protected $pending

$scheduleAhead protected_oe property

how long ahead to schedule cron jobs
protected $scheduleAhead

$scheduleLifetime protected_oe property

how long before a scheduled job is considered missed
protected $scheduleLifetime

$successLogLifetime protected_oe property

how long to keep successfully completed cron job logs
protected $successLogLifetime