-
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?
Conversation
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.
The property expireDays
should be an integer, not a string.
Casting to an integer doesn't seem to be the correct approach here.
I have also defaulting the constructor argument to be the integer 3.
Let's wait for future feedback, as usually changing a constructor argument is considered a breaking change. So it might be better to add this additional configuration value through a getter and setter methods instead.
/** | ||
* The number of days a failed job should be retained. | ||
* | ||
* @var string | ||
*/ | ||
protected $expireDays; |
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.
/** | |
* The number of days a failed job should be retained. | |
* | |
* @var string | |
*/ | |
protected $expireDays; | |
/** | |
* The number of days a failed job should be retained. | |
* | |
* @var int | |
*/ | |
protected $expireDays; |
{ | ||
$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 comment
The reason will be displayed to describe this comment to others. Learn more.
$this->expireDays = (int) $expireDays; | |
$this->expireDays = $expireDays; |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
$config['expire_days'] ?? '3' | |
$config['expire_days'] ?? 3 |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | |
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', 3); |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | |
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', 3); |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | |
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', 3); |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | |
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', 3); |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', '3'); | |
$provider = new DynamoDbFailedJobProvider($dynamoDbClient, 'application', 'table', 3); |
* @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 comment
The reason will be displayed to describe this comment to others. Learn more.
public function __construct(DynamoDbClient $dynamo, $applicationName, $table, $expireDays) | |
public function __construct(DynamoDbClient $dynamo, $applicationName, $table, $expireDays = 3) |
/** | ||
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
* @param string $expireDays | |
* @param int $expireDays |
This PR adds a new config option for queue.failed (when using DynamoDB):
expire_days
This allows controlling the expires_at value for jobs that are inserted into DynamoDB, instead of the hardcoded value of 3. (Still defaulted to 3 in the absence of the config option)
This pull request introduces changes to the
DynamoDbFailedJobProvider
class to make the expiration period for failed jobs configurable. The main modifications include adding a new property for expiration days, updating the constructor to accept this new parameter, and adjusting the tests to accommodate this change.Key changes:
Configuration of Expiration Days:
src/Illuminate/Queue/Failed/DynamoDbFailedJobProvider.php
: Added a new protected propertyexpireDays
, updated the constructor to acceptexpireDays
as a parameter, and modified thelog
method to use the configurable expiration period. [1] [2]Service Provider Adjustment:
src/Illuminate/Queue/QueueServiceProvider.php
: Updated thedynamoFailedJobProvider
method to pass theexpire_days
configuration value, defaulting to '3' if not provided.Test Updates:
tests/Queue/DynamoDbFailedJobProviderTest.php
: Updated multiple test methods to include theexpireDays
parameter when creatingDynamoDbFailedJobProvider
instances. [1] [2] [3] [4] [5]