CronJobGc
extends CronJob
in package
Uses
WithSelfRegister
Implement object cleanup handling
This class provides the necessary interfaces for garbage collection. It does also trigger session removals and logfile rotation.
Tags
Table of Contents
- $_progress : int
- internal progress buffer
- $dbal : CronJobDBAL|null
- database
- $definition : stdClass|null
- the job definition
- $id : int|null
- The job id
- $log_to_master : bool
- Indicates if logs are transferred to master after execution is done
- $multiply : float
- The multiplicator
- $name : string|null
- all cron jobs have to implement a name property
- $path : string|null
- local absolute storage path
- $run_single : bool
- $setup : stdClass|null
- the job information
- $config : object|null
- $git_repo : Git|null
- Git repository
- $max_age : int|float
- Max log file age is 60 days
- $max_age_basket : int|float
- Max age for baskets that will get deleted
- $max_age_git : int|float
- Max age for git log files, 3 days is ok
- $max_size : int|float
- Max log file size, set to 10 Mb for now
- $std_out_log : bool
- __construct() : mixed
- Construct a new instance of the object
- Cached() : bool
- Get no cache context
- ContextType() : string
- The context type id
- Delete() : Result
- Delete instance from database And the folder from file system
- Description() : string
- Expose the current description provide an interface to extract/set the current progress of this object
- Execute() : Result
- Execute the cleanup job
- Get() : mixed
- GetDefinition() : stdClass
- get setup object (content type defined) load the general plain setup object of this job
- GetMultiplicator() : float
- load multiplication load the factor for weighting this job in overall count on jobs executor
- GetName() : string
- expose the name
- GetPath() : string
- expose the storage path provide an interface to extract the current path of this object
- GetRegistrationTime() : bool|int
- Get registration Get the registration timestamp.
- GetStartTime() : int
- Get start time
- GetUser() : User|null
- Get current user
- Id() : int|null
- IsDone() : bool
- expose the current state provide an interface to extract whether this jo b is running
- IsError() : bool
- Set/Get if status is error provide an interface to extract whether this job is error
- IsRunning() : bool
- expose the current state provide an interface to extract whether this jo b is running
- Logfile() : string
- Path to the log file
- LogLine() : bool
- Log line write a line to the local system logfile
- LogToMaster() : bool
- The transfer flag
- LogToStdOut() : bool
- Target log output switch
- Pid() : false|string
- expose the current process pid provide an interface to extract the current Pid of this object
- Progress() : int|null
- Expose the current progress
- Register() : Result
- Registration handler This method is called when the run at time window is fitting
- Repository() : Git|null
- Get the git instance
- Restart() : Result
- ResultFile() : array<string|int, mixed>|null
- ResultFiles() : array<string|int, mixed>|null
- ReUse() : mixed
- re-use an existing object with alternative setup set the id to given and the path to null to force a reload
- Set() : mixed
- SetDefinition() : mixed
- add setup object (content type defined) buffers the general plain setup object of this job
- SetMultiply() : void
- Set the multiplactor
- Setup() : array<string|int, mixed>|null
- set/get the current setup
- Single() : bool
- Only one instance at a time allowed?
- TailLogfile() : Result
- Do log tail
- AttachResultFile() : Result
- cleanBasketChangeLog() : Result
- CleanBaskets() : Result
- Clear baskets
- cleanChangeLog() : Result
- cleanChat() : Result
- Delete historic chat messages
- CleanupJobs() : Result
- CleanupSessions() : Result
- Clean older session
- CleanupUploads() : Result
- Cleanup user uploads by age
- cleanUserChangeLog() : Result
- Database() : CronJobDBAL|null
- Get the database
- PersistItem() : Result|null
- Store some item in the database to persist it. Like the progress.
- RotateLogfiles() : Result
- Rotate known logfiles
Properties
$_progress
internal progress buffer
protected
int
$_progress
= 0
$dbal
database
protected
CronJobDBAL|null
$dbal
= null
$definition
the job definition
protected
stdClass|null
$definition
= null
$id
The job id
protected
int|null
$id
= null
$log_to_master
Indicates if logs are transferred to master after execution is done
protected
bool
$log_to_master
= false
$multiply
The multiplicator
protected
float
$multiply
= 0.0
$name
all cron jobs have to implement a name property
protected
string|null
$name
= null
Handlers name
$path
local absolute storage path
protected
string|null
$path
= null
$run_single
protected
bool
$run_single
= false
$setup
the job information
protected
stdClass|null
$setup
= null
$config
private
object|null
$config
= null
$git_repo
Git repository
private
Git|null
$git_repo
= null
$max_age
Max log file age is 60 days
private
int|float
$max_age
= 60 * 3600 * 24
$max_age_basket
Max age for baskets that will get deleted
private
int|float
$max_age_basket
= 86400 * 3
$max_age_git
Max age for git log files, 3 days is ok
private
int|float
$max_age_git
= 3 * 3600 * 24
$max_size
Max log file size, set to 10 Mb for now
private
int|float
$max_size
= 1024 * 1024 * 10
$std_out_log
private
bool
$std_out_log
= false
Methods
__construct()
Construct a new instance of the object
public
__construct([null $id = null ][, null $setup = null ]) : mixed
Parameters
- $id : null = null
-
A cron job identification number
- $setup : null = null
-
A cron job setup data set
Return values
mixed —Cached()
Get no cache context
public
Cached() : bool
Tags
Return values
bool —ContextType()
The context type id
public
ContextType() : string
Return values
string —Delete()
Delete instance from database And the folder from file system
public
Delete() : Result
Return values
Result —Description()
Expose the current description provide an interface to extract/set the current progress of this object
public
Description([string|null $value = null ]) : string
Parameters
- $value : string|null = null
-
The new description
Return values
string —The current description
Execute()
Execute the cleanup job
public
Execute() : Result
Return values
Result —Get()
public
Get(string $sg, string|null $key[, mixed $default = null ]) : mixed
Parameters
- $sg : string
- $key : string|null
- $default : mixed = null
Return values
mixed —GetDefinition()
get setup object (content type defined) load the general plain setup object of this job
public
GetDefinition() : stdClass
Return values
stdClass —a cron job definition from object storage
GetMultiplicator()
load multiplication load the factor for weighting this job in overall count on jobs executor
public
GetMultiplicator() : float
Return values
float —weighting of jobs in max buffer context
GetName()
expose the name
public
GetName() : string
provide an interface to extract the name
Return values
string —the object name
GetPath()
expose the storage path provide an interface to extract the current path of this object
public
GetPath() : string
Return values
string —the object storage path
GetRegistrationTime()
Get registration Get the registration timestamp.
public
GetRegistrationTime() : bool|int
Return values
bool|int —The timestamp
GetStartTime()
Get start time
public
GetStartTime() : int
Get the start timestamp.
Return values
int —The timestamp
GetUser()
Get current user
public
GetUser() : User|null
Tags
Return values
User|null —Id()
public
Id() : int|null
Return values
int|null —IsDone()
expose the current state provide an interface to extract whether this jo b is running
public
IsDone([int $value = null ]) : bool
Parameters
- $value : int = null
-
The current progress
Return values
bool —The current progress
IsError()
Set/Get if status is error provide an interface to extract whether this job is error
public
IsError([bool|null $value = null ]) : bool
Parameters
- $value : bool|null = null
-
The current progress
Return values
bool —The current progress
IsRunning()
expose the current state provide an interface to extract whether this jo b is running
public
IsRunning([int $value = null ]) : bool
Parameters
- $value : int = null
-
The current progress
Return values
bool —The current progress
Logfile()
Path to the log file
public
Logfile() : string
Return values
string —LogLine()
Log line write a line to the local system logfile
public
LogLine(mixed $value[, string $level = FAA_LOG_LEVEL_INFO ]) : bool
Parameters
- $value : mixed
-
The log message or any kind of object
- $level : string = FAA_LOG_LEVEL_INFO
-
The log level
Tags
Return values
bool —Write success or false on error
LogToMaster()
The transfer flag
public
LogToMaster() : bool
Return values
bool —LogToStdOut()
Target log output switch
public
LogToStdOut([bool|null $val = null ]) : bool
Parameters
- $val : bool|null = null
Return values
bool —Pid()
expose the current process pid provide an interface to extract the current Pid of this object
public
Pid([int|string|null $value = null ]) : false|string
Parameters
- $value : int|string|null = null
-
The current Pid
Return values
false|string —The current Pid
Progress()
Expose the current progress
public
Progress([float|int|null $value = null ]) : int|null
Provide an interface to extract the current progress of this object. When a value is given, the progress is set and persisted in the database
Parameters
- $value : float|int|null = null
-
The current progress
Return values
int|null —The current progress
Register()
Registration handler This method is called when the run at time window is fitting
public
abstract Register() : Result
Return values
Result —A system result object
Repository()
Get the git instance
public
Repository() : Git|null
Return values
Git|null —Restart()
public
Restart() : Result
Return values
Result —ResultFile()
public
ResultFile(string $name) : array<string|int, mixed>|null
Parameters
- $name : string
Return values
array<string|int, mixed>|null —ResultFiles()
public
ResultFiles() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —ReUse()
re-use an existing object with alternative setup set the id to given and the path to null to force a reload
public
ReUse(int $id) : mixed
Parameters
- $id : int
-
A cronjob identification number
Return values
mixed —Set()
public
Set(string $sg, string $key, mixed $data) : mixed
Parameters
- $sg : string
- $key : string
- $data : mixed
Return values
mixed —SetDefinition()
add setup object (content type defined) buffers the general plain setup object of this job
public
SetDefinition(stdClass $plain) : mixed
Parameters
- $plain : stdClass
-
A cronjob definition from object storage
Return values
mixed —SetMultiply()
Set the multiplactor
public
SetMultiply(float $val) : void
Parameters
- $val : float
Return values
void —Setup()
set/get the current setup
public
Setup([array<string|int, mixed>|null $value = null ]) : array<string|int, mixed>|null
provide an interface to extract the current setup of this object
Parameters
- $value : array<string|int, mixed>|null = null
-
The new setup
Return values
array<string|int, mixed>|null —The current setup
Single()
Only one instance at a time allowed?
public
Single() : bool
Return values
bool —TailLogfile()
Do log tail
public
TailLogfile(int $index) : Result
Get the tailing lines of the local log file.
Parameters
- $index : int
-
The start line index
Return values
Result —The result object
AttachResultFile()
protected
AttachResultFile(string $source[, string|null $name = null ][, bool $drop = false ]) : Result
Parameters
- $source : string
-
The source file
- $name : string|null = null
-
The target name or null
- $drop : bool = false
-
Drop original?
Return values
Result —cleanBasketChangeLog()
private
cleanBasketChangeLog() : Result
Return values
Result —CleanBaskets()
Clear baskets
private
CleanBaskets() : Result
This method will delete all open baskets without transaction id, status and owner It will cancel baskets with transaction but no status. The action will be skipped for baskets newer than defined day
Return values
Result —cleanChangeLog()
private
cleanChangeLog(string $type) : Result
Parameters
- $type : string
Return values
Result —cleanChat()
Delete historic chat messages
private
cleanChat() : Result
Return values
Result —CleanupJobs()
private
CleanupJobs() : Result
Return values
Result —CleanupSessions()
Clean older session
private
CleanupSessions() : Result
Return values
Result —CleanupUploads()
Cleanup user uploads by age
private
CleanupUploads() : Result
Return values
Result —cleanUserChangeLog()
private
cleanUserChangeLog() : Result
Return values
Result —Database()
Get the database
private
Database() : CronJobDBAL|null
Return values
CronJobDBAL|null —PersistItem()
Store some item in the database to persist it. Like the progress.
private
PersistItem(string $field, scalar $value) : Result|null
Parameters
- $field : string
-
The database column
- $value : scalar
-
The value
Return values
Result|null —RotateLogfiles()
Rotate known logfiles
private
RotateLogfiles() : Result
And delete older archived rotated log files