Hangfire.DynamicJobs 0.2.0

Prefix Reserved
dotnet add package Hangfire.DynamicJobs --version 0.2.0                
NuGet\Install-Package Hangfire.DynamicJobs -Version 0.2.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="Hangfire.DynamicJobs" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hangfire.DynamicJobs --version 0.2.0                
#r "nuget: Hangfire.DynamicJobs, 0.2.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 Hangfire.DynamicJobs as a Cake Addin
#addin nuget:?package=Hangfire.DynamicJobs&version=0.2.0

// Install Hangfire.DynamicJobs as a Cake Tool
#tool nuget:?package=Hangfire.DynamicJobs&version=0.2.0                

Hangfire.DynamicJobs

The Hangfire.DynamicJobs package provides dynamic recurring jobs for Hangfire to support multiple code bases with single storage. It does so by wrapping the original job with the DynamicJob type available in this package, so no reference to the assembly that contains the original job type is required neither for the recurring job manager nor for the Dashboard UI – only Hangfire.DynamicJobs package should be referenced. The original job type will be deserialized and performed as usual during the invocation process.

Hangfire 1.8.0 or later is required for this package. It doesn't use any special storage methods, so it's possible to use any of them.

Configuration

The UseDynamicJobs configuration method should be called during the initialization process. This method will add a custom job renderer for the Dashboard UI to make dynamic jobs more transparent, a special job filter provider implementation that knows how to deal with serialized filters that can be passed when creating a dynamic job.

For newer applications you can call the UseDynamicJobs method when configuring Hangfire with the AddHangfire method:

services.AddHangfire(confiuration => configuration.
    .UseDynamicJobs()
    .UseXXX()); // other configuration methods

For older applications, please place the call where GlobalConfiguration class is used:

GlobalConfiguration.Configuration
    .UseDynamicJobs()
    .UseXXX(); // other configuration methods

Usage

This package adds the AddOrUpdateDynamic method overloads for the IRecurringJobManager interface that you can use to create dynamic jobs. Everything you need is to pass the arguments as previously when creating a recurring job. Please note that there are no overloads available for the RecurringJob static class, so an instance of the IRecurringJobManager service is required.

IRecurringJobManager manager = new RecurringJobManager(); // or obtain instance using dependency injection

manager.AddOrUpdateDynamic<INewsletterService>("monthly-newsletter", x => x.SendMonthly(), Cron.Monthly());

Passing filters and options

Dynamic jobs don't have access to extension filters applied to the original type or method. However, it is possible to pass them dynamically by using the Filters property of the DynamicRecurringJobOptions class (that inherits the RecurringJobOptions) as shown below. In this case, all the given filters will be serialized with the job, and the job filter provider registered with the UseDynamicJobs method call will be used to activate them. Please note that not all filters can support serialization at this stage, if you found any problem, please report this by creating a GitHub issue.

You can also use the DynamicRecurringJobOptions class to pass other recurring job options as previously.

IRecurringJobManager manager = new RecurringJobManager(); // or obtain instance using dependency injection

manager.AddOrUpdateDynamic<INewsletterService>(
    "monthly-newsletter",
    x => x.SendMonthly(),
    Cron.Monthly(),
    new DynamicRecurringJobOptions()
    {
        Filters = new [] { new MyFilterAttribute("newsletter") },
        TimeZone = TimeZoneInfo.Local
    });

Questions? Problems?

If you've discovered a bug, please report it to the Hangfire GitHub Issues. Detailed reports with stack traces, and actual and expected behaviors are welcome.

Building the sources

To build a solution and get assembly files, just run the following command. All build artifacts, including *.pdb files will be placed into the build folder. Before proposing a pull request, please use this command to ensure everything is ok. Btw, you can execute this command from the Package Manager Console window.

build

To build NuGet packages as well as an archive file, use the pack command as shown below. You can find the result files in the build folder.

build pack

To see the full list of available commands, pass the -docs switch:

build -docs

Hangfire uses psake build automation tool. All psake tasks and functions are defined in psake-project.ps1`.

License

Copyright © 2023 Hangfire OÜ. Please see the LICENSE file for details.

By submitting a Pull Request, you disavow any rights or claims to any changes submitted to the Hangfire project and assign the copyright of those changes to Hangfire OÜ.

If you cannot or do not want to reassign those rights (your employment contract with your employer may not allow this), you should not submit a PR. Open an issue and someone else can do the work.

This is a legal way of saying "If you submit a PR to us, that code becomes ours". 99.9% of the time that's what you intend anyways; we hope it doesn't scare you away from contributing.

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 netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net451 is compatible.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.0 17,569 2/22/2024
0.1.1 8,231 6/6/2023
0.1.0 143 6/5/2023

https://github.com/HangfireIO/Hangfire.DynamicJobs/releases

0.2.0
• Project – Enable source link support with embedded symbols and repository-based sources.
• Project – Sign NuGet package and .NET assemblies on build with a company's own certificate.
• Project – Add readme file and icon to the NuGet package.
• Project – Require NuGet package signature validation on restore.
• Project – Restore NuGet package dependencies with a lock file in a locked mode.
• Project – Enable static analysis via the Microsoft.CodeAnalysis.NetAnalyzers package.

0.1.1
• Fixed – System.ArgumentNullException: Value cannot be null. (Parameter 'source').

0.1.0
Initial release