Hangfire.Tags
1.9.0-beta.2
Due to the prefix reservation of Hangfire on Nuget, we had to rename Hangfire.Tags to include an {Author} prefix.
See the version list below for details.
dotnet add package Hangfire.Tags --version 1.9.0-beta.2
NuGet\Install-Package Hangfire.Tags -Version 1.9.0-beta.2
<PackageReference Include="Hangfire.Tags" Version="1.9.0-beta.2" />
paket add Hangfire.Tags --version 1.9.0-beta.2
#r "nuget: Hangfire.Tags, 1.9.0-beta.2"
// Install Hangfire.Tags as a Cake Addin #addin nuget:?package=Hangfire.Tags&version=1.9.0-beta.2&prerelease // Install Hangfire.Tags as a Cake Tool #tool nuget:?package=Hangfire.Tags&version=1.9.0-beta.2&prerelease
Hangfire.Tags
Inspired by the lack of searching and grouping, Hangfire.Tags provides a way to search and group different jobs.
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.
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:
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 | Versions 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. |
-
.NETFramework 4.7.2
- Hangfire.Core (>= 1.8.2)
-
.NETStandard 2.0
- Hangfire.Core (>= 1.8.2)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Hangfire.Tags:
Package | Downloads |
---|---|
Hangfire.Tags.SqlServer
Support for SQL Server for Hangfire.Tags. This seperate library is required in order to search for tags, and proper cleanup. |
|
Hangfire.Tags.PostgreSql
Support for PostgreSql for Hangfire.Tags. This separate library is required in order to search for tags, and proper cleanup. |
|
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.Redis.StackExchange
Support for Redis for Hangfire.Tags. This separate library is required in order to search for tags, and proper cleanup. |
|
Hangfire.Tags.Redis
基于Hangfire.Tags和StackExchange.Redis,提供的Redis版Tags持久化。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.9.0-beta.3 | 8,350 | 7/11/2023 | |
1.9.0-beta.2 | 113 | 6/1/2023 | |
1.9.0-beta.1 | 1,941 | 5/30/2023 | |
1.8.5 | 29,537 | 7/10/2023 | |
1.8.4 | 33,230 | 5/30/2023 | |
1.8.4-beta.1 | 12,397 | 12/16/2022 | |
1.8.3 | 57,160 | 10/20/2022 | |
1.8.2 | 64,254 | 6/15/2022 | |
1.8.1 | 98,174 | 9/29/2021 | |
1.8.0 | 79,815 | 7/20/2021 | |
1.7.3 | 127,199 | 3/26/2021 | |
1.7.2 | 149,631 | 11/23/2020 | |
1.7.1 | 14,146 | 10/3/2020 | |
1.7.0 | 10,835 | 9/28/2020 | |
1.6.5 | 498 | 9/28/2020 | |
1.6.4 | 7,569 | 7/27/2020 | |
1.6.3 | 6,511 | 5/27/2020 | |
1.6.2 | 7,978 | 5/6/2020 | |
1.6.1 | 999 | 4/29/2020 | |
1.6.0 | 1,014 | 4/28/2020 | |
1.5.1 | 9,559 | 4/22/2020 | |
1.5.0 | 13,589 | 4/3/2020 | |
1.0.0 | 12,256 | 1/22/2020 | |
0.8.0 | 32,283 | 5/6/2019 | |
0.7.0 | 1,799 | 4/11/2019 | |
0.6.0 | 3,163 | 10/31/2018 | |
0.5.0 | 1,070 | 10/13/2018 |