Git Product home page Git Product logo

queue's Introduction

CodeIgniter Queue

Queues for the CodeIgniter 4 framework.

PHPUnit PHPStan Deptrac Coverage Status

PHP CodeIgniter License

Installation

composer require codeigniter4/queue

Migrate your database:

php spark migrate --all

Configuration

Publish configuration file:

php spark queue:publish

Create your first Job:

php spark queue:job Example

Add it to the $jobHandlers array in the app\Config\Queue.php file:

// ...

use App\Jobs\Example;

// ...

public array $jobHandlers = [
    'my-example' => Example::class
];

// ...

Basic usage

Add job to the queue:

service('queue')->push('queueName', 'my-example', ['data' => 'array']);

Run the queue worker:

php spark queue:work queueName

Docs

Read the full documentation: https://queue.codeigniter.com

Contributing

We accept and encourage contributions from the community in any shape. It doesn't matter whether you can code, write documentation, or help find bugs, all contributions are welcome. See the CONTRIBUTING.md file for details.

queue's People

Contributors

dependabot[bot] avatar kenjis avatar lonnieezell avatar michalsn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

queue's Issues

Dev: Postgresql queue:jobs

Hello everyone,
I don't know if you have performed any operations on postgresql.
I can't consume the jobs
php spark queue:job Email

attached the error image
Capture d’écran 2024-07-10 à 22 30 10

Thanks,

queue:work default - error after start job

CodeIgniter\CLI\CLI::print(): Argument #1 ($text) must be of type string, int given, called in \vendor\codeigniter4\queue\src\Commands\QueueWork.php on line 164

at SYSTEMPATH\CLI\CLI.php:449

Backtrace:
1 VENDORPATH\codeigniter4\queue\src\Commands\QueueWork.php:164
CodeIgniter\CLI\CLI::print()

2 SYSTEMPATH\CLI\Commands.php:65
CodeIgniter\Queue\Commands\QueueWork()->run()

3 SYSTEMPATH\CLI\Console.php:46
CodeIgniter\CLI\Commands()->run()

4 ROOTPATH\spark:102
CodeIgniter\CLI\Console()->run()

Bug: Queue Not Logging Failed Tasks with Transactions

Issue Description:
I have identified a bug in the CodeIgniter 4 queue system. When a task fails during execution, and that task involves a transaction, it fails to log the failure in the designated log file.

class ExampleJob
{
    public function process(string $data):
    {
        $db = db_connect();
        
        $db->transStart(); // Start Transaction
            
       // Job logic here and get RuntimeException

    }
}

When a job fails to execute, the system fails to log the failure in the queue_jobs_failed table. Furthermore, when utilizing the DatabaseHandler, the job record remains unremoved from the queue_jobs table.

This oversight results in a lack of visibility into failed jobs and may lead to potential data inconsistency within the job management system.

FOR UPDATE SKIP LOCKED

MariaDb 10.5 not work query

SELECT *
FROM `queue_jobs`
WHERE `queue` = 'price_import'
AND `status` = 0
AND `available_at` <= 1707854930
AND `priority` IN ('default')
ORDER BY `available_at` ASC, `id` ASC
 LIMIT 1 FOR UPDATE SKIP LOCKED

Dev: FOR UPDATE SKIP LOCKED issue when retrieving jobs in a queue

When retrieving jobs in a queue the function skipLocked() is called (QueueJobModel.php). The sql addon "FOR UPDATE SKIP LOCKED" is not available in new but not the newest MariaDB versions. This causes a "FALSE" on the query leading to an empty queue. Perhaps it's better to throw an exception than. Returning zero jobs is confusing.

by composer install error

[ErrorException]

Undefined array key 0

at VENDORPATH\codeigniter4\queue\src\Commands\QueuePublish.php:21

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.