-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[11.x] Adds support to allow specifying number of days to keep failed jobs in DynamoDB #54295
base: 11.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,19 +32,28 @@ class DynamoDbFailedJobProvider implements FailedJobProviderInterface | |||||
*/ | ||||||
protected $table; | ||||||
|
||||||
/** | ||||||
* The number of days a failed job should be retained. | ||||||
* | ||||||
* @var string | ||||||
*/ | ||||||
protected $expireDays; | ||||||
|
||||||
/** | ||||||
* Create a new DynamoDb failed job provider. | ||||||
* | ||||||
* @param \Aws\DynamoDb\DynamoDbClient $dynamo | ||||||
* @param string $applicationName | ||||||
* @param string $table | ||||||
* @param string $expireDays | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* @return void | ||||||
*/ | ||||||
public function __construct(DynamoDbClient $dynamo, $applicationName, $table) | ||||||
public function __construct(DynamoDbClient $dynamo, $applicationName, $table, $expireDays) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
$this->table = $table; | ||||||
$this->dynamo = $dynamo; | ||||||
$this->applicationName = $applicationName; | ||||||
$this->expireDays = (int) $expireDays; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -72,7 +81,7 @@ public function log($connection, $queue, $payload, $exception) | |||||
'payload' => ['S' => $payload], | ||||||
'exception' => ['S' => (string) $exception], | ||||||
'failed_at' => ['N' => (string) $failedAt->getTimestamp()], | ||||||
'expires_at' => ['N' => (string) $failedAt->addDays(3)->getTimestamp()], | ||||||
'expires_at' => ['N' => (string) $failedAt->addDays($this->expireDays)->getTimestamp()], | ||||||
], | ||||||
]); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -324,7 +324,8 @@ protected function dynamoFailedJobProvider($config) | |||||
return new DynamoDbFailedJobProvider( | ||||||
new DynamoDbClient($dynamoConfig), | ||||||
$this->app['config']['app.name'], | ||||||
$config['table'] | ||||||
$config['table'], | ||||||
$config['expire_days'] ?? '3' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
); | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -47,7 +47,7 @@ public function testCanProperlyLogFailedJob() | |||||
], | ||||||
]); | ||||||
|
||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table'); | ||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
$provider->log('connection', 'queue', json_encode(['uuid' => (string) $uuid]), $exception); | ||||||
|
||||||
|
@@ -83,7 +83,7 @@ public function testCanRetrieveAllFailedJobs() | |||||
], | ||||||
]); | ||||||
|
||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table'); | ||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
$response = $provider->all(); | ||||||
|
||||||
|
@@ -124,7 +124,7 @@ public function testASingleJobCanBeFound() | |||||
], | ||||||
]); | ||||||
|
||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table'); | ||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
$response = $provider->find('id'); | ||||||
|
||||||
|
@@ -152,7 +152,7 @@ public function testNullIsReturnedIfJobNotFound() | |||||
], | ||||||
])->andReturn([]); | ||||||
|
||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table'); | ||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
$response = $provider->find('id'); | ||||||
|
||||||
|
@@ -171,7 +171,7 @@ public function testJobsCanBeDeleted() | |||||
], | ||||||
])->andReturn([]); | ||||||
|
||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table'); | ||||||
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
$provider->forget('id'); | ||||||
} | ||||||
|
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.