-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b754325
Showing
14 changed files
with
507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2014 Mark Manos | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# AWS SQS push queue driver for Laravel 4 | ||
|
||
This package provides a laravel queue driver with support for AWS SQS push queues. This technique is used by the AWS Elastic Beanstalk worker tier environments. | ||
|
||
## Installation Via Composer | ||
|
||
Add this to you composer.json file, in the require object: | ||
|
||
```javascript | ||
"mmanos/laravel-sqspushqueue": "dev-master" | ||
``` | ||
|
||
After that, run composer install to install the package. | ||
|
||
Add the service provider to `app/config/app.php`, within the `providers` array. | ||
|
||
```php | ||
'providers' => array( | ||
// ... | ||
'Mmanos\SqsPushQueue\SqsPushQueueServiceProvider', | ||
) | ||
``` | ||
|
||
## Configuration | ||
|
||
Update the existing `queue.php` config file and change the sqs driver to be `sqspush`. This driver will use the existing sqs config properites (`key`, `secret`, etc...). | ||
|
||
#### Dependencies | ||
|
||
The following dependencies are needed for this package: | ||
|
||
* AWS: `aws/aws-sdk-php` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "mmanos/laravel-sqspushqueue", | ||
"description": "An AWS SQS push queue driver for Laravel 4.", | ||
"keywords": ["laravel", "queue", "aws", "sqs", "push", "elasticbeanstalk", "elastic", "beanstalk", "worker"], | ||
"authors": [ | ||
{ | ||
"name": "Mark Manos", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"illuminate/support": "4.*" | ||
}, | ||
"suggest": { | ||
"aws/aws-sdk-php": "2.*" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"Mmanos\\SqsPushQueue\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "stable", | ||
"license": "MIT" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php namespace Mmanos\SqsPushQueue; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Queue\Connectors\ConnectorInterface; | ||
use Aws\Sqs\SqsClient; | ||
use Illuminate\Queue\SqsQueue; | ||
|
||
class Connector implements ConnectorInterface { | ||
|
||
/** | ||
* The current request instance. | ||
* | ||
* @var \Illuminate\Http\Request | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* Create a new Iron connector instance. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return void | ||
*/ | ||
public function __construct(Request $request) | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* Establish a queue connection. | ||
* | ||
* @param array $config | ||
* @return \Illuminate\Queue\QueueInterface | ||
*/ | ||
public function connect(array $config) | ||
{ | ||
$sqs = SqsClient::factory($config); | ||
|
||
return new Queue($sqs, $this->request, $config['queue']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php namespace Mmanos\SqsPushQueue; | ||
|
||
use Illuminate\Queue\Jobs\Job as AbstractJob; | ||
use Aws\Sqs\SqsClient; | ||
use Illuminate\Container\Container; | ||
use Exception; | ||
|
||
class Job extends AbstractJob { | ||
|
||
/** | ||
* The Amazon SQS client instance. | ||
* | ||
* @var \Aws\Sqs\SqsClient | ||
*/ | ||
protected $sqs; | ||
|
||
/** | ||
* The Amazon SQS job instance. | ||
* | ||
* @var array | ||
*/ | ||
protected $job; | ||
|
||
/** | ||
* Create a new job instance. | ||
* | ||
* @param \Illuminate\Container\Container $container | ||
* @param \Aws\Sqs\SqsClient $sqs | ||
* @param array $job | ||
* @return void | ||
*/ | ||
public function __construct(Container $container, | ||
SqsClient $sqs, | ||
array $job) | ||
{ | ||
$this->sqs = $sqs; | ||
$this->job = $job; | ||
$this->container = $container; | ||
} | ||
|
||
/** | ||
* Fire the job. | ||
* | ||
* @return void | ||
*/ | ||
public function fire() | ||
{ | ||
$body = json_decode($this->getRawBody(), true); | ||
$this->resolveAndFire($body); | ||
} | ||
|
||
/** | ||
* Get the raw body string for the job. | ||
* | ||
* @return string | ||
*/ | ||
public function getRawBody() | ||
{ | ||
return $this->job['Body']; | ||
} | ||
|
||
/** | ||
* Release the job back into the queue. | ||
* | ||
* @param int $delay | ||
* @return void | ||
*/ | ||
public function release($delay = 0) | ||
{ | ||
throw new Exception('Release'); | ||
} | ||
|
||
/** | ||
* Get the number of times the job has been attempted. | ||
* | ||
* @return int | ||
*/ | ||
public function attempts() | ||
{ | ||
return (int) $this->job['Attributes']['ApproximateReceiveCount']; | ||
} | ||
|
||
/** | ||
* Get the job identifier. | ||
* | ||
* @return string | ||
*/ | ||
public function getJobId() | ||
{ | ||
return $this->job['MessageId']; | ||
} | ||
|
||
/** | ||
* Get the IoC container instance. | ||
* | ||
* @return \Illuminate\Container\Container | ||
*/ | ||
public function getContainer() | ||
{ | ||
return $this->container; | ||
} | ||
|
||
/** | ||
* Get the underlying SQS client instance. | ||
* | ||
* @return \Aws\Sqs\SqsClient | ||
*/ | ||
public function getSqs() | ||
{ | ||
return $this->sqs; | ||
} | ||
|
||
/** | ||
* Get the underlying raw SQS job. | ||
* | ||
* @return array | ||
*/ | ||
public function getSqsJob() | ||
{ | ||
return $this->job; | ||
} | ||
|
||
} |
Oops, something went wrong.