Skip to content

Commit

Permalink
Add current supported features
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Clase committed Apr 10, 2024
1 parent a53dac2 commit 06cb716
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Version>0.4.1</Version>
<Version>0.4.2</Version>
<Authors>RaisedApp</Authors>
<Company>RaisedApp</Company>
<Copyright>Copyright © 2019 - Present</Copyright>
Expand All @@ -20,7 +20,7 @@
<title>Hangfire Storage SQLite</title>
<Description>An Alternative SQLite Storage for Hangfire</Description>
<PackageReleaseNotes>
0.4.1
0.4.2
- Stability and retry enhancements introduced by: Daniel Lindblom
</PackageReleaseNotes>
</PropertyGroup>
Expand Down
27 changes: 27 additions & 0 deletions src/main/Hangfire.Storage.SQLite/SQLiteStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ public class SQLiteStorage : JobStorage, IDisposable
private readonly SQLiteDbConnectionFactory _dbConnectionFactory;

private readonly SQLiteStorageOptions _storageOptions;

private readonly Dictionary<string, bool> _features = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase)
{
{ "Storage.ExtendedApi", false },
{ "Job.Queue", true },
{ "Connection.GetUtcDateTime", false },
{ "Connection.BatchedGetFirstByLowestScoreFromSet", false },
{ "Connection.GetSetContains", true },
{ "Connection.GetSetCount.Limited", false },
{ "BatchedGetFirstByLowestScoreFromSet", false },
{ "Transaction.AcquireDistributedLock", true },
{ "Transaction.CreateJob", true },
{ "Transaction.SetJobParameter", true },
{ "TransactionalAcknowledge:InMemoryFetchedJob", false },
{ "Monitoring.DeletedStateGraphs", false },
{ "Monitoring.AwaitingJobs", false }
};

private ConcurrentQueue<PooledHangfireDbContext> _dbContextPool = new ConcurrentQueue<PooledHangfireDbContext>();

/// <summary>
Expand Down Expand Up @@ -113,6 +131,15 @@ private void EnqueueOrPhaseOut(PooledHangfireDbContext dbContext)
}
}

public override bool HasFeature(string featureId)
{
if (featureId == null) throw new ArgumentNullException(nameof(featureId));

return _features.TryGetValue(featureId, out var isSupported)
? isSupported
: base.HasFeature(featureId);
}

/// <summary>
/// Returns text representation of the object
/// </summary>
Expand Down
13 changes: 12 additions & 1 deletion src/samples/WebSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
.UseSQLiteStorage("Hangfire.db")
.UseHeartbeatPage(checkInterval: TimeSpan.FromSeconds(10))
.UseJobsLogger());
services.AddHangfireServer();
services.AddHangfireServer(options =>
{
options.Queues = new[] { "test_queue_1", "default" };
});

var app = builder.Build();

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

var t = app.Services.GetService<IBackgroundJobClient>();
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));
t.Enqueue(queue: "test_queue_1", methodCall: () => Console.WriteLine("Testing......"));

app.Run();

0 comments on commit 06cb716

Please sign in to comment.