PHP Class Cronario\Producer

Inheritance: use trait TraitOptions
Datei anzeigen Open project: cronario/cronario Class Usage Examples

Protected Properties

Property Type Description
$appId
$config
$logger Psr\Log\LoggerInterface
$managerIgnoreSet
$managerSet region MANAGER ************************************************************
$queue
$redis
$storage Cronario\Storage\StorageInterface

Public Methods

Method Description
__construct ( array $options = [] )
getAppId ( ) : string
getLogger ( ) : Psr\Log\LoggerInterface
getQueue ( ) : Queue
getRedis ( ) : Client
getRedisNamespace ( ) : string
getStats ( ) : array | string
getStorage ( ) : Cronario\Storage\StorageInterface
isStateStart ( ) : boolean
kill ( ) : boolean
reset ( )
restart ( )
start ( ) : boolean START daemon
stop ( boolean $async = false ) : boolean

Protected Methods

Method Description
buildManagerId ( $workerClass, $managerId ) : string
calcManagerSize ( $countJobsReady, $managerPoolSize, $managersLimit ) : float
cleanData ( )
cleanManagerSet ( ) Clean Manager SET
countManagerSet ( ) : integer
decData ( $key, integer $by = 1 )
deleteData ( $key )
getConfig ( null $key = null ) : array | integer | string | null
getData ( null $key = null ) : array | string
getProcessId ( ) : array | string
getState ( ) : array | string
incData ( $key, integer $by = 1 )
isState ( $state ) : boolean
mainLoop ( ) Daemon Main Loop 1) checking if Daemon should finish work (if redis flag is finish then finish loop) 2) updating info about loop and current process 3) Migrate all 'delayed job' to 'ready queue' if time is become 4) Update Manager set with theirs worker balance (create new Managers if needed) 5) Clean Manager if they are finished theirs works 6) loop sleep cause and run again until redis flag is 'start'
parseManagerId ( $string ) : array
processExists ( ) : boolean
processKill ( ) : string
setAppId ( $appId )
setConfig ( array $config )
setData ( $key, $value )
setLogger ( Psr\Log\LoggerInterface $logger )
setProcessId ( $id )
setQueue ( Queue $queue )
setRedis ( Client $redis )
setState ( $state )
setStorage ( Cronario\Storage\StorageInterface $storage )
updateInfo ( )
updateManagerSet ( ) Update Manager SET
waitManagersDone ( )

Method Details

__construct() public method

public __construct ( array $options = [] )
$options array

buildManagerId() protected method

protected buildManagerId ( $workerClass, $managerId ) : string
$workerClass
$managerId
return string

calcManagerSize() protected method

protected calcManagerSize ( $countJobsReady, $managerPoolSize, $managersLimit ) : float
$countJobsReady
$managerPoolSize
$managersLimit
return float

cleanData() protected method

protected cleanData ( )

cleanManagerSet() protected method

Checking each manager in ManagerSet and delete manager that done theirs work
protected cleanManagerSet ( )

countManagerSet() protected method

protected countManagerSet ( ) : integer
return integer

decData() protected method

protected decData ( $key, integer $by = 1 )
$key
$by integer

deleteData() protected method

protected deleteData ( $key )
$key

getAppId() public method

public getAppId ( ) : string
return string

getConfig() protected method

protected getConfig ( null $key = null ) : array | integer | string | null
$key null
return array | integer | string | null

getData() protected method

protected getData ( null $key = null ) : array | string
$key null
return array | string

getLogger() public method

public getLogger ( ) : Psr\Log\LoggerInterface
return Psr\Log\LoggerInterface

getProcessId() protected method

protected getProcessId ( ) : array | string
return array | string

getQueue() public method

public getQueue ( ) : Queue
return Queue

getRedis() public method

public getRedis ( ) : Client
return Predis\Client

getRedisNamespace() public method

public getRedisNamespace ( ) : string
return string

getState() protected method

protected getState ( ) : array | string
return array | string

getStats() public method

public getStats ( ) : array | string
return array | string

getStorage() public method

public getStorage ( ) : Cronario\Storage\StorageInterface
return Cronario\Storage\StorageInterface

incData() protected method

protected incData ( $key, integer $by = 1 )
$key
$by integer

isState() protected method

protected isState ( $state ) : boolean
$state
return boolean

isStateStart() public method

public isStateStart ( ) : boolean
return boolean

kill() public method

public kill ( ) : boolean
return boolean

mainLoop() protected method

Daemon Main Loop 1) checking if Daemon should finish work (if redis flag is finish then finish loop) 2) updating info about loop and current process 3) Migrate all 'delayed job' to 'ready queue' if time is become 4) Update Manager set with theirs worker balance (create new Managers if needed) 5) Clean Manager if they are finished theirs works 6) loop sleep cause and run again until redis flag is 'start'
protected mainLoop ( )

parseManagerId() protected method

protected parseManagerId ( $string ) : array
$string
return array

processExists() protected method

protected processExists ( ) : boolean
return boolean

processKill() protected method

protected processKill ( ) : string
return string

reset() public method

public reset ( )

restart() public method

public restart ( )

setAppId() protected method

protected setAppId ( $appId )
$appId

setConfig() protected method

protected setConfig ( array $config )
$config array

setData() protected method

protected setData ( $key, $value )
$key
$value

setLogger() protected method

protected setLogger ( Psr\Log\LoggerInterface $logger )
$logger Psr\Log\LoggerInterface

setProcessId() protected method

protected setProcessId ( $id )
$id

setQueue() protected method

protected setQueue ( Queue $queue )
$queue Queue

setRedis() protected method

protected setRedis ( Client $redis )
$redis Predis\Client

setState() protected method

protected setState ( $state )
$state

setStorage() protected method

protected setStorage ( Cronario\Storage\StorageInterface $storage )
$storage Cronario\Storage\StorageInterface

start() public method

1) get
public start ( ) : boolean
return boolean

stop() public method

public stop ( boolean $async = false ) : boolean
$async boolean
return boolean

updateInfo() protected method

protected updateInfo ( )

updateManagerSet() protected method

REMEMBER queueName === workerClass (cause we have relation one queue name for one type of worker) 1) get Queue stats for all queues on server 2) filter queues (stopping flag / existing ready job in it) 3) get worker configuration (to know what manager balance should do later) - if worker have problems with config we will add him to ignore manager set 4) then we try to create manager depend on exists managerSet and current balance
protected updateManagerSet ( )

waitManagersDone() protected method

protected waitManagersDone ( )

Property Details

$appId protected_oe property

protected $appId

$config protected_oe property

protected $config

$logger protected_oe property

protected LoggerInterface,Psr\Log $logger
return Psr\Log\LoggerInterface

$managerIgnoreSet protected_oe property

protected $managerIgnoreSet

$managerSet protected_oe property

region MANAGER ************************************************************
protected $managerSet

$queue protected_oe property

protected $queue

$redis protected_oe property

protected $redis

$storage protected_oe property

protected StorageInterface,Cronario\Storage $storage
return Cronario\Storage\StorageInterface