Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
Add Laravel 10 support (#5)
Browse files Browse the repository at this point in the history
* Update composer.json

* Laravel 10 upgrades

* Update composer.json
  • Loading branch information
SimplyCorey authored Mar 29, 2023
1 parent 148206b commit 29a0924
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 46 deletions.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"require": {
"php": ">=8.0",
"aws/aws-sdk-php": "^3.189.0",
"league/flysystem": "^3.0",
"illuminate/container": "^9.0.0",
"illuminate/contracts": "^9.0.0",
"illuminate/filesystem": "^9.0.0",
"illuminate/queue": "^9.0.0",
"illuminate/support": "^9.0.0"
"league/flysystem": "~3",
"illuminate/container": "~9|~10",
"illuminate/contracts": "~9|~10",
"illuminate/filesystem": "~9|~10",
"illuminate/queue": "~9|~10",
"illuminate/support": "~9|~10"
},
"require-dev": {
"mockery/mockery": "~1",
"phpunit/phpunit": "~9",
"phpunit/phpunit": "~10",
"friendsofphp/php-cs-fixer": "^3.2"
},
"suggest": {
Expand Down
50 changes: 11 additions & 39 deletions src/SqsDiskQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace SimpleSoftwareIO\SqsDisk;

use Aws\Sqs\SqsClient;
use DateInterval;
use DateTimeInterface;
use Illuminate\Contracts\Queue\Job;
use Illuminate\Support\Arr;
use Illuminate\Queue\SqsQueue;

Expand All @@ -17,50 +20,22 @@ class SqsDiskQueue extends SqsQueue
*/
public const MAX_SQS_LENGTH = 250000;

/**
* The Amazon SQS instance.
*
* @var \Aws\Sqs\SqsClient
*/
protected $sqs;

/**
* The name of the default queue.
*
* @var string
*/
protected $default;

/**
* The disk options to save large payloads.
*
* @var array
*/
protected $diskOptions;

/**
* The queue URL prefix.
*
* @var string
*/
protected $prefix;

/**
* The queue name suffix.
*
* @var string
*/
private $suffix;
protected array $diskOptions;

/**
* Create a new Amazon SQS queue instance.
*
* @param \Aws\Sqs\SqsClient $sqs
* @param SqsClient $sqs
* @param string $default
* @param array $diskOptions
* @param string $prefix
* @param string $suffix
* @param bool $dispatchAfterCommit
* @param bool $dispatchAfterCommit
*
* @return void
*/
Expand All @@ -72,12 +47,9 @@ public function __construct(
$suffix = '',
$dispatchAfterCommit = false,
) {
$this->sqs = $sqs;
$this->default = $default;
$this->diskOptions = $diskOptions;
$this->prefix = $prefix;
$this->suffix = $suffix;
$this->dispatchAfterCommit = $dispatchAfterCommit;

parent::__construct($sqs, $default, $prefix, $suffix, $dispatchAfterCommit);
}

/**
Expand Down Expand Up @@ -115,7 +87,7 @@ public function pushRaw($payload, $queue = null, array $options = [], $delay = 0
/**
* Push a new job onto the queue after a delay.
*
* @param \DateTimeInterface|\DateInterval|int $delay
* @param DateTimeInterface|DateInterval|int $delay
* @param string $job
* @param mixed $data
* @param string|null $queue
Expand All @@ -140,7 +112,7 @@ function ($payload, $queue) use ($delay) {
*
* @param string|null $queue
*
* @return \Illuminate\Contracts\Queue\Job|null
* @return Job|null
*/
public function pop($queue = null)
{
Expand All @@ -162,7 +134,7 @@ public function pop($queue = null)
}

/**
* Delete all of the jobs from the queue.
* Delete all the jobs from the queue.
*
* @param string $queue
*
Expand Down
3 changes: 3 additions & 0 deletions tests/SqsDiskJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ public function testItRemovesTheJobFromTheDiskIfCleanupIsEnabled()
{
$this->mockedFilesystemAdapter->shouldReceive('disk')
->with('s3')
->once()
->andReturnSelf();

$this->mockedFilesystemAdapter->shouldReceive('delete')
->with('prefix/e3cd03ee-59a3-4ad8-b0aa-ee2e3808ac81.json')
->once()
->andReturnSelf();

$this->mockedContainer->shouldReceive('make')
->with('filesystem')
->once()
->andReturn($this->mockedFilesystemAdapter);

$this->mockedSqsClient->shouldReceive('deleteMessage');
Expand Down

0 comments on commit 29a0924

Please sign in to comment.