Skip to content

Commit ae8933b

Browse files
authored
Merge pull request #80 from itsC-Ramesh/upgrade
Upgrade project to .NET 8, latest Hangfire.Core reference and fix RID graph warnings
2 parents a072349 + e096010 commit ae8933b

16 files changed

Lines changed: 108 additions & 98 deletions

src/main/Hangfire.Storage.SQLite/CountersAggregator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using Hangfire.Annotations;
22
using Hangfire.Logging;
33
using Hangfire.Server;
4+
using Hangfire.Storage.SQLite.Entities;
45
using System;
56
using System.Linq;
67
using System.Threading;
7-
using Hangfire.Storage.SQLite.Entities;
88

99
namespace Hangfire.Storage.SQLite
1010
{
Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
</PropertyGroup>
6-
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
7-
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>
8-
</PropertyGroup>
9-
<PropertyGroup>
10-
<Version>0.4.2</Version>
11-
<Authors>RaisedApp</Authors>
12-
<Company>RaisedApp</Company>
13-
<Copyright>Copyright © 2019 - Present</Copyright>
14-
<PackageLicenseFile>LICENSE</PackageLicenseFile>
15-
<PackageProjectUrl>https://github.com/raisedapp/Hangfire.Storage.SQLite</PackageProjectUrl>
16-
<RepositoryUrl>https://github.com/raisedapp/Hangfire.Storage.SQLite</RepositoryUrl>
17-
<RepositoryType>git</RepositoryType>
18-
<PackageTags>Hangfire Hangfire-Storage Hangfire-Extension SQLite</PackageTags>
19-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
20-
<title>Hangfire Storage SQLite</title>
21-
<Description>An Alternative SQLite Storage for Hangfire</Description>
22-
<PackageReleaseNotes>
23-
0.4.2
24-
-remove re-entrancy (fixes SQLiteDistributedLock doesn't play right with async #68). Thanks to @kirides
25-
-pause heartbeat timer while processing. Thanks to @kirides
26-
-update expiration using SQL Update statement in a single step. Thanks to @kirides
27-
-Added Heartbeat event (for testing). Thanks to @kirides
28-
-if we no longer own the lock, we immediately dispose the heartbeat timer (fixes Unable to update heartbeat - still happening in .NET 6.0 #69). Thanks to @kirides
29-
</PackageReleaseNotes>
30-
</PropertyGroup>
31-
<ItemGroup>
32-
<None Include="..\..\..\LICENSE">
33-
<Pack>True</Pack>
34-
<PackagePath></PackagePath>
35-
</None>
36-
</ItemGroup>
37-
<ItemGroup>
38-
<PackageReference Include="Hangfire.Core" Version="1.8.0" />
39-
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
40-
</ItemGroup>
3+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
7+
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>
8+
</PropertyGroup>
9+
<PropertyGroup>
10+
<Version>0.4.3</Version>
11+
<Authors>RaisedApp</Authors>
12+
<Company>RaisedApp</Company>
13+
<Copyright>Copyright © 2019 - Present</Copyright>
14+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
15+
<PackageProjectUrl>https://github.com/raisedapp/Hangfire.Storage.SQLite</PackageProjectUrl>
16+
<RepositoryUrl>https://github.com/raisedapp/Hangfire.Storage.SQLite</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
18+
<PackageTags>Hangfire Hangfire-Storage Hangfire-Extension SQLite</PackageTags>
19+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
20+
<title>Hangfire Storage SQLite</title>
21+
<Description>An Alternative SQLite Storage for Hangfire</Description>
22+
<PackageReleaseNotes>
23+
0.4.3
24+
- Upgrade projects to .NET 8.0 (LTS).
25+
- Update dependencies (Hangfire 1.8.23, Newtonsoft.Json 13.0.4).
26+
- Explicitly referenced SQLitePCLRaw.bundle_green 2.1.11 to resolve NETSDK1206 RID-related warnings.
27+
- Support for modern Hangfire 1.8 background process registration (GetStorageWideProcesses).
28+
</PackageReleaseNotes>
29+
</PropertyGroup>
30+
<ItemGroup>
31+
<None Include="..\..\..\LICENSE">
32+
<Pack>True</Pack>
33+
<PackagePath></PackagePath>
34+
</None>
35+
</ItemGroup>
36+
<ItemGroup>
37+
<PackageReference Include="Hangfire.Core" Version="1.8.23" />
38+
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
39+
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
40+
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
41+
</ItemGroup>
4142

4243
</Project>

src/main/Hangfire.Storage.SQLite/HangfireDbContext.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Hangfire.Logging;
22
using Hangfire.Storage.SQLite.Entities;
3-
using Newtonsoft.Json;
43
using SQLite;
54
using System;
65
using System.Threading;
@@ -42,7 +41,7 @@ internal HangfireDbContext(SQLiteConnection connection, string prefix = "hangfir
4241

4342
ConnectionId = Guid.NewGuid().ToString();
4443
}
45-
44+
4645
/// <summary>
4746
/// Initializes initial tables schema for Hangfire
4847
/// </summary>
@@ -62,7 +61,7 @@ public void Init(SQLiteStorageOptions storageOptions)
6261
TryFewTimesDueToConcurrency(() => Database.CreateTable<Set>());
6362
TryFewTimesDueToConcurrency(() => Database.CreateTable<State>());
6463
TryFewTimesDueToConcurrency(() => Database.CreateTable<DistributedLock>());
65-
64+
6665
void TryFewTimesDueToConcurrency(Action action, int times = 10)
6766
{
6867
var current = 0;
@@ -136,7 +135,7 @@ protected virtual void Dispose(bool disposing)
136135
Database = null;
137136
}
138137
}
139-
138+
140139
public void Dispose()
141140
{
142141
Dispose(true);

src/main/Hangfire.Storage.SQLite/PooledHangfireDbContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System;
2-
using SQLite;
1+
using SQLite;
2+
using System;
33

44
namespace Hangfire.Storage.SQLite
55
{
@@ -8,7 +8,7 @@ internal class PooledHangfireDbContext : HangfireDbContext
88
private readonly Action<PooledHangfireDbContext> _onDispose;
99
public bool PhaseOut { get; set; }
1010

11-
internal PooledHangfireDbContext(SQLiteConnection connection, Action<PooledHangfireDbContext> onDispose, string prefix = "hangfire")
11+
internal PooledHangfireDbContext(SQLiteConnection connection, Action<PooledHangfireDbContext> onDispose, string prefix = "hangfire")
1212
: base(connection, prefix)
1313
{
1414
_onDispose = onDispose ?? throw new ArgumentNullException(nameof(onDispose));

src/main/Hangfire.Storage.SQLite/SQLiteDbConnectionFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System;
2-
using SQLite;
1+
using SQLite;
2+
using System;
33

44
namespace Hangfire.Storage.SQLite
55
{

src/main/Hangfire.Storage.SQLite/SQLiteDistributedLock.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class SQLiteDistributedLock : IDisposable
2828
private string EventWaitHandleName => string.Intern($@"{GetType().FullName}.{_resource}");
2929

3030
public event Action<bool> Heartbeat;
31-
31+
3232
/// <summary>
3333
/// Creates SQLite distributed lock
3434
/// </summary>
@@ -117,7 +117,7 @@ private void Acquire(TimeSpan timeout)
117117
return;
118118
}
119119

120-
var waitTime = (int) timeout.TotalMilliseconds / 10;
120+
var waitTime = (int)timeout.TotalMilliseconds / 10;
121121
// either wait for the event to be raised, or timeout
122122
lock (EventWaitHandleName)
123123
{
@@ -134,7 +134,8 @@ private void Acquire(TimeSpan timeout)
134134
/// <exception cref="DistributedLockTimeoutException"></exception>
135135
private void Release()
136136
{
137-
Retry.Twice((retry) => {
137+
Retry.Twice((retry) =>
138+
{
138139

139140
// Remove resource lock (if it's still ours)
140141
var count = _dbContext.DistributedLockRepository.Delete(_ => _.Resource == _resource && _.ResourceKey == _resourceKey);
@@ -150,7 +151,8 @@ private void Cleanup()
150151
{
151152
try
152153
{
153-
Retry.Twice((_) => {
154+
Retry.Twice((_) =>
155+
{
154156
// Delete expired locks (of any owner)
155157
_dbContext.DistributedLockRepository.
156158
Delete(x => x.Resource == _resource && x.ExpireAt < DateTime.UtcNow);

src/main/Hangfire.Storage.SQLite/SQLiteMonitoringApi.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using Hangfire.Common;
1+
using Hangfire.Common;
62
using Hangfire.States;
73
using Hangfire.Storage.Monitoring;
84
using Hangfire.Storage.SQLite.Entities;
95
using Newtonsoft.Json;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
109

1110
namespace Hangfire.Storage.SQLite
1211
{

src/main/Hangfire.Storage.SQLite/SQLiteStorage.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public SQLiteStorage(string databasePath, SQLiteStorageOptions storageOptions)
5858
string.IsNullOrWhiteSpace(databasePath) ? throw new ArgumentNullException(nameof(databasePath)) : databasePath,
5959
SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.NoMutex,
6060
storeDateTimeAsTicks: true
61-
) {BusyTimeout = TimeSpan.FromSeconds(10)}), storageOptions)
61+
)
62+
{ BusyTimeout = TimeSpan.FromSeconds(10) }), storageOptions)
6263
{
6364
}
6465

@@ -135,6 +136,8 @@ public override bool HasFeature(string featureId)
135136
{
136137
if (featureId == null) throw new ArgumentNullException(nameof(featureId));
137138

139+
if (featureId == "JobStorage.ProcessesInsteadOfComponents") return true;
140+
138141
return _features.TryGetValue(featureId, out var isSupported)
139142
? isSupported
140143
: base.HasFeature(featureId);
@@ -187,9 +190,18 @@ private static void ThrowObjectDisposedException()
187190
///
188191
/// </summary>
189192
/// <returns></returns>
190-
#pragma warning disable 618
193+
public override IEnumerable<IBackgroundProcess> GetStorageWideProcesses()
194+
{
195+
yield return new ExpirationManager(this, _storageOptions.JobExpirationCheckInterval);
196+
yield return new CountersAggregator(this, _storageOptions.CountersAggregateInterval);
197+
}
198+
199+
/// <summary>
200+
///
201+
/// </summary>
202+
/// <returns></returns>
203+
[Obsolete("Please use GetStorageWideProcesses instead. Will be removed with Hangfire.Core 2.0.0.")]
191204
public override IEnumerable<IServerComponent> GetComponents()
192-
#pragma warning restore 618
193205
{
194206
yield return new ExpirationManager(this, _storageOptions.JobExpirationCheckInterval);
195207
yield return new CountersAggregator(this, _storageOptions.CountersAggregateInterval);

src/main/Hangfire.Storage.SQLite/SQLiteStorageExtensions.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using Hangfire.Annotations;
22
using System;
3-
using System.Collections.Generic;
4-
using System.Text;
53

64
namespace Hangfire.Storage.SQLite
75
{
@@ -20,9 +18,9 @@ public static IGlobalConfiguration<SQLiteStorage> UseSQLiteStorage(
2018
[NotNull] this IGlobalConfiguration configuration)
2119
{
2220
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
23-
21+
2422
var storage = new SQLiteStorage("Hangfire.db", new SQLiteStorageOptions());
25-
23+
2624
return configuration.UseStorage(storage);
2725
}
2826

@@ -42,9 +40,9 @@ public static IGlobalConfiguration<SQLiteStorage> UseSQLiteStorage(
4240
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
4341
if (nameOrConnectionString == null) throw new ArgumentNullException(nameof(nameOrConnectionString));
4442
if (options == null) options = new SQLiteStorageOptions();
45-
43+
4644
var storage = new SQLiteStorage(nameOrConnectionString, options);
47-
45+
4846
return configuration.UseStorage(storage);
4947
}
5048

src/main/Hangfire.Storage.SQLite/SQLiteWriteOnlyTransaction.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Linq.Expressions;
5-
using System.Text;
6-
using Hangfire.States;
1+
using Hangfire.States;
72
using Hangfire.Storage.SQLite.Entities;
83
using Newtonsoft.Json;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
97

108
namespace Hangfire.Storage.SQLite
119
{
@@ -113,7 +111,8 @@ public override void AddToSet(string key, string value, double score)
113111

114112
public override void Commit()
115113
{
116-
Retry.Twice((attempts) => {
114+
Retry.Twice((attempts) =>
115+
{
117116

118117
lock (_lockObject)
119118
{

0 commit comments

Comments
 (0)