Skip to content

Compatible for laravel 8/9? #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8504bf7
🔨 Upgrade to Laravel v6.0
antonioftamura Feb 18, 2021
a34c6b8
Merge pull request #1 from DNXLabs/feature/6.xLaravelSupport
antonioftamura Feb 18, 2021
c16608e
💚 Setup Github Actions
antonioftamura Feb 18, 2021
1bc77f7
🔧 Namespace Changes
antonioftamura Feb 18, 2021
d12cff6
💚 Continuous Integration
antonioftamura Feb 19, 2021
b62c775
🔥 Remove < PHP 7.2 Support in the new version
antonioftamura Feb 19, 2021
bc4649c
💚 Continuous Integration
antonioftamura Feb 19, 2021
6ac4462
Include additional signature for AWS batch command
sohflp Feb 19, 2021
c250f4e
Merge branch 'master' of github.com:DNXLabs/laravel-queue-aws-batch
sohflp Feb 19, 2021
3517ac4
Remove extension of pop() function
sohflp Feb 19, 2021
672c975
💚 Continuous Integration
antonioftamura Feb 20, 2021
3465256
💚 Continuous Integration
antonioftamura Feb 20, 2021
c534c34
💚 Continuous Integration
antonioftamura Feb 20, 2021
c2d0297
💚 Continuous Integration
antonioftamura Feb 20, 2021
224e6f4
💚 Continuous Integration
antonioftamura Feb 20, 2021
94322cb
💚 Continuous Integration
antonioftamura Feb 20, 2021
14fd803
💚 Continuous Integration
antonioftamura Feb 20, 2021
a7742e9
💚 Continuous Integration
antonioftamura Feb 20, 2021
199eb04
💚 Continuous Integration
antonioftamura Feb 20, 2021
1181cd5
💚 Continuous Integration
antonioftamura Feb 20, 2021
6e2962f
💚 Continuous Integration
antonioftamura Feb 20, 2021
e4a041f
💚 Continuous Integration
antonioftamura Feb 20, 2021
2631d2c
💚 Continuous Integration
antonioftamura Feb 20, 2021
9c3cdb3
💚 Continuous Integration
antonioftamura Feb 20, 2021
241dbc4
🐛 Fix Connnection Argument Should be Optional
antonioftamura Mar 5, 2021
aaefb78
Merge pull request #2 from DNXLabs/bug/FixOptionalConnectionParameter
antonioftamura Mar 5, 2021
6a34879
🔖 Release v3.0.4
antonioftamura Mar 5, 2021
49af158
Add Laravel connection ID to list of AWS Batch parameters
sohflp Mar 5, 2021
b4a1609
Fix dispatcher of single job ID for Laravel 6.x
sohflp Mar 9, 2021
2c47a93
Fix job name limit of 128 characters
sohflp Mar 19, 2021
cd240c5
Replace str_limit by Laravel Str::limit
sohflp Mar 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PHP Composer

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

# - name: Run test suite
# run: composer run-script test
96 changes: 77 additions & 19 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,81 @@
filter:
excluded_paths: [tests/*]

checks:
php:
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
code_rating: true
duplication: true

build_failure_conditions:
- 'project.metric_change("scrutinizer.quality", < -0.10)'
- 'elements.rating(<= D).exists' # No classes/methods with a rating of D or worse
- 'elements.rating(<= D).new.exists' # No new classes/methods with a rating of D or worse allowed
- 'issues.label("coding-style").exists' # No coding style issues allowed
- 'issues.label("coding-style").new.exists' # No new coding style issues allowed
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
- 'issues.severity(>= MAJOR).exists' # New major or higher severity issues
- 'project.metric("scrutinizer.quality", < 9)' # Code Quality Rating drops below 9
- 'project.metric_change("scrutinizer.test_coverage", < -0.1)' # Code Coverage decreased from previous inspection by more than 10%
- 'patches.label("Doc Comments").exists' # No doc comments patches allowed
- 'patches.label("Spacing").exists' # No spacing patches allowed

build:
nodes:
analysis:
tests:
override:
-
command: php-scrutinizer-run
command: composer run-script codestyle

coverage:
tests:
override:
-
command: ./vendor/bin/phpunit --coverage-clover=tests/reports/clover.xml
idle_timeout: 1200
coverage:
file: 'tests/reports/clover.xml'
format: 'php-clover'
command: php vendor/bin/ocular code-coverage:upload --format=php-clover tests/reports/clover.xml

cache:
directories:
- vendor # Cache for already installed composer package -> speed up composer install
- ~/.composer # Composer home directory (avoid fetching already fetched packages)


tools:
external_code_coverage:
timeout: 600
runs: 3
php_analyzer:
enabled: true
config:
checkstyle:
enabled: true
naming:
isser_method_name: ^.*$
utility_class_name: ^.*$
doc_comment_fixes:
enabled: false
reflection_fixes:
enabled: false
use_statement_fixes:
enabled: false
simplify_boolean_return:
enabled: true
external_code_coverage: false
php_code_coverage: true
php_changetracking: true
php_cpd: true
php_cs_fixer: false
php_mess_detector: true
php_pdepend: true
sensiolabs_security_checker: true

filter:
paths:
- src/*

coding_style:
php:
spaces:
before_parentheses:
closure_definition: true
around_operators:
concatenation: false
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

cache:
directories:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release Notes for 2.x

## v3.0.4 (2021-03-05)

* Fix `queue-work:batch` command connection as optional argument ([#2](https://github.com/dnxlabs/laravel-queue-aws-batch/pull/1))

## v3.0.0 (2021-02-18)

### Added
* Support for Laravel 6.x ([#21](https://github.com/dnxlabs/laravel-queue-aws-batch/pull/1))

## v2.0.1 (2017-04-13)

### Fixed
Expand Down
34 changes: 22 additions & 12 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@
### Supported Versions
| Laravel Version | Package Tag | Supported |
|-----------------|-------------|-----------|
| 5.4.x | 2.0.x | yes |
| 5.3.x | 1.0.x | yes |
| 5.2.x | 1.0.x | yes |
| 5.1.x | 1.0.x | yes |
| 6.0.x | 3.0.x | yes |

### Installation
See the table above for package version information, and change the version below accordingly.

Add custom repository to your composer json:
```
"require": {
"dnxlabs/laravel-queue-aws-batch": "~3.0.0"
},
"repositories": [
{
"type": "vcs",
"url": "[email protected]:dnxlabs/laravel-queue-aws-batch.git"
}
]
```

Using `composer`, run:

composer require lukewaite/laravel-queue-aws-batch ~2.0
composer require dnxlabs/laravel-queue-aws-batch ~3.0


### Usage
Expand Down Expand Up @@ -79,7 +89,7 @@ the _next_ run after tries has been exceeded by jobs failing. Newer versions wil
this requirement can be relaxed later.

6. Add the Service Provider to your application:
* In `config/app.php` add to the `providers` array: `LukeWaite\LaravelQueueAwsBatch\BatchQueueServiceProvider::class`
* In `config/app.php` add to the `providers` array: `DNXLabs\LaravelQueueAwsBatch\BatchQueueServiceProvider::class`


### Limitations
Expand All @@ -89,11 +99,11 @@ AWS Batch has no method to delay a job and as it's our runner, we don't have an
jobs for your use case, at this point my recommendation would be to use a regular DB queue, and to fire a job into it
which will fire your batch job at the correct time.

[ico-version]: https://img.shields.io/packagist/v/lukewaite/laravel-queue-aws-batch.svg?style=flat-square
[ico-version]: https://img.shields.io/packagist/v/dnxlabs/laravel-queue-aws-batch.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/lukewaite/laravel-queue-aws-batch/master.svg?style=flat-square
[ico-coverage]: https://img.shields.io/scrutinizer/coverage/g/lukewaite/laravel-queue-aws-batch/master.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/dnxlabs/laravel-queue-aws-batch/master.svg?style=flat-square
[ico-coverage]: https://img.shields.io/scrutinizer/coverage/g/dnxlabs/laravel-queue-aws-batch/master.svg?style=flat-square

[link-packagist]: https://packagist.org/packages/lukewaite/laravel-queue-aws-batch
[link-travis]: https://travis-ci.org/lukewaite/laravel-queue-aws-batch
[link-coverage]: https://scrutinizer-ci.com/g/lukewaite/laravel-queue-aws-batch/?branch=master
[link-packagist]: https://packagist.org/packages/dnxlabs/laravel-queue-aws-batch
[link-travis]: https://travis-ci.org/dnxlabs/laravel-queue-aws-batch
[link-coverage]: https://scrutinizer-ci.com/g/dnxlabs/laravel-queue-aws-batch/?branch=master
10 changes: 5 additions & 5 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lukewaite/laravel-queue-aws-batch",
"name": "dnxlabs/laravel-queue-aws-batch",
"description": "Laravel Queue for AWS Batch, enabling users to submit jobs for processing to a Batch queue.",
"keywords": [
"laravel",
Expand All @@ -10,7 +10,7 @@
"license": "MIT",
"autoload": {
"psr-4": {
"LukeWaite\\LaravelQueueAwsBatch\\": "src/"
"DNXLabs\\LaravelQueueAwsBatch\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -24,9 +24,9 @@
},
"require-dev": {
"mockery/mockery": "^0.9.6",
"laravel/framework": ">5.4",
"phpunit/phpunit": "~4.8",
"squizlabs/php_codesniffer": "^2.8",
"laravel/framework": "^6.0",
"phpunit/phpunit": "~8.2",
"squizlabs/php_codesniffer": ">2.8",
"scrutinizer/ocular": "^1.3"
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/BatchQueueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* @copyright 2017 Luke Waite
* @license http://www.opensource.org/licenses/mit-license.php MIT
*
* @link https://github.com/lukewaite/laravel-queue-aws-batch
* @link https://github.com/dnxlabs/laravel-queue-aws-batch
*/

namespace LukeWaite\LaravelQueueAwsBatch;
namespace DNXLabs\LaravelQueueAwsBatch;

use Illuminate\Support\ServiceProvider;
use LukeWaite\LaravelQueueAwsBatch\Connectors\BatchConnector;
use LukeWaite\LaravelQueueAwsBatch\Console\QueueWorkBatchCommand;
use DNXLabs\LaravelQueueAwsBatch\Connectors\BatchConnector;
use DNXLabs\LaravelQueueAwsBatch\Console\QueueWorkBatchCommand;

class BatchQueueServiceProvider extends ServiceProvider
{
Expand Down
6 changes: 3 additions & 3 deletions src/Connectors/BatchConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* @copyright 2017 Luke Waite
* @license http://www.opensource.org/licenses/mit-license.php MIT
*
* @link https://github.com/lukewaite/laravel-queue-aws-batch
* @link https://github.com/dnxlabs/laravel-queue-aws-batch
*/

namespace LukeWaite\LaravelQueueAwsBatch\Connectors;
namespace DNXLabs\LaravelQueueAwsBatch\Connectors;

use Aws\Batch\BatchClient;
use Illuminate\Queue\Connectors\DatabaseConnector;
use Illuminate\Support\Arr;
use LukeWaite\LaravelQueueAwsBatch\Queues\BatchQueue;
use DNXLabs\LaravelQueueAwsBatch\Queues\BatchQueue;

class BatchConnector extends DatabaseConnector
{
Expand Down
35 changes: 22 additions & 13 deletions src/Console/QueueWorkBatchCommand.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
* @copyright 2017 Luke Waite
* @license http://www.opensource.org/licenses/mit-license.php MIT
*
* @link https://github.com/lukewaite/laravel-queue-aws-batch
* @link https://github.com/dnxlabs/laravel-queue-aws-batch
*/

namespace LukeWaite\LaravelQueueAwsBatch\Console;
namespace DNXLabs\LaravelQueueAwsBatch\Console;

use Illuminate\Console\Command;
use Illuminate\Container\Container;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Queue\Console\WorkCommand;
use Illuminate\Queue\QueueManager;
use Illuminate\Queue\Worker;
use Illuminate\Queue\WorkerOptions;
use LukeWaite\LaravelQueueAwsBatch\Exceptions\JobNotFoundException;
use LukeWaite\LaravelQueueAwsBatch\Exceptions\UnsupportedException;
use LukeWaite\LaravelQueueAwsBatch\Queues\BatchQueue;
use DNXLabs\LaravelQueueAwsBatch\Exceptions\JobNotFoundException;
use DNXLabs\LaravelQueueAwsBatch\Exceptions\UnsupportedException;
use DNXLabs\LaravelQueueAwsBatch\Queues\BatchQueue;
use Symfony\Component\Debug\Exception\FatalThrowableError;

class QueueWorkBatchCommand extends WorkCommand
Expand All @@ -33,20 +34,24 @@ class QueueWorkBatchCommand extends WorkCommand
{connection? : The name of the queue connection to work}
{--memory=128 : The memory limit in megabytes}
{--timeout=60 : The number of seconds a child process can run}
{--tries=0 : Number of times to attempt a job before logging it failed}';
{--tries=0 : Number of times to attempt a job before logging it failed}
{--force : Force the worker to run even in maintenance mode}
{--queue= : The names of the queues to work}
{--once : Only process the next job on the queue}
{--stop-when-empty : Stop when the queue is empty}';


protected $manager;
protected $exceptions;

public function __construct(QueueManager $manager, Worker $worker, Handler $exceptions)
{
parent::__construct($worker);
parent::__construct($worker, Container::getInstance()->make(Repository::class));
$this->manager = $manager;
$this->exceptions = $exceptions;
}

public function fire()
public function handle()
{
$this->listenForEvents();

Expand All @@ -64,7 +69,7 @@ public function fire()
// TOOD: Refactor out the logic here into an extension of the Worker class
protected function runJob()
{
$connectionName = $this->argument('connection');
$connectionName = $connection = $this->argument('connection') ?: $this->laravel['config']['queue.default'];
$jobId = $this->argument('job_id');

/** @var BatchQueue $connection */
Expand Down Expand Up @@ -98,9 +103,13 @@ protected function runJob()
protected function gatherWorkerOptions()
{
return new WorkerOptions(
0, $this->option('memory'),
$this->option('timeout'), 0,
$this->option('tries'), false
0, // delay
$this->option('memory'),
$this->option('timeout'),
0, // sleep
$this->option('tries'),
false, // force
$this->option('stop-when-empty')
);
}
}
4 changes: 2 additions & 2 deletions src/Exceptions/JobNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* @copyright 2017 Luke Waite
* @license http://www.opensource.org/licenses/mit-license.php MIT
*
* @link https://github.com/lukewaite/laravel-queue-aws-batch
* @link https://github.com/dnxlabs/laravel-queue-aws-batch
*/

namespace LukeWaite\LaravelQueueAwsBatch\Exceptions;
namespace DNXLabs\LaravelQueueAwsBatch\Exceptions;

class JobNotFoundException extends LaravelAwsBatchQueueException
{
Expand Down
Loading