PHP 클래스 Resque_Worker, php-resque

저자: Chris Boulton ([email protected])
파일 보기 프로젝트 열기: chrisboulton/php-resque 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$logger Logging object that impliments the PSR-3 LoggerInterface

공개 메소드들

메소드 설명
__construct ( string | array $queues ) Instantiate a new worker, given a list of queues that it should be working on. The list of queues should be supplied in the priority that they should be checked for jobs (first come, first served)
__toString ( ) : string Generate a string representation of this worker.
all ( ) : array Return all workers known to Resque as instantiated instances.
doneWorking ( ) Notify Redis that we've finished working on a job, clearing the working state and incrementing the job stats.
exists ( string $workerId ) : boolean Given a worker ID, check if it is registered/valid.
find ( string $workerId ) : Resque_Worker Given a worker ID, find it and return an instantiated worker class for it.
getStat ( string $stat ) : integer Get a statistic belonging to this worker.
job ( ) : object Return an object describing the job this worker is currently working on.
killChild ( ) Kill a forked child job immediately. The job it is processing will not be completed.
pauseProcessing ( ) Signal handler callback for USR2, pauses processing of new jobs.
perform ( Resque_Job $job ) Process a single job.
pruneDeadWorkers ( ) Look for any workers which should be running on this server and if they're not, remove them from Redis.
queues ( boolean $fetch = true ) : array Return an array containing all of the queues that this worker should use when searching for jobs.
registerWorker ( ) Register this worker in Redis.
reserve ( boolean $blocking = false, integer $timeout = null ) : object | boolean
setId ( string $workerId ) Set the ID of this worker to a given ID string.
setLogger ( Psr\Log\LoggerInterface $logger ) Inject the logging object into the worker
shutdown ( ) Schedule a worker for shutdown. Will finish processing the current job and when the timeout interval is reached, the worker will shut down.
shutdownNow ( ) Force an immediate shutdown of the worker, killing any child jobs currently running.
unPauseProcessing ( ) Signal handler callback for CONT, resumes worker allowing it to pick up new jobs.
unregisterWorker ( ) Unregister this worker in Redis. (shutdown etc)
work ( integer $interval = Resque::DEFAULT_INTERVAL, $blocking = false ) The primary loop for a worker which when called on an instance starts the worker's life cycle.
workerPids ( ) : array Return an array of process IDs for all of the Resque workers currently running on this machine.
workingOn ( Resque_Job $job ) Tell Redis which job we're currently working on.

비공개 메소드들

메소드 설명
registerSigHandlers ( ) Register signal handlers that a worker should respond to.
startup ( ) Perform necessary actions to start a worker.
updateProcLine ( string $status ) On supported systems (with the PECL proctitle module installed), update the name of the currently running process to indicate the current state of a worker.

메소드 상세

__construct() 공개 메소드

Passing a single '*' allows the worker to work on all queues in alphabetical order. You can easily add new queues dynamically and have them worked on using this method.
public __construct ( string | array $queues )
$queues string | array String with a single queue name, array with multiple.

__toString() 공개 메소드

Generate a string representation of this worker.
public __toString ( ) : string
리턴 string String identifier for this worker instance.

all() 공개 정적인 메소드

Return all workers known to Resque as instantiated instances.
public static all ( ) : array
리턴 array

doneWorking() 공개 메소드

Notify Redis that we've finished working on a job, clearing the working state and incrementing the job stats.
public doneWorking ( )

exists() 공개 정적인 메소드

Given a worker ID, check if it is registered/valid.
public static exists ( string $workerId ) : boolean
$workerId string ID of the worker.
리턴 boolean True if the worker exists, false if not.

find() 공개 정적인 메소드

Given a worker ID, find it and return an instantiated worker class for it.
public static find ( string $workerId ) : Resque_Worker
$workerId string The ID of the worker.
리턴 Resque_Worker Instance of the worker. False if the worker does not exist.

getStat() 공개 메소드

Get a statistic belonging to this worker.
public getStat ( string $stat ) : integer
$stat string Statistic to fetch.
리턴 integer Statistic value.

job() 공개 메소드

Return an object describing the job this worker is currently working on.
public job ( ) : object
리턴 object Object with details of current job.

killChild() 공개 메소드

Kill a forked child job immediately. The job it is processing will not be completed.
public killChild ( )

pauseProcessing() 공개 메소드

Signal handler callback for USR2, pauses processing of new jobs.
public pauseProcessing ( )

perform() 공개 메소드

Process a single job.
public perform ( Resque_Job $job )
$job Resque_Job The job to be processed.

pruneDeadWorkers() 공개 메소드

This is a form of garbage collection to handle cases where the server may have been killed and the Resque workers did not die gracefully and therefore leave state information in Redis.
public pruneDeadWorkers ( )

queues() 공개 메소드

If * is found in the list of queues, every queue will be searched in alphabetic order. (@see $fetch)
public queues ( boolean $fetch = true ) : array
$fetch boolean If true, and the queue is set to *, will fetch all queue names from redis.
리턴 array Array of associated queues.

registerWorker() 공개 메소드

Register this worker in Redis.
public registerWorker ( )

reserve() 공개 메소드

public reserve ( boolean $blocking = false, integer $timeout = null ) : object | boolean
$blocking boolean
$timeout integer
리턴 object | boolean Instance of Resque_Job if a job is found, false if not.

setId() 공개 메소드

Set the ID of this worker to a given ID string.
public setId ( string $workerId )
$workerId string ID for the worker.

setLogger() 공개 메소드

Inject the logging object into the worker
public setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

shutdown() 공개 메소드

Schedule a worker for shutdown. Will finish processing the current job and when the timeout interval is reached, the worker will shut down.
public shutdown ( )

shutdownNow() 공개 메소드

Force an immediate shutdown of the worker, killing any child jobs currently running.
public shutdownNow ( )

unPauseProcessing() 공개 메소드

Signal handler callback for CONT, resumes worker allowing it to pick up new jobs.
public unPauseProcessing ( )

unregisterWorker() 공개 메소드

Unregister this worker in Redis. (shutdown etc)
public unregisterWorker ( )

work() 공개 메소드

Queues are checked every $interval (seconds) for new jobs.
public work ( integer $interval = Resque::DEFAULT_INTERVAL, $blocking = false )
$interval integer How often to check for new jobs across the queues.

workerPids() 공개 메소드

Return an array of process IDs for all of the Resque workers currently running on this machine.
public workerPids ( ) : array
리턴 array Array of Resque worker process IDs.

workingOn() 공개 메소드

Tell Redis which job we're currently working on.
public workingOn ( Resque_Job $job )
$job Resque_Job Resque_Job instance containing the job we're working on.

프로퍼티 상세

$logger 공개적으로 프로퍼티

Logging object that impliments the PSR-3 LoggerInterface
public $logger