FaceIT.Hangfire.Tags 1.9.0

Prefix Reserved
dotnet add package FaceIT.Hangfire.Tags --version 1.9.0                
NuGet\Install-Package FaceIT.Hangfire.Tags -Version 1.9.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FaceIT.Hangfire.Tags" Version="1.9.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FaceIT.Hangfire.Tags --version 1.9.0                
#r "nuget: FaceIT.Hangfire.Tags, 1.9.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FaceIT.Hangfire.Tags as a Cake Addin
#addin nuget:?package=FaceIT.Hangfire.Tags&version=1.9.0

// Install FaceIT.Hangfire.Tags as a Cake Tool
#tool nuget:?package=FaceIT.Hangfire.Tags&version=1.9.0                

Hangfire.Tags

Build status NuGet MIT License Donate

Inspired by the lack of searching and grouping, Hangfire.Tags provides a way to search and group different jobs.

sidemenu dashboard

Contributers

  • Yong Liu: Special thanks for all the pull requests you've created. Thank you so much!
  • Adam Taylor: MySql support

Features

  • 100% Safe: no Hangfire-managed data is ever updated, hence there's no risk to corrupt it.
  • Attributes: supports [Tag("{0}")] syntax for creating a default set of tags when creating a job.
  • Extensions: has extension methods on PerformContext, but also on string (for instance for adding tags to a jobid).
  • Clean up: uses Hangfire sets, which are cleaned when jobs are removed.
  • Filtering: allows filtering of tags based on tags and states, this makes it easy to requeue failed jobs with a certain tag.
  • Searching: allows you to search for tags
  • Storages: has an storage for SQL Server, MySql, PostgreSql and initial Redis support
  • Dark and light mode: supports the new dark and light mode support of Hangfire

Setup

In .NET Core's Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddHangfire(config =>
    {
        config.UseSqlServerStorage("connectionSting");
        // config.UseTagsWithPostgreSql();
        // config.UseTagsWithMySql();
        // config.UseTagsWithRedis();
        config.UseTagsWithSql();
    });
}

Otherwise,

GlobalConfiguration.Configuration
    .UseSqlServerStorage("connectionSting")
    //.UseTagsWithPostgreSql()
    //.UseTagsWithMySql()
    //.UseTagsWithRedis();
    .UseTagsWithSql();

NOTE: If you have Dashboard and Server running separately, you'll need to call UseTags(), UseTagsWithSql(), UseTagsWithPostgreSql(), UseTagsWithMySql() or UseTagsWithRedis() on both.

Sql Options

If you have a custom HangFire schema in your database, you'll need to pass your sql options to your storage method. For example:

        var tagsOptions = new TagsOptions() { TagsListStyle = TagsListStyle.Dropdown };
        var hangfireSqlOptions = new SqlServerStorageOptions
        {
            SchemaName = "MyCustomHangFireSchema",
        };
        services.AddHangfire(hangfireConfig => hangfireConfig
            .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
            .UseColouredConsoleLogProvider()
            .UseSimpleAssemblyNameTypeSerializer()
            .UseRecommendedSerializerSettings()
            .UseSqlServerStorage("dbConnection", hangfireSqlOptions)
            .UseTagsWithSql(tagsOptions, hangfireSqlOptions)
        );

Additional options

As usual, you may provide additional options for UseTags() method.

Here's what you can configure:

  • TagColor/DarkTagColor - default background color for the tags
  • TextColor/TextColor - default text color of the tags
  • Tags interface - you can specify an autocomplete tags search (Yong Liu)
  • MaxLength - the maximum length of the tags, automatically set to 100 for SQL Server

NOTE: After you initially add Hangfire.Tags (or change the options above) you may need to clear browser cache, as generated CSS/JS can be cached by browser.

Providers

In order to properly cleanup tags for expired jobs, an extension is required for the default storage providers. Right now, there are three providers: for SQL server, for PostgreSQL and for MySql.

Tags

Hangfire.Tags provides extension methods on PerformContext object, hence you'll need to add it as a job argument.

NOTE: Like IJobCancellationToken, PerformContext is a special argument type which Hangfire will substitute automatically. You should pass null when enqueuing a job.

Now you can add a tag:

public void TaskMethod(PerformContext context)
{
    context.AddTag("Hello, world!");
}

which results in the tag hello-world.

You can also add tags using attributes, either on the class, or on the method (or both!)

[Tag("TaskMethod")]
public void TaskMethod(PerformContext context)
{
    ....
}

Search tags

In the Dashboard, when clicking on Jobs, you'll see a new menu item, called Tags. By default this page will show you all defined tags in the system. Clicking on a tag will show a list of all jobs with that tag attached.

The default view for showing the tags is a so called tagcloud. If you prefer an autocomplete dropdown list, you can specify that using the options:

var options = new TagsOptions()
{
   TagsListStyle = TagsListStyle.Dropdown
};
config.UseTagsWithSql(options);

The result will look like this: tagsearch

License

Copyright (c) 2018 2Face-IT B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on FaceIT.Hangfire.Tags:

Package Downloads
Hangfire.HttpJob

httpjob for Hangfire(基于hangfire的webjob调度服务)

FaceIT.Hangfire.Tags.SqlServer

Support for SQL Server for Hangfire.Tags. This seperate library is required in order to search for tags, and proper cleanup.

FaceIT.Hangfire.Tags.PostgreSql

Support for PostgreSql for Hangfire.Tags. This separate library is required in order to search for tags, and proper cleanup.

FaceIT.Hangfire.Tags.Pro.Redis

Support for Redis for Hangfire.Tags. This separate library is required in order to search for tags, and proper cleanup.

Hangfire.Tags.MemoryStorage

Enables Tags (https://github.com/face-it/Hangfire.Tags) for MemoryStorage (https://github.com/perrich/Hangfire.MemoryStorage)

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on FaceIT.Hangfire.Tags:

Repository Stars
yuzd/Hangfire.HttpJob
httpjob for Hangfire,restful api for Hangfire,job调度与业务分离
Version Downloads Last updated
1.9.0 22,073 7/2/2024
1.9.0-beta.5 395 7/2/2024
1.9.0-beta.4 74,129 7/24/2023
1.9.0-beta.3 886 7/20/2023
1.9.0-beta.2 95 7/20/2023
1.8.5 74,177 7/20/2023