Giter Site home page Giter Site logo

safe-queue's Introduction

SafeQueue

A Laravel Queue worker that's safe for use with Laravel Doctrine

When to use SafeQueue

  • You use Laravel 6 or up
  • You use Laravel Doctrine
  • Devops say the CPU usage of queue:listen is unacceptable
  • You want to do php artisan queue:work --daemon without hitting cascading EntityManager is closed exceptions

Compatibility

Version Supported Laravel Versions
0.1.* 5.1, 5.2
0.2.* ^5.3.16
0.3.* > 5.4 & <=5.8.*
0.4.* ^6.0 & ^7.0
0.5.* ^8.0

How it Works

SafeQueue overrides a small piece of Laravel functionality to make the queue worker daemon safe for use with Doctrine. It makes sure that the worker exits if the EntityManager is closed after an exception. For good measure it also clears the EM before working each job.

Installation

Install using composer

composer require digbang/safe-queue

Once you've got the codez add the following to your service providers in app.php

Digbang\SafeQueue\DoctrineQueueProvider::class
Lumen

Create the config file config/safequeue.php and load it: $app->configure('safequeue');

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Worker Command Name
    |--------------------------------------------------------------------------
    |
    | Configure the signature / name of the Work Command here. The default
    | is to rename the command to 'doctrine:queue:work', however you can
    | rename it to whatever you want by changing this value.
    |
    | To override the Laravel 'queue:work' command name just set this
    | to a false value or 'queue:work'.
    |
    */
    'command_name' => 'doctrine:queue:work',

];

Usage

php artisan doctrine:queue:work  connection --daemon --sleep=3 --tries=3 ...

All options are identical to Laravel's own queue:work method.

safe-queue's People

Contributors

dpgover avatar filipegranato avatar hodgy avatar jon-frankel avatar leeovery avatar maarten00 avatar maxbrokman avatar microdel avatar motia avatar sisve avatar sojeda avatar

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.