Skip to content

Commit 06cb716

Browse files
author
Felix Clase
committed
Add current supported features
1 parent a53dac2 commit 06cb716

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>
88
</PropertyGroup>
99
<PropertyGroup>
10-
<Version>0.4.1</Version>
10+
<Version>0.4.2</Version>
1111
<Authors>RaisedApp</Authors>
1212
<Company>RaisedApp</Company>
1313
<Copyright>Copyright © 2019 - Present</Copyright>
@@ -20,7 +20,7 @@
2020
<title>Hangfire Storage SQLite</title>
2121
<Description>An Alternative SQLite Storage for Hangfire</Description>
2222
<PackageReleaseNotes>
23-
0.4.1
23+
0.4.2
2424
- Stability and retry enhancements introduced by: Daniel Lindblom
2525
</PackageReleaseNotes>
2626
</PropertyGroup>

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

+27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ public class SQLiteStorage : JobStorage, IDisposable
1414
private readonly SQLiteDbConnectionFactory _dbConnectionFactory;
1515

1616
private readonly SQLiteStorageOptions _storageOptions;
17+
18+
private readonly Dictionary<string, bool> _features = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase)
19+
{
20+
{ "Storage.ExtendedApi", false },
21+
{ "Job.Queue", true },
22+
{ "Connection.GetUtcDateTime", false },
23+
{ "Connection.BatchedGetFirstByLowestScoreFromSet", false },
24+
{ "Connection.GetSetContains", true },
25+
{ "Connection.GetSetCount.Limited", false },
26+
{ "BatchedGetFirstByLowestScoreFromSet", false },
27+
{ "Transaction.AcquireDistributedLock", true },
28+
{ "Transaction.CreateJob", true },
29+
{ "Transaction.SetJobParameter", true },
30+
{ "TransactionalAcknowledge:InMemoryFetchedJob", false },
31+
{ "Monitoring.DeletedStateGraphs", false },
32+
{ "Monitoring.AwaitingJobs", false }
33+
};
34+
1735
private ConcurrentQueue<PooledHangfireDbContext> _dbContextPool = new ConcurrentQueue<PooledHangfireDbContext>();
1836

1937
/// <summary>
@@ -113,6 +131,15 @@ private void EnqueueOrPhaseOut(PooledHangfireDbContext dbContext)
113131
}
114132
}
115133

134+
public override bool HasFeature(string featureId)
135+
{
136+
if (featureId == null) throw new ArgumentNullException(nameof(featureId));
137+
138+
return _features.TryGetValue(featureId, out var isSupported)
139+
? isSupported
140+
: base.HasFeature(featureId);
141+
}
142+
116143
/// <summary>
117144
/// Returns text representation of the object
118145
/// </summary>

src/samples/WebSample/Program.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
.UseSQLiteStorage("Hangfire.db")
1919
.UseHeartbeatPage(checkInterval: TimeSpan.FromSeconds(10))
2020
.UseJobsLogger());
21-
services.AddHangfireServer();
21+
services.AddHangfireServer(options =>
22+
{
23+
options.Queues = new[] { "test_queue_1", "default" };
24+
});
2225

2326
var app = builder.Build();
2427

@@ -27,4 +30,12 @@
2730
RecurringJob.AddOrUpdate("TaskMethod()", (TaskSample t) => t.TaskMethod(), Cron.Minutely);
2831
RecurringJob.AddOrUpdate("TaskMethod2()", (TaskSample t) => t.TaskMethod2(null), Cron.Minutely);
2932

33+
var t = app.Services.GetService<IBackgroundJobClient>();
34+
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
35+
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
36+
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
37+
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
38+
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
39+
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
40+
3041
app.Run();

0 commit comments

Comments
 (0)