{"id":20893113,"url":"https://github.com/hangfireio/hangfire.dynamicjobs","last_synced_at":"2025-05-12T22:32:24.978Z","repository":{"id":172716691,"uuid":"649589371","full_name":"HangfireIO/Hangfire.DynamicJobs","owner":"HangfireIO","description":"Dynamic recurring jobs for Hangfire to support multiple code bases with single storage","archived":false,"fork":false,"pushed_at":"2024-03-27T04:28:55.000Z","size":5022,"stargazers_count":21,"open_issues_count":2,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-04-27T05:42:57.137Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HangfireIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-06-05T07:58:36.000Z","updated_at":"2024-02-19T19:56:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd38aad2-33c8-4eb6-ba2b-8472d11a2cf3","html_url":"https://github.com/HangfireIO/Hangfire.DynamicJobs","commit_stats":null,"previous_names":["hangfireio/hangfire.dynamicjobs"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HangfireIO%2FHangfire.DynamicJobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HangfireIO%2FHangfire.DynamicJobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HangfireIO%2FHangfire.DynamicJobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HangfireIO%2FHangfire.DynamicJobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HangfireIO","download_url":"https://codeload.github.com/HangfireIO/Hangfire.DynamicJobs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225156969,"owners_count":17429701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T10:14:42.694Z","updated_at":"2024-11-18T10:14:42.801Z","avatar_url":"https://github.com/HangfireIO.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hangfire.DynamicJobs\n\nThe [`Hangfire.DynamicJobs`](https://www.nuget.org/packages/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.\n\nHangfire 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.\n\n## Configuration\n\nThe `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.\n\nFor newer applications you can call the `UseDynamicJobs` method when configuring Hangfire with the `AddHangfire` method:\n\n```csharp\nservices.AddHangfire(confiuration =\u003e configuration.\n    .UseDynamicJobs()\n    .UseXXX()); // other configuration methods\n```\n\nFor older applications, please place the call where `GlobalConfiguration` class is used:\n\n```csharp\nGlobalConfiguration.Configuration\n    .UseDynamicJobs()\n    .UseXXX(); // other configuration methods\n```\n\n## Usage\n\nThis 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.\n\n```csharp\nIRecurringJobManager manager = new RecurringJobManager(); // or obtain instance using dependency injection\n\nmanager.AddOrUpdateDynamic\u003cINewsletterService\u003e(\"monthly-newsletter\", x =\u003e x.SendMonthly(), Cron.Monthly());\n```\n\n### Passing filters and options\n\nDynamic 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](https://github.com/HangfireIO/Hangfire/issues).\n\nYou can also use the `DynamicRecurringJobOptions` class to pass other recurring job options as previously.\n\n```csharp\nIRecurringJobManager manager = new RecurringJobManager(); // or obtain instance using dependency injection\n\nmanager.AddOrUpdateDynamic\u003cINewsletterService\u003e(\n    \"monthly-newsletter\",\n    x =\u003e x.SendMonthly(),\n    Cron.Monthly(),\n    new DynamicRecurringJobOptions()\n    {\n        Filters = new [] { new MyFilterAttribute(\"newsletter\") },\n        TimeZone = TimeZoneInfo.Local\n    });\n```\n\n## Questions? Problems?\n\nIf you've discovered a bug, please report it to the [Hangfire GitHub Issues](https://github.com/HangfireIO/Hangfire/issues). Detailed reports with stack traces, and actual and expected behaviors are welcome.\n\n## Building the sources\n\nTo 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.\n\n```\nbuild\n```\n\nTo 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.\n\n```\nbuild pack\n```\n\nTo see the full list of available commands, pass the `-docs` switch:\n\n```\nbuild -docs\n```\n\nHangfire uses [psake](https://github.com/psake/psake) build automation tool. All psake tasks and functions are defined in `psake-project`.ps1`.\n\n## License\n\nCopyright \u0026copy; 2023 Hangfire OÜ. Please see the [`LICENSE`](https://github.com/HangfireIO/Hangfire.DynamicJobs/blob/main/LICENSE) file for details.\n\n## Legal\n\nBy 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Ü.\n\nIf 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.\n\nThis 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhangfireio%2Fhangfire.dynamicjobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhangfireio%2Fhangfire.dynamicjobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhangfireio%2Fhangfire.dynamicjobs/lists"}