Skip to content

Create Background Processing Infrastructure: Create additional Background Process functions #485

@mxbclang

Description

@mxbclang

Create the remaining job functions needed to handle jobs correctly within the background process.

Acceptance Criteria

Create a new perflab_update_background_job function

  • Function accepts the following parameters
    • $job_id - Required. An integer of the job ID to update.
    • $job_data - Optional. An array of the job data to update, defaults to an empty array.
  • The job term is updated using update_term_meta function.
  • The job_data term meta is replaced entirely by the new $job_data array passed.

Create a new perflab_complete_background_job

  • Function accepts the following parameters
    • $job_id - Required. An integer of the job ID to update.
  • The function will use the $job_id to update the following term meta
    • job_completed_at - Set the term meta to the current timestamp
    • job_status - Set the term meta to the string completed.

Create a new perflab_background_job_error

  • Function accepts the following parameters
    • $job_id - Required. An integer of the job ID to update.
    • $message - Required. A string containing the error message.
    • $error_data - Optional. An array of additional data to store for debugging. Defaults to an empty array.
  • The function will use the job ID to update the following term meta.
    • job_errors - The job_errors array will be updated by appending the new error. Each error stored in the array is an another array containing the following keys:
      • datetime - The datetime string when the error message was created. format YYYY-MM-DD HH:MM:SS
      • message - The error message from the $message parameter
      • data - The $error_data array passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions