Skip to content
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

Makes SqlServerStorage configurable #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cultiv.Hangfire/HangfireComposer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Hangfire;
using Hangfire;
using Hangfire.Console;
using Hangfire.Dashboard;
using Hangfire.SqlServer;
Expand All @@ -8,6 +7,7 @@
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Web.Common.ApplicationBuilder;
Expand Down Expand Up @@ -87,13 +87,13 @@ public void Compose(IUmbracoBuilder builder)
.UseConsole()
.UseSqlServerStorage((Func<SqlConnection>)ConnectionFactory, new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = true,
EnableHeavyMigrations = true,
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true
PrepareSchemaIfNecessary = settings.StorageOptions.PrepareSchemaIfNecessary,
EnableHeavyMigrations = settings.StorageOptions.EnableHeavyMigrations,
CommandBatchMaxTimeout = settings.StorageOptions.CommandBatchMaxTimeout,
SlidingInvisibilityTimeout = settings.StorageOptions.SlidingInvisibilityTimeout,
QueuePollInterval = settings.StorageOptions.QueuePollInterval,
UseRecommendedIsolationLevel = settings.StorageOptions.UseRecommendedIsolationLevel,
DisableGlobalLocks = settings.StorageOptions.DisableGlobalLocks
});
});

Expand Down
18 changes: 16 additions & 2 deletions Cultiv.Hangfire/HangfireSettings.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
namespace Cultiv.Hangfire;
using System;

namespace Cultiv.Hangfire;

public class HangfireSettings
{
public Server Server { get; set; }
public StorageOptions StorageOptions { get; set; } = new StorageOptions();
}

public class Server
{
public bool? Disabled { get; set; }
public bool? Disabled { get; set; }
}

public class StorageOptions
{
public bool PrepareSchemaIfNecessary { get; set; } = true;
public bool EnableHeavyMigrations { get; set; } = true;
public TimeSpan CommandBatchMaxTimeout { get; set; } = TimeSpan.FromMinutes(5);
public TimeSpan SlidingInvisibilityTimeout { get; set; } = TimeSpan.FromMinutes(5);
public TimeSpan QueuePollInterval { get; set; } = TimeSpan.Zero;
public bool UseRecommendedIsolationLevel { get; set; } = true;
public bool DisableGlobalLocks { get; set; } = true;
}