Skip to content

Commit

Permalink
Support Laravel 10.x (#28)
Browse files Browse the repository at this point in the history
* Support Laravel 10.x
* Improve test config
  • Loading branch information
squigg authored Mar 17, 2023
1 parent b213c57 commit e579e02
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ workflows:
- php/test:
matrix:
parameters:
version: ["8.0", "8.1"]
version: ["8.1", "8.2"]
pre-steps:
- run:
command: sudo pecl install pcov
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

azure-queue-laravel
=============

Expand All @@ -17,6 +18,7 @@ PHP Laravel Queue Driver package to support Microsoft Azure Storage Queues
- PHP 7.2+ for Laravel 6+
- PHP 7.3+ for Laravel 8+
- PHP 8.0+ for Laravel 9+
- PHP 8.1+ for Laravel 10+
- Microsoft Azure Storage Account and Storage Account Key
- Queue container created through Azure Portal or via
[Azure CLI](https://docs.microsoft.com/en-us/cli/azure/storage/queue?view=azure-cli-latest#az-storage-queue-create)
Expand All @@ -29,6 +31,9 @@ You can find this library on [Packagist](https://packagist.org/packages/squigg/a

Require this package in your `composer.json`. The version numbers will follow Laravel.

#### Laravel 10.x
"squigg/azure-queue-laravel": "^10.0"
composer require squigg/azure-queue-laravel:^10.0
#### Laravel 9.x
"squigg/azure-queue-laravel": "^9.0"
composer require squigg/azure-queue-laravel:^9.0
Expand Down Expand Up @@ -127,6 +132,8 @@ Remember to update the default queue by setting the `QUEUE_DRIVER` value in your

## Changelog

2023-03-17 - V10.0 - Support for Laravel 10.x

2022-03-17 - V9.0 - Support for Laravel 9.x

2021-10-16 - V8.1 - Support for PHP 8
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
}
],
"require": {
"php": "^7.3|^8.0",
"illuminate/queue": "^9.0",
"php": "^8.1",
"illuminate/queue": "^10.0",
"microsoft/azure-storage-queue": "~1.3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0|^9.0",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^10.0",
"orchestra/testbench": "^8.0",
"mockery/mockery": "~1.0",
"php-coveralls/php-coveralls": "~2.0",
"ext-json": "*"
Expand All @@ -35,6 +35,9 @@
"Squigg\\AzureQueueLaravel\\": "src/"
}
},
"autoload-dev": {
"psr-4": { "Squigg\\AzureQueueLaravel\\Tests\\": "tests/" }
},
"minimum-stability": "stable",
"extra": {
"laravel": {
Expand Down
10 changes: 0 additions & 10 deletions phpunit.php

This file was deleted.

8 changes: 4 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="true" bootstrap="phpunit.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<!-- List of source files for code coverage checker -->
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
Expand All @@ -12,8 +13,7 @@
<!-- List of files with tests inside -->
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>
<!-- List of source files for code coverage checker -->
</phpunit>
6 changes: 1 addition & 5 deletions src/AzureConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ class AzureConnector implements ConnectorInterface

/**
* Establish a queue connection.
*
* @param array $config
*
* @return \Illuminate\Contracts\Queue\Queue
*/
public function connect(array $config)
public function connect(array $config): AzureQueue
{
$connectionString = 'DefaultEndpointsProtocol=' . $config['protocol'] . ';AccountName=' . $config['accountname'] . ';AccountKey=' . $config['key'];

Expand Down
53 changes: 16 additions & 37 deletions src/AzureJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,22 @@
use Illuminate\Queue\Jobs\Job;
use MicrosoftAzure\Storage\Queue\Internal\IQueue;
use MicrosoftAzure\Storage\Queue\Models\QueueMessage;
use MicrosoftAzure\Storage\Queue\QueueRestProxy;

class AzureJob extends Job implements JobContract
{

/**
* The Azure QueueRestProxy instance.
*
* @var QueueRestProxy
*/
protected $azure;
protected IQueue $azure;

/**
* The Azure QueueMessage instance.
*
* @var QueueMessage
*/
protected $job;
protected QueueMessage $job;

/**
* The queue that the job belongs to.
*
* @var string
*/
protected $queue;

Expand All @@ -43,11 +36,11 @@ class AzureJob extends Job implements JobContract
* @param string $queue
*
*/
public function __construct(Container $container,
IQueue $azure,
QueueMessage $job,
$connectionName,
$queue)
public function __construct(Container $container,
IQueue $azure,
QueueMessage $job,
string $connectionName,
string $queue)
{
$this->azure = $azure;
$this->job = $job;
Expand All @@ -58,10 +51,8 @@ public function __construct(Container $container,

/**
* Delete the job from the queue.
*
* @return void
*/
public function delete()
public function delete(): void
{
parent::delete();
$this->azure->deleteMessage($this->queue, $this->job->getMessageId(), $this->job->getPopReceipt());
Expand All @@ -71,10 +62,8 @@ public function delete()
* Release the job back into the queue.
*
* @param int $delay
*
* @return void
*/
public function release($delay = 0)
public function release($delay = 0): void
{
parent::release($delay);
$this->azure->updateMessage($this->queue, $this->job->getMessageId(), $this->job->getPopReceipt(), null,
Expand All @@ -83,58 +72,48 @@ public function release($delay = 0)

/**
* Get the number of times the job has been attempted.
*
* @return int
*/
public function attempts()
public function attempts(): int
{
return $this->job->getDequeueCount();
}

/**
* Get the IoC container instance.
*
* @return Container
*/
public function getContainer()
public function getContainer(): Container
{
return $this->container;
}

/**
* Get the underlying Azure client instance.
*
* @return QueueRestProxy
*/
public function getAzure()
public function getAzure(): IQueue
{
return $this->azure;
}

/**
* Get the underlying raw Azure job.
*
* @return QueueMessage
*/
public function getAzureJob()
public function getAzureJob(): QueueMessage
{
return $this->job;
}

/**
* @return int
* Get the job ID
*/
public function getJobId()
public function getJobId(): int
{
return $this->job->getMessageId();
}

/**
* Get the raw body string for the job.
*
* @return string
*/
public function getRawBody()
public function getRawBody(): string
{
return $this->job->getMessageText();
}
Expand Down
Loading

0 comments on commit e579e02

Please sign in to comment.