-
Notifications
You must be signed in to change notification settings - Fork 64
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
Store job attempt in job payload & use Laravel's built-in queue worker #31
Closed
Closed
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8706ab4
port vapor
georgeboot 4adbbd7
New worker
georgeboot eb33481
refactor
georgeboot 4f97d57
refactor
georgeboot 26f3509
Add doc
georgeboot 3a80ea0
Fix indent
georgeboot 50241fc
composer
georgeboot 5ac2dca
Strict types
georgeboot ee43cfb
Code style
georgeboot 76360a7
PHP 7.3
georgeboot 0882be5
refactor
georgeboot 8eaa7c3
Attribute copyright to Taylor Otwell
georgeboot aa1b360
Remove Laravel license
georgeboot 9787ac7
3 tries
georgeboot a35f5e7
Merge branch 'sqs-patch' of https://github.com/georgeboot/laravel-bri…
georgeboot b690f6c
Merge remote-tracking branch 'upstream/master' into sqs-patch
georgeboot 4843447
Laravel 9 support
georgeboot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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,43 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Bref\LaravelBridge\Queue; | ||
|
||
use Illuminate\Queue\Jobs\SqsJob as LaravelSqsJob; | ||
|
||
/** | ||
* @author Taylor Otwell <[email protected]> | ||
* @copyright Copyright (c) 2019, Taylor Otwell | ||
*/ | ||
class SqsJob extends LaravelSqsJob | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function release($delay = 0) | ||
{ | ||
$this->released = true; | ||
|
||
$payload = $this->payload(); | ||
|
||
$payload['attempts'] = ($payload['attempts'] ?? 0) + 1; | ||
|
||
$this->sqs->deleteMessage([ | ||
'QueueUrl' => $this->queue, | ||
'ReceiptHandle' => $this->job['ReceiptHandle'], | ||
]); | ||
|
||
$this->sqs->sendMessage([ | ||
'QueueUrl' => $this->queue, | ||
'MessageBody' => json_encode($payload), | ||
'DelaySeconds' => $this->secondsUntil($delay), | ||
]); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function attempts() | ||
{ | ||
return ($this->payload()['attempts'] ?? 0) + 1; | ||
} | ||
} |
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,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Bref\LaravelBridge\Queue; | ||
|
||
use Illuminate\Contracts\Queue\Job; | ||
use Illuminate\Queue\Worker as LaravelWorker; | ||
use Illuminate\Queue\WorkerOptions; | ||
|
||
class Worker extends LaravelWorker | ||
{ | ||
public function runSqsJob(Job $job, string $connectionName, WorkerOptions $options): void | ||
{ | ||
$this->runJob($job, $connectionName, $options); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnapoli how do you want me to give attribution in this code? phpdoc references are not allowed.