-
Notifications
You must be signed in to change notification settings - Fork 143
Create Background Processing Infrastructure: Perflab_Background_Process class #482
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
[Plugin] Performance LabIssue relates to work in the Performance Lab Plugin onlyIssue relates to work in the Performance Lab Plugin only[Plugin] Regenerate Existing ImagesIssues for the Regenerate Existing Images moduleIssues for the Regenerate Existing Images module
Description
Create Perflab_Background_Process::run method
Create a new a Perflab_Background_Process class to handle the background process runs.
This class will contain other helper methods for running jobs the background process built out in other issues.
- Create Background Processing Infrastructure: Create Perflab_Background_Process::memory_exceeded method #493
- Create Background Processing Infrastructure: Create Perflab_Background_Process::time_exceeded method #494
Acceptance Criteria
- Create a new
run( int $job_id )method in thePerflab_Background_Processclass. - The method will run through the following steps sequentially.
-
Set the start time
A$start_timevariable is set using the current timestamp as the value. -
Lock the process
- The job process is locked by setting a term meta against the job term. The meta key will be
job_lockand the value the current timestamp. - The job status is also updated by setting the
job_statusmeta torunning
- Retrieve the job information
Using the$job_idpassed to therunmethod get the following information.
$job- Create a new Job object using thePerflab_Background_Jobclass$job_namethis is the the job terms slug$job_datathis is from thejob_dataterm meta
- Call the job action
Within a do/while loop calldo_action( 'perflab_job_' . $job_name, $job_id, $job_data );
The while loop conditions will call the following like so:
while( ! $this->memory_exceeded() && ! $this->time_exceeded() && ! $job->is_completed( $job_id ) )
-
Unlock process
Outside of the while loop, to end the process, unlock the job by removing thejob_lockterm meta. -
Start the next batch process
Start the next batch process by calling the functionperflab_background_process_next_batch()passing the$job_idas the only parameter.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Plugin] Performance LabIssue relates to work in the Performance Lab Plugin onlyIssue relates to work in the Performance Lab Plugin only[Plugin] Regenerate Existing ImagesIssues for the Regenerate Existing Images moduleIssues for the Regenerate Existing Images module
Type
Fields
Give feedbackNo fields configured for issues without a type.