Hangfire Search - #2414
Hangfire Search#2414fairking wants to merge 4 commits into
Conversation
|
Hello @fairking! The feature is really nice and looks awesome, but it can't be merged with Hangfire, because of breaking changes. A lot of packages, storages depend on this API, and we can't break everything. So the only viable option I see currently is to think how to make this as an extension package for Hangfire, but unfortunately I can't guide you this way, because it's not a trivial thing. |
Thanks @odinserj for you honest opinion. Of course I would do it as an extension if it was possible. But I don't want to waste time by creating some crazy workarounds. I would like everything to be simple and straight forward. I see the following options:
|
|
What about just adding an overload with and without That would solve the breaking changes. |
I think this would be the most obvious solution - If you wanted to remove entirely for |
|
@fairking Instead of extending or modifying IMonitoringApi and the existing methods directly, an alternative would be to completely isolate the search and filtering logic as a new system capability. The idea would be to introduce a new tab or section dedicated exclusively to advanced search within the dashboard, decoupled from the existing monitoring views. From a technical perspective, this could be implemented through: Extension methods for JobStorage Extension methods for the monitoring API An optional feature/capability that each storage implementation may support or not With this approach: Existing contracts remain untouched There is no need to modify current methods or add additional parameters to already public APIs Storage providers can adopt the feature progressively The UI can enable or disable the experience depending on the capabilities supported by the storage Additionally, this model opens the door to much more flexible scenarios than a simple Contains search over jobs. For example: Search by states Search by specific fields Search by method or type name Search over arguments Chained filters Advanced query syntax in the future Essentially, this would behave more like a dedicated search engine layer, separated from the traditional monitoring APIs. The main benefit is that search would no longer be a side effect embedded into existing monitoring APIs, but instead become an independent, extensible, and evolvable feature. This could even be exposed through a capability validation mechanism (for example, SupportsAdvancedSearch), allowing the core to automatically enable the functionality only when the underlying storage supports it. With this approach, we could introduce this capability into the Hangfire core without introducing breaking changes or impacting existing IMonitoringApi implementations. |
|
If someone is willing to implement the required tests to validate the integration of these two new extension methods for advanced job search, I’d be open to moving forward with the PR and submitting the changes. For now, the idea is to keep it as a transparent and fully configurable feature, exposed as a new capability supported by JobStorage on top of the monitoring API. It would even be possible to add support for JSON_VALUE and create indexes by detecting the database engine version, dynamically generating the query for each type of filter based on that information. @odinserj Do you see this possibility as viable?
Examples changes:
|



Introducing search in Hangfire Dashboard.
Minimal changes, but PLEASE BE AWARE there are breaking changes (see IMonitoringApi.cs) which I cannot see how we can avoid. On the other hand the search implementation could be very easy task for other projects derived from
IMonitoringApi.Search works as "Contains" and applies to the following fields:
Search is available in:
Note:
State(exception messages or time executed). Could be improved later. But I found it less important than the search by method name or arguments.Flexibility:
The search field which introduced in this PR could allow us to customize the search abilities in future. For example we can introduce some kind of language which would allow to search by multiple fields. Or use third party extensions which would do that. Or add such improvements in PRO version. Similar how github search field works. Eg:
MyJob// Search in job InvocationData only,arg:9c5b94b1-35ad-49bb-b118-8e8fc24abf80// Search in job Arguments by entity ID,state:NullReferenceException// Search in state data by exception,date:2024-01-01// Search by state date,param:RecurringJobId="easy_job1"// Search by job parameterparam:Tenant="ABC"// Another search by job parameterMyJob,state:NullReferenceException,date:2024-01-01// Search by multiple fields,MyJob,param:Tenant="ABC"// Another search by multiple fields,Closes #2287
Closes #2253
Closes #717
Screenshots: