Skip to content

Commit 40d8416

Browse files
committed
Added JobExpirationCheckInterval property to PostgreSqlStorageOptions to make it configurable from the default of 1 hour
This setting determines how often expired jobs are detected within ExpirationManager
1 parent e920229 commit 40d8416

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Hangfire.PostgreSql/ExpirationManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal class ExpirationManager : IBackgroundProcess, IServerComponent
5656
private readonly TimeSpan _checkInterval;
5757

5858
public ExpirationManager(PostgreSqlStorage storage, PostgreSqlStorageOptions options)
59-
: this(storage, options, TimeSpan.FromHours(1))
59+
: this(storage, options, options.JobExpirationCheckInterval)
6060
{
6161
}
6262

src/Hangfire.PostgreSql/PostgreSqlStorageOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ public class PostgreSqlStorageOptions
2929
private TimeSpan _invisibilityTimeout;
3030
private TimeSpan _distributedLockTimeout;
3131
private TimeSpan _transactionSerializationTimeout;
32+
private TimeSpan _jobExpirationCheckInterval;
3233

3334
public PostgreSqlStorageOptions()
3435
{
3536
QueuePollInterval = TimeSpan.FromSeconds(15);
3637
InvisibilityTimeout = TimeSpan.FromMinutes(30);
3738
DistributedLockTimeout = TimeSpan.FromMinutes(10);
3839
TransactionSynchronisationTimeout = TimeSpan.FromMilliseconds(500);
40+
JobExpirationCheckInterval = TimeSpan.FromHours(1);
3941
SchemaName = "hangfire";
4042
UseNativeDatabaseTransactions = true;
4143
PrepareSchemaIfNecessary = true;
@@ -81,6 +83,16 @@ public TimeSpan TransactionSynchronisationTimeout
8183
}
8284
}
8385

86+
public TimeSpan JobExpirationCheckInterval
87+
{
88+
get => _jobExpirationCheckInterval;
89+
set
90+
{
91+
ThrowIfValueIsNotPositive(value, nameof(JobExpirationCheckInterval));
92+
_jobExpirationCheckInterval = value;
93+
}
94+
}
95+
8496
public bool UseNativeDatabaseTransactions { get; set; }
8597
public bool PrepareSchemaIfNecessary { get; set; }
8698
public string SchemaName { get; set; }

0 commit comments

Comments
 (0)