master

laravel/framework

Last updated at: 29/12/2023 09:24

FailedJobProviderInterface.php

TLDR

This file defines the FailedJobProviderInterface interface, which provides methods for logging, retrieving, and deleting failed jobs in a queue.

Methods

log

Log a failed job into storage.

  • Parameters:
    • $connection (string): The connection name.
    • $queue (string): The queue name.
    • $payload (string): The job's serialized payload.
    • $exception (\Throwable): The exception that caused the job to fail.
  • Returns: string|int|null. The id of the logged failed job.

all

Get a list of all failed jobs.

  • Returns: array. An array of all failed jobs.

find

Get a single failed job by its id.

  • Parameters:
    • $id (mixed): The id of the failed job.
  • Returns: object|null. The failed job object if found, otherwise null.

forget

Delete a single failed job from storage.

  • Parameters:
    • $id (mixed): The id of the failed job to delete.
  • Returns: bool. true if the failed job was deleted successfully, otherwise false.

flush

Flush all failed jobs from storage.

  • Parameters:
    • $hours (int|null): The number of hours of failed jobs to keep. If null, all failed jobs will be deleted.
  • Returns: void.
<?php

namespace Illuminate\Queue\Failed;

/**
 * @method array ids(string $queue = null)
 */
interface FailedJobProviderInterface
{
    /**
     * Log a failed job into storage.
     *
     * @param  string  $connection
     * @param  string  $queue
     * @param  string  $payload
     * @param  \Throwable  $exception
     * @return string|int|null
     */
    public function log($connection, $queue, $payload, $exception);

    /**
     * Get a list of all of the failed jobs.
     *
     * @return array
     */
    public function all();

    /**
     * Get a single failed job.
     *
     * @param  mixed  $id
     * @return object|null
     */
    public function find($id);

    /**
     * Delete a single failed job from storage.
     *
     * @param  mixed  $id
     * @return bool
     */
    public function forget($id);

    /**
     * Flush all of the failed jobs from storage.
     *
     * @param  int|null  $hours
     * @return void
     */
    public function flush($hours = null);
}